mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-01 19:07:47 +00:00
opensync: Additional client DHCP attributes in ovsdb
- Added support to report client DHCP attributes such as subnetmask, gateway, dhcp server, primary and secondary dns Fixes: WIFI-432 Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
This commit is contained in:
committed by
John Crispin
parent
4596dd23d2
commit
9934f93701
115
feeds/wlan-ap/opensync/patches/18-client-dhcp-attributes.patch
Normal file
115
feeds/wlan-ap/opensync/patches/18-client-dhcp-attributes.patch
Normal file
@@ -0,0 +1,115 @@
|
||||
--- a/interfaces/opensync.ovsschema
|
||||
+++ b/interfaces/opensync.ovsschema
|
||||
@@ -2657,6 +2657,41 @@
|
||||
"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"
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
},
|
||||
"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 */
|
||||
@@ -227,6 +227,21 @@ bool netifd_dhcp_lease_notify(
|
||||
sdl.vendor_class_exists = true;
|
||||
strscpy(sdl.vendor_class, dl->dl_vendorclass, sizeof(sdl.vendor_class));
|
||||
|
||||
sdl.subnet_mask_exists = true;
|
||||
snprintf(sdl.subnet_mask, sizeof(sdl.subnet_mask), PRI_osn_ip_addr, FMT_osn_ip_addr(dl->dl_subnetmask));
|
||||
|
||||
sdl.gateway_exists = true;
|
||||
snprintf(sdl.gateway, sizeof(sdl.gateway), PRI_osn_ip_addr, FMT_osn_ip_addr(dl->dl_gateway));
|
||||
|
||||
sdl.dhcp_server_exists = true;
|
||||
snprintf(sdl.dhcp_server, sizeof(sdl.dhcp_server), PRI_osn_ip_addr, FMT_osn_ip_addr(dl->dl_dhcpserver));
|
||||
|
||||
sdl.primary_dns_exists = true;
|
||||
snprintf(sdl.primary_dns, sizeof(sdl.primary_dns), PRI_osn_ip_addr, FMT_osn_ip_addr(dl->dl_primarydns));
|
||||
|
||||
sdl.secondary_dns_exists = true;
|
||||
snprintf(sdl.secondary_dns, sizeof(sdl.secondary_dns), PRI_osn_ip_addr, FMT_osn_ip_addr(dl->dl_secondarydns));
|
||||
|
||||
/* A lease time of 0 indicates that this entry should be deleted */
|
||||
sdl.lease_time_exists = true;
|
||||
if (released) {
|
||||
|
||||
Reference in New Issue
Block a user