diff options
author | Luca Deri <deri@ntop.org> | 2017-09-17 21:25:55 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2017-09-17 21:25:55 +0200 |
commit | d6f7dd9c08b8abcaa964f19c3f34c24ed2c558cd (patch) | |
tree | 16e5d716925ea5ca8a4a3f01d921251a0cd93deb /src/lib | |
parent | 4176fd5068ed84c9f662a4b9ba97aa7794354fa4 (diff) |
Implemented DHCP field 55 decode
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/protocols/dhcp.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/lib/protocols/dhcp.c b/src/lib/protocols/dhcp.c index 38711c911..ee5b12834 100644 --- a/src/lib/protocols/dhcp.c +++ b/src/lib/protocols/dhcp.c @@ -78,24 +78,36 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru while(i < DHCP_VEND_LEN) { u_int8_t id = dhcp->options[i]; - if(id == 0xFF) break; + + if(id == 0xFF) + break; else { u_int8_t len = dhcp->options[i+1]; - + if(len == 0) break; - + #ifdef DHCP_DEBUG printf("[DHCP] Id=%d [len=%d]\n", id, len); #endif - + if(id == 53 /* DHCP Message Type */) { u_int8_t msg_type = dhcp->options[i+2]; - + if(msg_type <= 8) foundValidMsgType = 1; + } else if(id == 55 /* Parameter Request List / Fingerprint */) { + u_int idx, offset = 0, + hex_len = ndpi_min(len * 2, sizeof(flow->dhcp_fingerprint)); + + for(idx=0; idx<len; idx++) { + snprintf((char*)&flow->dhcp_fingerprint[offset], + sizeof(flow->dhcp_fingerprint)-offset-1, + "%02X", dhcp->options[i+2+idx] & 0xFF); + offset += 2; + } } else if(id == 12 /* Host Name */) { char *name = (char*)&dhcp->options[i+2]; int j = 0; - + #ifdef DHCP_DEBUG printf("[DHCP] "); while(j < len) { printf("%c", name[j]); j++; } @@ -105,6 +117,7 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru strncpy((char*)flow->host_server_name, name, j); flow->host_server_name[j] = '\0'; } + i += len + 2; } } |