| @@ -253,6 +253,8 @@ int dp_dhcp_check(struct nfq_data *nfa, dp_conf *conf) { | |||
| } | |||
| } | |||
| if ( conf->debug ) printf("remoteidlen=%i\n",remoteidlen); | |||
| if ( remoteidlen>0 ) { | |||
| if ( conf->debug ) { | |||
| int i; | |||
| @@ -283,43 +285,45 @@ int dp_dhcp_check(struct nfq_data *nfa, dp_conf *conf) { | |||
| } | |||
| void dp_dhcpv6_check(dp_conf *conf, unsigned char *pkt, int pktlen, int offset, unsigned char **remoteid, int *remoteidlen) { | |||
| uint8_t msgtype = (uint8_t)pkt[offset]; | |||
| while(offset<pktlen) { | |||
| uint8_t msgtype = (uint8_t)pkt[offset]; | |||
| if ( conf->debug ) printf("offset=%i\n",offset); | |||
| switch(msgtype) { | |||
| case 11: // RELAY-FORW | |||
| case 12: // RELAY-REPL | |||
| offset += 2 + 16 + 16; // msg-type, hop-count, link-addr, peer-addr | |||
| break; | |||
| default: // all other msgtypes | |||
| offset += 2; // msg-type, hop-count | |||
| } | |||
| switch(msgtype) { | |||
| case 12: // RELAY-FORW | |||
| case 13: // RELAY-REPL | |||
| offset += 2 + 16 + 16; // msg-type, hop-count, link-addr, peer-addr | |||
| if ( conf->debug ) printf("this is a relay msg\n"); | |||
| break; | |||
| default: // all other msgtypes | |||
| offset += 2; // msg-type, hop-count | |||
| } | |||
| while(offset+4<=pktlen) { | |||
| uint16_t code = ntohs((uint16_t)pkt[offset]); | |||
| uint16_t len = ntohs((uint16_t)pkt[offset+2]); | |||
| if ( conf->debug ) printf("offset=%i\n",offset); | |||
| offset+=4; | |||
| while(offset+4<=pktlen) { | |||
| uint16_t code = ntohs(*(uint16_t*)(pkt+offset)); | |||
| uint16_t len = ntohs(*(uint16_t*)(pkt+offset+2)); | |||
| if ( code == 9 ) { // relay message | |||
| offset += 4; | |||
| continue; | |||
| } | |||
| if ( conf->debug ) printf("code %i len %i\n", code, len); | |||
| if ( code == 1 ) { // Client identifier / DUID | |||
| // make sure there's enough space | |||
| if ( offset + len <= pktlen ) { | |||
| *remoteid = pkt+offset; | |||
| *remoteidlen = len; | |||
| break; | |||
| } | |||
| } | |||
| offset+=len; | |||
| offset+=4; | |||
| if ( code == 9 ) { // relay message | |||
| if ( conf->debug ) printf("option 9, relay msg\n"); | |||
| offset+=4; | |||
| continue; | |||
| } | |||
| if ( *remoteidlen>0 ) | |||
| break; | |||
| if ( code == 1 ) { // Client identifier / DUID | |||
| // make sure there's enough space | |||
| if ( offset + len <= pktlen ) { | |||
| *remoteid = pkt+offset; | |||
| *remoteidlen = len; | |||
| break; | |||
| } | |||
| } | |||
| offset+=len; | |||
| } | |||
| } | |||