Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/src/discovery.c 2014-07-13 15:39:25.618377527 +0200
- +++ b/src/discovery.c 2014-07-13 16:33:49.661124198 +0200
- @@ -61,12 +61,10 @@
- parseForHostUniq(UINT16_t type, UINT16_t len, unsigned char *data,
- void *extra)
- {
- - int *val = (int *) extra;
- - if (type == TAG_HOST_UNIQ && len == sizeof(pid_t)) {
- - pid_t tmp;
- - memcpy(&tmp, data, len);
- - if (tmp == getpid()) {
- - *val = 1;
- + char *val = (char *) extra;
- + if (type == TAG_HOST_UNIQ && len == strlen(val)) {
- + if (strcmp(data, val)) {
- + *val = 0;
- }
- }
- }
- @@ -85,16 +83,15 @@
- static int
- packetIsForMe(PPPoEConnection *conn, PPPoEPacket *packet)
- {
- - int forMe = 0;
- -
- + char uniq = conn->useHostUniq;
- /* If packet is not directed to our MAC address, forget it */
- if (memcmp(packet->ethHdr.h_dest, conn->myEth, ETH_ALEN)) return 0;
- /* If we're not using the Host-Unique tag, then accept the packet */
- if (!conn->useHostUniq) return 1;
- - parsePacket(packet, parseForHostUniq, &forMe);
- - return forMe;
- + parsePacket(packet, parseForHostUniq, uniq);
- + return uniq;
- }
- /**********************************************************************
- @@ -284,14 +281,14 @@
- /* If we're using Host-Uniq, copy it over */
- if (conn->useHostUniq) {
- PPPoETag hostUniq;
- - pid_t pid = getpid();
- + int len = strlen(conn->useHostUniq);
- hostUniq.type = htons(TAG_HOST_UNIQ);
- - hostUniq.length = htons(sizeof(pid));
- - memcpy(hostUniq.payload, &pid, sizeof(pid));
- - CHECK_ROOM(cursor, packet.payload, sizeof(pid) + TAG_HDR_SIZE);
- - memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE);
- - cursor += sizeof(pid) + TAG_HDR_SIZE;
- - plen += sizeof(pid) + TAG_HDR_SIZE;
- + hostUniq.length = htons(len);
- + memcpy(hostUniq.payload, conn->useHostUniq, len);
- + CHECK_ROOM(cursor, packet.payload, len + TAG_HDR_SIZE);
- + memcpy(cursor, &hostUniq, len + TAG_HDR_SIZE);
- + cursor += len + TAG_HDR_SIZE;
- + plen += len + TAG_HDR_SIZE;
- }
- packet.length = htons(plen);
- @@ -454,14 +451,14 @@
- /* If we're using Host-Uniq, copy it over */
- if (conn->useHostUniq) {
- PPPoETag hostUniq;
- - pid_t pid = getpid();
- + int len = strlen(conn->useHostUniq);
- hostUniq.type = htons(TAG_HOST_UNIQ);
- - hostUniq.length = htons(sizeof(pid));
- - memcpy(hostUniq.payload, &pid, sizeof(pid));
- - CHECK_ROOM(cursor, packet.payload, sizeof(pid)+TAG_HDR_SIZE);
- - memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE);
- - cursor += sizeof(pid) + TAG_HDR_SIZE;
- - plen += sizeof(pid) + TAG_HDR_SIZE;
- + hostUniq.length = htons(len);
- + memcpy(hostUniq.payload, &conn->useHostUniq, len);
- + CHECK_ROOM(cursor, packet.payload, len+TAG_HDR_SIZE);
- + memcpy(cursor, &hostUniq, len + TAG_HDR_SIZE);
- + cursor += len + TAG_HDR_SIZE;
- + plen += len + TAG_HDR_SIZE;
- }
- /* Copy cookie and relay-ID if needed */
- --- a/src/pppoe.c 2014-07-13 15:28:11.000000000 +0200
- +++ b/src/pppoe.c 2014-07-13 15:45:34.774387413 +0200
- @@ -415,7 +415,7 @@
- " -A -- Print access concentrator names and exit.\n"
- " -S name -- Set desired service name.\n"
- " -C name -- Set desired access concentrator name.\n"
- - " -U -- Use Host-Unique to allow multiple PPPoE sessions.\n"
- + " -U unique -- Use Host-Unique to allow multiple PPPoE sessions.\n"
- " -s -- Use synchronous PPP encapsulation.\n"
- " -m MSS -- Clamp incoming and outgoing MSS options.\n"
- " -p pidfile -- Write process-ID to pidfile.\n"
- @@ -479,9 +479,9 @@
- char const *options;
- #ifdef DEBUGGING_ENABLED
- - options = "I:VAT:D:hS:C:Usm:np:e:kdf:F:t:H:";
- + options = "I:VAT:D:hS:C:U:sm:np:e:kdf:F:t:H:";
- #else
- - options = "I:VAT:hS:C:Usm:np:e:kdf:F:t:H:";
- + options = "I:VAT:hS:C:U:sm:np:e:kdf:F:t:H:";
- #endif
- while((opt = getopt(argc, argv, options)) != -1) {
- switch(opt) {
- @@ -581,7 +581,7 @@
- conn.synchronous = 1;
- break;
- case 'U':
- - conn.useHostUniq = 1;
- + SET_STRING(conn.useHostUniq, optarg);
- break;
- #ifdef DEBUGGING_ENABLED
- case 'D':
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement