--- a/interfaces/opensync.ovsschema +++ b/interfaces/opensync.ovsschema @@ -2657,6 +2657,69 @@ "type": "integer" } } + }, + "subnet_mask": { + "type": { + "key": { + "type": "string" + } + } + }, + "gateway": { + "type": { + "key": { + "type": "string" + } + } + }, + "dhcp_server": { + "type": { + "key": { + "type": "string" + } + } + }, + "primary_dns": { + "type": { + "key": { + "type": "string" + } + } + }, + "secondary_dns": { + "type": { + "key": { + "type": "string" + } + } + }, + "db_status": { + "type": { + "key": { + "type": "integer" + } + } + }, + "device_name": { + "type": { + "key": { + "type": "string" + } + } + }, + "device_type": { + "type": { + "key": { + "type": "integer" + } + } + }, + "manuf_id": { + "type": { + "key": { + "type": "integer" + } + } } }, "isRoot": true --- a/src/lib/inet/src/linux/inet_dhsnif_pcap.c +++ b/src/lib/inet/src/linux/inet_dhsnif_pcap.c @@ -814,6 +814,40 @@ void __inet_dhsnif_process_dhcp( lease->le_info.dl_vendorclass[optlen] = '\0'; break; + case DHCP_OPTION_DNS_SERVERS: + if (optlen == 0) + break; + + for (int i =0; i < optlen; i+=4) + { + if (i == 0) + { + lease->le_info.dl_primarydns = OSN_IP_ADDR_INIT; + lease->le_info.dl_primarydns.ia_addr = *(struct in_addr *)popt; + } + else if (i == 4) + { + lease->le_info.dl_secondarydns = OSN_IP_ADDR_INIT; + lease->le_info.dl_secondarydns.ia_addr = *((struct in_addr *)(popt + 4)); + } + } + break; + + case DHCP_OPTION_SUBNET_MASK: + if (optlen == 0) + break; + lease->le_info.dl_subnetmask = OSN_IP_ADDR_INIT; + lease->le_info.dl_subnetmask.ia_addr = *(struct in_addr *)popt; + break; + + case DHCP_OPTION_ROUTER: + if (optlen == 0) + break; + lease->le_info.dl_gateway = OSN_IP_ADDR_INIT; + lease->le_info.dl_gateway.ia_addr = *(struct in_addr *)popt; + LOG(INFO, "inet_dhsnif: GATEWAY"); + break; + default: #if 0 LOG(DEBUG, "inet_dhsnif: %s: "PRI(inet_macaddr_t)": Received DHCP Option: %d(%d)\n", @@ -882,9 +916,12 @@ void __inet_dhsnif_process_dhcp( break; case DHCP_MSG_ACK: - /* Update the IP address */ + /* Update the client IP address */ lease->le_info.dl_ipaddr = OSN_IP_ADDR_INIT; lease->le_info.dl_ipaddr.ia_addr = dhcp->dhcp_yiaddr; + /* DHCP Server address */ + lease->le_info.dl_dhcpserver = OSN_IP_ADDR_INIT; + lease->le_info.dl_dhcpserver.ia_addr = dhcp->dhcp_siaddr; LOG(NOTICE, "inet_dhsnif: ACK IP:"PRI_osn_ip_addr" MAC:"PRI_osn_mac_addr" Hostname:%s", FMT_osn_ip_addr(lease->le_info.dl_ipaddr), --- a/src/lib/osn/inc/osn_dhcp.h +++ b/src/lib/osn/inc/osn_dhcp.h @@ -240,6 +240,11 @@ struct osn_dhcp_server_lease { osn_mac_addr_t dl_hwaddr; /**< Client hardware address */ osn_ip_addr_t dl_ipaddr; /**< Client IPv4 address */ + osn_ip_addr_t dl_subnetmask; /**< Client Subnet Mask */ + osn_ip_addr_t dl_primarydns; /**< Primary DNS Server */ + osn_ip_addr_t dl_secondarydns; /**< Secondary DNS Server */ + osn_ip_addr_t dl_gateway; /**< Gateway */ + osn_ip_addr_t dl_dhcpserver; /**< DHCP Server */ char dl_hostname[C_HOSTNAME_LEN]; /**< Client hostname */ char dl_fingerprint[OSN_DHCP_FINGERPRINT_MAX]; /**< DHCP fingerprint information */ char dl_vendorclass[OSN_DHCP_VENDORCLASS_MAX]; /**< Vendor class information */