Implemented DHCP field 55 decode
This commit is contained in:
@@ -908,6 +908,8 @@ struct ndpi_detection_module_struct {
|
|||||||
direction_detect_disable:1; /* disable internal detection of packet direction */
|
direction_detect_disable:1; /* disable internal detection of packet direction */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define dhcp_fingerprint host_server_name
|
||||||
|
|
||||||
struct ndpi_flow_struct {
|
struct ndpi_flow_struct {
|
||||||
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_SIZE];
|
u_int16_t detected_protocol_stack[NDPI_PROTOCOL_SIZE];
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@@ -946,7 +948,7 @@ struct ndpi_flow_struct {
|
|||||||
*/
|
*/
|
||||||
struct ndpi_id_struct *server_id;
|
struct ndpi_id_struct *server_id;
|
||||||
/* HTTP host or DNS query */
|
/* HTTP host or DNS query */
|
||||||
u_char host_server_name[256];
|
u_char host_server_name[256]; /* Shared with dhcp_fingerprint */
|
||||||
/* Via HTTP User-Agent */
|
/* Via HTTP User-Agent */
|
||||||
u_char detected_os[32];
|
u_char detected_os[32];
|
||||||
/* Via HTTP X-Forwarded-For */
|
/* Via HTTP X-Forwarded-For */
|
||||||
|
|||||||
@@ -78,24 +78,36 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
|
|||||||
|
|
||||||
while(i < DHCP_VEND_LEN) {
|
while(i < DHCP_VEND_LEN) {
|
||||||
u_int8_t id = dhcp->options[i];
|
u_int8_t id = dhcp->options[i];
|
||||||
if(id == 0xFF) break;
|
|
||||||
|
if(id == 0xFF)
|
||||||
|
break;
|
||||||
else {
|
else {
|
||||||
u_int8_t len = dhcp->options[i+1];
|
u_int8_t len = dhcp->options[i+1];
|
||||||
|
|
||||||
if(len == 0) break;
|
if(len == 0) break;
|
||||||
|
|
||||||
#ifdef DHCP_DEBUG
|
#ifdef DHCP_DEBUG
|
||||||
printf("[DHCP] Id=%d [len=%d]\n", id, len);
|
printf("[DHCP] Id=%d [len=%d]\n", id, len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(id == 53 /* DHCP Message Type */) {
|
if(id == 53 /* DHCP Message Type */) {
|
||||||
u_int8_t msg_type = dhcp->options[i+2];
|
u_int8_t msg_type = dhcp->options[i+2];
|
||||||
|
|
||||||
if(msg_type <= 8) foundValidMsgType = 1;
|
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 */) {
|
} else if(id == 12 /* Host Name */) {
|
||||||
char *name = (char*)&dhcp->options[i+2];
|
char *name = (char*)&dhcp->options[i+2];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
#ifdef DHCP_DEBUG
|
#ifdef DHCP_DEBUG
|
||||||
printf("[DHCP] ");
|
printf("[DHCP] ");
|
||||||
while(j < len) { printf("%c", name[j]); j++; }
|
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);
|
strncpy((char*)flow->host_server_name, name, j);
|
||||||
flow->host_server_name[j] = '\0';
|
flow->host_server_name[j] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
i += len + 2;
|
i += len + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user