udhcp: rename giaddr to gateway_nip and server to server_nip
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 16 Jun 2009 08:23:55 +0000 (10:23 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 16 Jun 2009 08:23:55 +0000 (10:23 +0200)
"nip" stands for "IP in network order"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/udhcp/common.h
networking/udhcp/dhcpd.c
networking/udhcp/dhcpd.h
networking/udhcp/dhcprelay.c
networking/udhcp/leases.c
networking/udhcp/serverpacket.c
networking/udhcp/socket.c

index ca96847a7154278439dc65fdb7677cfade3829b6..fef0b66a8670d89a8eb20e0c3a275cffca52a8c7 100644 (file)
@@ -36,7 +36,7 @@ struct dhcpMessage {
        uint32_t yiaddr; /* 'your' (client) IP address */
        uint32_t siaddr; /* IP address of next server to use in bootstrap,
                          * returned in DHCPOFFER, DHCPACK by server */
-       uint32_t giaddr; /* relay agent IP address */
+       uint32_t gateway_nip; /* relay agent IP address */
        uint8_t chaddr[16];/* link-layer client hardware address (MAC) */
        uint8_t sname[64]; /* server host name (ASCIZ) */
        uint8_t file[128]; /* boot file name (ASCIZ) */
@@ -88,7 +88,7 @@ void udhcp_run_script(struct dhcpMessage *packet, const char *name) FAST_FUNC;
 void udhcp_sp_setup(void) FAST_FUNC;
 int udhcp_sp_fd_set(fd_set *rfds, int extra_fd) FAST_FUNC;
 int udhcp_sp_read(const fd_set *rfds) FAST_FUNC;
-int udhcp_read_interface(const char *interface, int *ifindex, uint32_t *addr, uint8_t *arp) FAST_FUNC;
+int udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *arp) FAST_FUNC;
 int udhcp_raw_socket(int ifindex) FAST_FUNC;
 int udhcp_listen_socket(/*uint32_t ip,*/ int port, const char *inf) FAST_FUNC;
 /* Returns 1 if no reply received */
index 61e4a1d95767df838cdca475a528a982cb0b3570..09524e29cdd857f678c81055130d3b75abdc4764 100644 (file)
@@ -94,7 +94,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
        read_leases(server_config.lease_file);
 
        if (udhcp_read_interface(server_config.interface, &server_config.ifindex,
-                          &server_config.server, server_config.arp)) {
+                          &server_config.server_nip, server_config.arp)) {
                retval = 1;
                goto ret;
        }
@@ -202,7 +202,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
                                if (server_id) {
                                        /* SELECTING State */
                                        DEBUG("server_id = %08x", ntohl(server_id_aligned));
-                                       if (server_id_aligned == server_config.server
+                                       if (server_id_aligned == server_config.server_nip
                                         && requested
                                         && requested_aligned == lease->lease_nip
                                        ) {
index a3ace92d4a4b27efd18e03840fbc35f725392755..bb281c51b12826b5d62d57ac510bd24e65345bd5 100644 (file)
@@ -28,7 +28,7 @@ struct static_lease {
 };
 
 struct server_config_t {
-       uint32_t server;                /* Our IP, in network order */
+       uint32_t server_nip;            /* Our IP, in network order */
 #if ENABLE_FEATURE_UDHCP_PORT
        uint16_t port;
 #endif
index 53540d1ab9d8a6472d45e5bfbffb146d258cd7a5..2fee49a419e2c20e8303e197f0ac4e3376e3318c 100644 (file)
@@ -247,7 +247,7 @@ int dhcprelay_main(int argc, char **argv)
        char **client_ifaces;
        int *fds;
        int num_sockets, max_socket;
-       uint32_t our_ip;
+       uint32_t our_nip;
 
        server_addr.sin_family = AF_INET;
        server_addr.sin_port = htons(SERVER_PORT);
@@ -272,7 +272,7 @@ int dhcprelay_main(int argc, char **argv)
        max_socket = init_sockets(client_ifaces, num_sockets, argv[2], fds);
 
        /* Get our IP on server_iface */
-       if (udhcp_read_interface(argv[2], NULL, &our_ip, NULL))
+       if (udhcp_read_interface(argv[2], NULL, &our_nip, NULL))
                return 1;
 
        /* Main loop */
@@ -309,10 +309,10 @@ int dhcprelay_main(int argc, char **argv)
 
                                /* Get our IP on corresponding client_iface */
 //why? what if server can't route such IP?
-                               if (udhcp_read_interface(client_ifaces[i-1], NULL, &dhcp_msg.giaddr, NULL)) {
+                               if (udhcp_read_interface(client_ifaces[i-1], NULL, &dhcp_msg.gateway_nip, NULL)) {
                                        /* Fall back to our server_iface's IP */
 //this makes more sense!
-                                       dhcp_msg.giaddr = our_ip;
+                                       dhcp_msg.gateway_nip = our_nip;
                                }
 //maybe set dhcp_msg.flags |= BROADCAST_FLAG too?
                                pass_to_server(&dhcp_msg, packlen, i, fds, &client_addr, &server_addr);
index 040126fe897d8d8fbedaffaddaa7210455c272cd..403a8bca6665ea01cef1f406ac5e704500851355 100644 (file)
@@ -128,7 +128,7 @@ static int nobody_responds_to_arp(uint32_t addr, const uint8_t *safe_mac)
        int r;
 
        r = arpping(addr, safe_mac,
-                       server_config.server, server_config.arp,
+                       server_config.server_nip, server_config.arp,
                        server_config.interface);
        if (r)
                return r;
index 6aa2d34faee9b19e3f86192c8a7949c247e5217f..55ed4a833cc6ed309e5070a408c68c9d02f11f59 100644 (file)
 #include "options.h"
 
 
-/* send a packet to giaddr using the kernel ip stack */
+/* send a packet to gateway_nip using the kernel ip stack */
 static int send_packet_to_relay(struct dhcpMessage *payload)
 {
        DEBUG("Forwarding packet to relay");
 
        return udhcp_send_kernel_packet(payload,
-                       server_config.server, SERVER_PORT,
-                       payload->giaddr, SERVER_PORT);
+                       server_config.server_nip, SERVER_PORT,
+                       payload->gateway_nip, SERVER_PORT);
 }
 
 
@@ -69,7 +69,7 @@ static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcas
        }
 
        return udhcp_send_raw_packet(payload,
-               /*src*/ server_config.server, SERVER_PORT,
+               /*src*/ server_config.server_nip, SERVER_PORT,
                /*dst*/ ciaddr, CLIENT_PORT, chaddr,
                server_config.ifindex);
 }
@@ -78,7 +78,7 @@ static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcas
 /* send a dhcp packet, if force broadcast is set, the packet will be broadcast to the client */
 static int send_packet(struct dhcpMessage *payload, int force_broadcast)
 {
-       if (payload->giaddr)
+       if (payload->gateway_nip)
                return send_packet_to_relay(payload);
        return send_packet_to_client(payload, force_broadcast);
 }
@@ -90,9 +90,9 @@ static void init_packet(struct dhcpMessage *packet, struct dhcpMessage *oldpacke
        packet->xid = oldpacket->xid;
        memcpy(packet->chaddr, oldpacket->chaddr, 16);
        packet->flags = oldpacket->flags;
-       packet->giaddr = oldpacket->giaddr;
+       packet->gateway_nip = oldpacket->gateway_nip;
        packet->ciaddr = oldpacket->ciaddr;
-       add_simple_option(packet->options, DHCP_SERVER_ID, server_config.server);
+       add_simple_option(packet->options, DHCP_SERVER_ID, server_config.server_nip);
 }
 
 
index edf4355b500644b1eb32e90a3c49cb5b2b9de67d..449fcb7aa589c0eec7089dc7f1d5be832ead0350 100644 (file)
@@ -37,7 +37,7 @@
 #include "common.h"
 
 
-int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *addr, uint8_t *arp)
+int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *arp)
 {
        int fd;
        struct ifreq ifr;
@@ -48,7 +48,7 @@ int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t
 
        ifr.ifr_addr.sa_family = AF_INET;
        strncpy_IFNAMSIZ(ifr.ifr_name, interface);
-       if (addr) {
+       if (nip) {
                if (ioctl_or_perror(fd, SIOCGIFADDR, &ifr,
                        "is interface %s up and configured?", interface)
                ) {
@@ -56,7 +56,7 @@ int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t
                        return -1;
                }
                our_ip = (struct sockaddr_in *) &ifr.ifr_addr;
-               *addr = our_ip->sin_addr.s_addr;
+               *nip = our_ip->sin_addr.s_addr;
                DEBUG("ip of %s = %s", interface, inet_ntoa(our_ip->sin_addr));
        }