[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Ovirt-devel] [PATCH] The node sends the ip address, netmask and interface name during identification.



Darryl L. Pierce wrote:
This patch requires the associated patch for the server which includes the netmask and broadcast columns.

See comments on the other patch in this series.

Perry

Signed-off-by: Darryl L. Pierce <dpierce redhat com>
---
 ovirt-identify-node/gather.c              |   37 ++++++++++++++++++++++++++--
 ovirt-identify-node/ovirt-identify-node.h |    3 ++
 ovirt-identify-node/protocol.c            |    6 ++++-
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/ovirt-identify-node/gather.c b/ovirt-identify-node/gather.c
index 4a664f7..7c6fa55 100644
--- a/ovirt-identify-node/gather.c
+++ b/ovirt-identify-node/gather.c
@@ -22,6 +22,10 @@
#include "ovirt-identify-node.h" +struct sockaddr_in sa;
+
+#define inaddrr(x) (*(struct in_addr *) &ifr.x[sizeof sa.sin_port])
+
 int
 init_gather(void)
 {
@@ -205,6 +209,7 @@ get_nic_data(char *nic, nic_info_ptr nic_info_p)
     interface =
         libhal_device_get_property_string(hal_ctx, nic, "net.interface",
                                           &dbus_error);
+    snprintf(nic_info_p->iface_name, BUFFER_LENGTH, "%s", interface);
     bzero(&ifr, sizeof(struct ifreq));
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
@@ -212,12 +217,36 @@ get_nic_data(char *nic, nic_info_ptr nic_info_p)
         int bandwidth;
ifr.ifr_addr.sa_family = AF_INET;
-        strncpy(ifr.ifr_name, interface, IFNAMSIZ - 1);
+ strncpy(ifr.ifr_name, interface, IFNAMSIZ - 1); + + if(!ioctl(sockfd,SIOCGIFADDR,&ifr)) { + + DEBUG("ip_address=%s\n",inet_ntoa(inaddrr(ifr_addr.sa_data))); + + snprintf(nic_info_p->ip_address, BUFFER_LENGTH, "%s", + inet_ntoa(inaddrr(ifr_addr.sa_data))); + } + + if(!ioctl(sockfd,SIOCGIFNETMASK,&ifr) &&
+                strcmp("255.255.255.255", inet_ntoa(inaddrr(ifr_addr.sa_data)))) {
+ + DEBUG("netmask=%s",inet_ntoa(inaddrr(ifr_addr.sa_data))); + + snprintf(nic_info_p->netmask, BUFFER_LENGTH, "%s",
+                    inet_ntoa(inaddrr(ifr_addr.sa_data)));
+        }
+
+        if(!ioctl(sockfd,SIOCGIFBRDADDR,&ifr)) {
+ + DEBUG("broadcast=%s",inet_ntoa(inaddrr(ifr_addr.sa_data))); + + snprintf(nic_info_p->broadcast, BUFFER_LENGTH, "%s",
+                    inet_ntoa(inaddrr(ifr_addr.sa_data)));
+        }
ifr.ifr_data = (caddr_t)&ecmd;
         ioctl(sockfd, SIOCETHTOOL, &ifr);
-        close(sockfd);
-
+ bandwidth = 10;
         if (ecmd.supported & SUPPORTED_10000baseT_Full)
             bandwidth = 10000;
@@ -234,6 +263,8 @@ get_nic_data(char *nic, nic_info_ptr nic_info_p)
             bandwidth = 10;
snprintf(nic_info_p->bandwidth, BUFFER_LENGTH, "%d", bandwidth); + + close(sockfd);
     }
 }
diff --git a/ovirt-identify-node/ovirt-identify-node.h b/ovirt-identify-node/ovirt-identify-node.h
index c595891..b8485fc 100644
--- a/ovirt-identify-node/ovirt-identify-node.h
+++ b/ovirt-identify-node/ovirt-identify-node.h
@@ -67,6 +67,9 @@ typedef struct _nic_info {
     char mac_address[BUFFER_LENGTH];
     char bandwidth[BUFFER_LENGTH];
     char ip_address[BUFFER_LENGTH];
+    char netmask[BUFFER_LENGTH];
+    char iface_name[BUFFER_LENGTH];
+    char broadcast[BUFFER_LENGTH];
     struct _nic_info* next;
 } t_nic_info;
diff --git a/ovirt-identify-node/protocol.c b/ovirt-identify-node/protocol.c
index 2a92edb..35bf651 100644
--- a/ovirt-identify-node/protocol.c
+++ b/ovirt-identify-node/protocol.c
@@ -181,7 +181,11 @@ send_nic_details(void)
if (!(get_text("NICINFO?")) &&
             (!send_value("MAC", current->mac_address)) &&
-            (!send_value("BANDWIDTH", current->bandwidth))) {
+            (!send_value("BANDWIDTH", current->bandwidth)) &&
+            (!send_value("IFACE_NAME", current->iface_name)) &&
+            (!send_value("IP_ADDRESS", current->ip_address)) &&
+            (!send_value("NETMASK", current->netmask)) &&
+            (!send_value("BROADCAST", current->broadcast))) {
             send_text("ENDNIC");
             result = get_text("ACK NIC");
         }

--
|=-        Red Hat, Engineering, Emerging Technologies, Boston        -=|
|=-                     Email: pmyers redhat com                      -=|
|=-         Office: +1 412 474 3552   Mobile: +1 703 362 9622         -=|
|=- GnuPG: E65E4F3D 88F9 F1C9 C2F3 1303 01FE 817C C5D2 8B91 E65E 4F3D -=|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]