X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fplugins%2Frp-pppoe%2Fcommon.c;h=9ea7fd609c8774aafbaf2cbe9bb6a6d86679b516;hb=f1e3aa2dc7e7772d8491c6ff61e4e6d28af33d4b;hp=a49efe7e43546525a6673380430b25da66e9e068;hpb=427e3d851c86e35655e14f1dfa9c831a8fab94d9;p=ppp.git diff --git a/pppd/plugins/rp-pppoe/common.c b/pppd/plugins/rp-pppoe/common.c index a49efe7..9ea7fd6 100644 --- a/pppd/plugins/rp-pppoe/common.c +++ b/pppd/plugins/rp-pppoe/common.c @@ -58,14 +58,14 @@ parsePacket(PPPoEPacket *packet, ParseFunc *func, void *extra) } /* Do some sanity checks on packet */ - if (len > ETH_DATA_LEN - 6) { /* 6-byte overhead for PPPoE header */ + if (len > ETH_JUMBO_LEN - PPPOE_OVERHEAD) { /* 6-byte overhead for PPPoE header */ error("Invalid PPPoE packet length (%u)", len); return -1; } /* Step through the tags */ curTag = packet->payload; - while(curTag - packet->payload < len) { + while (curTag - packet->payload + TAG_HDR_SIZE <= len) { /* Alignment is not guaranteed, so do this by hand... */ tagType = (curTag[0] << 8) + curTag[1]; tagLen = (curTag[2] << 8) + curTag[3]; @@ -119,15 +119,11 @@ sendPADT(PPPoEConnection *conn, char const *msg) conn->session = 0; /* If we're using Host-Uniq, copy it over */ - if (conn->useHostUniq) { - PPPoETag hostUniq; - pid_t pid = getpid(); - hostUniq.type = htons(TAG_HOST_UNIQ); - hostUniq.length = htons(sizeof(pid)); - memcpy(hostUniq.payload, &pid, sizeof(pid)); - memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE); - cursor += sizeof(pid) + TAG_HDR_SIZE; - plen += sizeof(pid) + TAG_HDR_SIZE; + if (conn->hostUniq.length) { + int len = ntohs(conn->hostUniq.length); + memcpy(cursor, &conn->hostUniq, len + TAG_HDR_SIZE); + cursor += len + TAG_HDR_SIZE; + plen += len + TAG_HDR_SIZE; } /* Copy error message */ @@ -209,8 +205,8 @@ void pppoe_printpkt(PPPoEPacket *packet, ntohs(packet->ethHdr.h_proto)); } - printer(arg, " dst %x:%x:%x:%x:%x:%x ", EH(packet->ethHdr.h_dest)); - printer(arg, " src %x:%x:%x:%x:%x:%x\n", EH(packet->ethHdr.h_source)); + printer(arg, " dst %02x:%02x:%02x:%02x:%02x:%02x ", EH(packet->ethHdr.h_dest)); + printer(arg, " src %02x:%02x:%02x:%02x:%02x:%02x\n", EH(packet->ethHdr.h_source)); if (ntohs(packet->ethHdr.h_proto) != ETH_PPPOE_DISCOVERY) return; @@ -246,6 +242,9 @@ void pppoe_printpkt(PPPoEPacket *packet, case TAG_RELAY_SESSION_ID: printer(arg, "relay-session-id"); break; + case TAG_PPP_MAX_PAYLOAD: + printer(arg, "PPP-max-payload"); + break; case TAG_SERVICE_NAME_ERROR: printer(arg, "service-name-error"); text = 1;