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) */
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 */
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;
}
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
) {
};
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
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);
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 */
/* 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);
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;
#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);
}
}
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);
}
/* 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);
}
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);
}
#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;
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)
) {
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));
}