/********************************************************************** *%FUNCTION: parsePADSTags *%ARGUMENTS: * type -- tag type * len -- tag length * data -- tag data * extra -- extra user data (pointer to PPPoEConnection structure) *%RETURNS: * Nothing *%DESCRIPTION: * Picks interesting tags out of a PADS packet ***********************************************************************/ static void parsePADSTags(UINT16_t type, UINT16_t len, unsigned char *data, void *extra) { PPPoEConnection *conn = (PPPoEConnection *) extra; switch(type) { case TAG_SERVICE_NAME: syslog(LOG_DEBUG, "PADS: Service-Name: '%.*s'", (int) len, data); break; case TAG_GENERIC_ERROR: case TAG_AC_SYSTEM_ERROR: case TAG_SERVICE_NAME_ERROR: pktLogErrs("PADS", type, len, data, extra); conn->PADSHadError = 1; break; case TAG_RELAY_SESSION_ID: conn->relayId.type = htons(type); conn->relayId.length = htons(len); memcpy(conn->relayId.payload, data, len); break; } }
/********************************************************************** *%FUNCTION: parsePADSTags *%ARGUMENTS: * type -- tag type * len -- tag length * data -- tag data * extra -- extra user data (pointer to PPPoEConnection structure) *%RETURNS: * Nothing *%DESCRIPTION: * Picks interesting tags out of a PADS packet ***********************************************************************/ static void parsePADSTags(UINT16_t type, UINT16_t len, unsigned char *data, void *extra) { #ifdef PLUGIN UINT16_t mru; #endif PPPoEConnection *conn = (PPPoEConnection *) extra; switch(type) { case TAG_SERVICE_NAME: syslog(LOG_DEBUG, "PADS: Service-Name: '%.*s'", (int) len, data); break; case TAG_GENERIC_ERROR: case TAG_AC_SYSTEM_ERROR: case TAG_SERVICE_NAME_ERROR: pktLogErrs("PADS", type, len, data, extra); conn->PADSHadError = 1; break; case TAG_RELAY_SESSION_ID: conn->relayId.type = htons(type); conn->relayId.length = htons(len); memcpy(conn->relayId.payload, data, len); break; #ifdef PLUGIN case TAG_PPP_MAX_PAYLOAD: if (len == sizeof(mru)) { memcpy(&mru, data, sizeof(mru)); mru = ntohs(mru); if (mru >= ETH_PPPOE_MTU) { if (lcp_allowoptions[0].mru > mru) lcp_allowoptions[0].mru = mru; if (lcp_wantoptions[0].mru > mru) lcp_wantoptions[0].mru = mru; conn->seenMaxPayload = 1; } } break; #endif } }
/********************************************************************** *%FUNCTION: parsePADOTags *%ARGUMENTS: * type -- tag type * len -- tag length * data -- tag data * extra -- extra user data. Should point to a PacketCriteria structure * which gets filled in according to selected AC name and service * name. *%RETURNS: * Nothing *%DESCRIPTION: * Picks interesting tags out of a PADO packet ***********************************************************************/ static void parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data, void *extra) { struct PacketCriteria *pc = (struct PacketCriteria *) extra; PPPoEConnection *conn = pc->conn; int i; switch(type) { case TAG_AC_NAME: pc->seenACName = 1; if (conn->printACNames) { printf("Access-Concentrator: %.*s\n", (int) len, data); } if (conn->acName && len == strlen(conn->acName) && !strncmp((char *) data, conn->acName, len)) { pc->acNameOK = 1; } break; case TAG_SERVICE_NAME: pc->seenServiceName = 1; if (conn->printACNames && len > 0) { printf(" Service-Name: %.*s\n", (int) len, data); } if (conn->serviceName && len == strlen(conn->serviceName) && !strncmp((char *) data, conn->serviceName, len)) { pc->serviceNameOK = 1; } break; case TAG_AC_COOKIE: if (conn->printACNames) { printf("Got a cookie:"); /* Print first 20 bytes of cookie */ for (i=0; i<len && i < 20; i++) { printf(" %02x", (unsigned) data[i]); } if (i < len) printf("..."); printf("\n"); } conn->cookie.type = htons(type); conn->cookie.length = htons(len); memcpy(conn->cookie.payload, data, len); break; case TAG_RELAY_SESSION_ID: if (conn->printACNames) { printf("Got a Relay-ID:"); /* Print first 20 bytes of relay ID */ for (i=0; i<len && i < 20; i++) { printf(" %02x", (unsigned) data[i]); } if (i < len) printf("..."); printf("\n"); } conn->relayId.type = htons(type); conn->relayId.length = htons(len); memcpy(conn->relayId.payload, data, len); break; case TAG_SERVICE_NAME_ERROR: if (conn->printACNames) { printf("Got a Service-Name-Error tag: %.*s\n", (int) len, data); } else { pktLogErrs("PADO", type, len, data, extra); exit(1); } break; case TAG_AC_SYSTEM_ERROR: if (conn->printACNames) { printf("Got a System-Error tag: %.*s\n", (int) len, data); } else { pktLogErrs("PADO", type, len, data, extra); exit(1); } break; case TAG_GENERIC_ERROR: if (conn->printACNames) { printf("Got a Generic-Error tag: %.*s\n", (int) len, data); } else { pktLogErrs("PADO", type, len, data, extra); exit(1); } break; } }
/********************************************************************** *%FUNCTION: parsePADOTags *%ARGUMENTS: * type -- tag type * len -- tag length * data -- tag data * extra -- extra user data. Should point to a PacketCriteria structure * which gets filled in according to selected AC name and service * name. *%RETURNS: * Nothing *%DESCRIPTION: * Picks interesting tags out of a PADO packet ***********************************************************************/ static void parsePADOTags(UINT16_t type, UINT16_t len, unsigned char *data, void *extra) { struct PacketCriteria *pc = (struct PacketCriteria *) extra; PPPoEConnection *conn = pc->conn; int i; #ifdef PLUGIN UINT16_t mru; #endif switch(type) { case TAG_AC_NAME: pc->seenACName = 1; if (conn->printACNames) { printf("Access-Concentrator: %.*s\n", (int) len, data); } if (conn->acName && len == strlen(conn->acName) && !strncmp((char *) data, conn->acName, len)) { pc->acNameOK = 1; } break; case TAG_SERVICE_NAME: pc->seenServiceName = 1; if (conn->printACNames && len > 0) { printf(" Service-Name: %.*s\n", (int) len, data); } if (conn->serviceName && len == strlen(conn->serviceName) && !strncmp((char *) data, conn->serviceName, len)) { pc->serviceNameOK = 1; } break; case TAG_AC_COOKIE: if (conn->printACNames) { printf("Got a cookie:"); /* Print first 20 bytes of cookie */ for (i=0; i<len && i < 20; i++) { printf(" %02x", (unsigned) data[i]); } if (i < len) printf("..."); printf("\n"); } conn->cookie.type = htons(type); conn->cookie.length = htons(len); memcpy(conn->cookie.payload, data, len); break; case TAG_RELAY_SESSION_ID: if (conn->printACNames) { printf("Got a Relay-ID:"); /* Print first 20 bytes of relay ID */ for (i=0; i<len && i < 20; i++) { printf(" %02x", (unsigned) data[i]); } if (i < len) printf("..."); printf("\n"); } conn->relayId.type = htons(type); conn->relayId.length = htons(len); memcpy(conn->relayId.payload, data, len); break; case TAG_SERVICE_NAME_ERROR: if (conn->printACNames) { printf("Got a Service-Name-Error tag: %.*s\n", (int) len, data); } else { pktLogErrs("PADO", type, len, data, extra); pc->gotError = 1; if (!persist) { exit(1); } } break; case TAG_AC_SYSTEM_ERROR: if (conn->printACNames) { printf("Got a System-Error tag: %.*s\n", (int) len, data); } else { pktLogErrs("PADO", type, len, data, extra); pc->gotError = 1; if (!persist) { exit(1); } } break; case TAG_GENERIC_ERROR: if (conn->printACNames) { printf("Got a Generic-Error tag: %.*s\n", (int) len, data); } else { pktLogErrs("PADO", type, len, data, extra); pc->gotError = 1; if (!persist) { exit(1); } } break; #ifdef PLUGIN case TAG_PPP_MAX_PAYLOAD: if (len == sizeof(mru)) { memcpy(&mru, data, sizeof(mru)); mru = ntohs(mru); if (mru >= ETH_PPPOE_MTU) { if (lcp_allowoptions[0].mru > mru) lcp_allowoptions[0].mru = mru; if (lcp_wantoptions[0].mru > mru) lcp_wantoptions[0].mru = mru; conn->seenMaxPayload = 1; } } break; #endif } }