Home | History | Annotate | Download | only in rp-pppoe

Lines Matching refs:packet

36 * packet -- the PPPoE discovery packet to parse
37 * func -- function called for each tag in the packet
42 * Parses a PPPoE discovery packet, calling "func" for each tag in the packet.
46 parsePacket(PPPoEPacket *packet, ParseFunc *func, void *extra)
48 UINT16_t len = ntohs(packet->length);
52 if (packet->ver != 1) {
53 syslog(LOG_ERR, "Invalid PPPoE version (%d)", (int) packet->ver);
56 if (packet->type != 1) {
57 syslog(LOG_ERR, "Invalid PPPoE type (%d)", (int) packet->type);
61 /* Do some sanity checks on packet */
63 syslog(LOG_ERR, "Invalid PPPoE packet length (%u)", len);
68 curTag = packet->payload;
69 while(curTag - packet->payload < len) {
78 if ((curTag - packet->payload) + tagLen + TAG_HDR_SIZE > len) {
91 * packet -- the PPPoE discovery packet to parse
101 findTag(PPPoEPacket *packet, UINT16_t type, PPPoETag *tag)
103 UINT16_t len = ntohs(packet->length);
107 if (packet->ver != 1) {
108 syslog(LOG_ERR, "Invalid PPPoE version (%d)", (int) packet->ver);
111 if (packet->type != 1) {
112 syslog(LOG_ERR, "Invalid PPPoE type (%d)", (int) packet->type);
116 /* Do some sanity checks on packet */
118 syslog(LOG_ERR, "Invalid PPPoE packet length (%u)", len);
123 curTag = packet->payload;
124 while(curTag - packet->payload < len) {
133 if ((curTag - packet->payload) + tagLen + TAG_HDR_SIZE > len) {
234 * packet -- PPPoE session packet
243 clampMSS(PPPoEPacket *packet, char const *dir, int clampMss)
255 if (packet->payload[0] & 0x01) {
259 if (packet->payload[0] != 0x21) {
264 ipHdr = packet->payload + 1;
270 if (packet->payload[0] != 0x00 ||
271 packet->payload[1] != 0x21) {
276 ipHdr = packet->payload + 2;
281 len = (int) ntohs(packet->length);
292 /* Is it a fragment that's not at the beginning of the packet? */
310 /* Compute and verify TCP checksum -- do not touch a packet with a bad
389 * msg -- if non-NULL, extra error message to include in PADT packet.
393 * Sends a PADT packet
398 PPPoEPacket packet;
399 unsigned char *cursor = packet.payload;
409 memcpy(packet.ethHdr.h_dest, conn->peerEth, ETH_ALEN);
410 memcpy(packet.ethHdr.h_source, conn->myEth, ETH_ALEN);
412 packet.ethHdr.h_proto = htons(Eth_PPPOE_Discovery);
413 packet.ver = 1;
414 packet.type = 1;
415 packet.code = CODE_PADT;
416 packet.session = conn->session;
448 CHECK_ROOM(cursor, packet.payload,
456 CHECK_ROOM(cursor, packet.payload,
463 packet.length = htons(plen);
464 sendPacket(conn, conn->discoverySocket, &packet, (int) (plen + HDR_SIZE));
466 dumpPacket(conn->debugFile, &packet, "SENT");
483 * Picks error tags out of a packet and logs them.