From 56f2d06c6496e49d7e752d1ee5ac5ea420b4ed11 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 16 Jun 2009 10:25:35 +0200 Subject: udhcp: rename sprintip to sprint_nip, siaddr to siaddr_nip Signed-off-by: Denys Vlasenko --- networking/udhcp/script.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'networking/udhcp/script.c') diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c index 3029b1367..97c1d30c3 100644 --- a/networking/udhcp/script.c +++ b/networking/udhcp/script.c @@ -37,7 +37,8 @@ static inline int upper_length(int length, int opt_index) } -static int sprintip(char *dest, const char *pre, const uint8_t *ip) +/* note: ip is a pointer to an IP in network order, possibly misaliged */ +static int sprint_nip(char *dest, const char *pre, const uint8_t *ip) { return sprintf(dest, "%s%d.%d.%d.%d", pre, ip[0], ip[1], ip[2], ip[3]); } @@ -76,12 +77,12 @@ static char *alloc_fill_opts(uint8_t *option, const struct dhcp_option *type_p, for (;;) { switch (type) { case OPTION_IP_PAIR: - dest += sprintip(dest, "", option); + dest += sprint_nip(dest, "", option); *dest++ = '/'; option += 4; optlen = 4; case OPTION_IP: /* Works regardless of host byte order. */ - dest += sprintip(dest, "", option); + dest += sprint_nip(dest, "", option); break; case OPTION_BOOLEAN: dest += sprintf(dest, *option ? "yes" : "no"); @@ -145,7 +146,7 @@ static char **fill_envp(struct dhcpMessage *packet) num_options++; /* for mton */ } } - if (packet->siaddr) + if (packet->siaddr_nip) num_options++; temp = get_option(packet, DHCP_OPTION_OVERLOAD); if (temp) @@ -164,7 +165,7 @@ static char **fill_envp(struct dhcpMessage *packet) return envp; *curr = xmalloc(sizeof("ip=255.255.255.255")); - sprintip(*curr, "ip=", (uint8_t *) &packet->yiaddr); + sprint_nip(*curr, "ip=", (uint8_t *) &packet->yiaddr); putenv(*curr++); opt_name = dhcp_option_strings; @@ -187,9 +188,9 @@ static char **fill_envp(struct dhcpMessage *packet) opt_name += strlen(opt_name) + 1; i++; } - if (packet->siaddr) { + if (packet->siaddr_nip) { *curr = xmalloc(sizeof("siaddr=255.255.255.255")); - sprintip(*curr, "siaddr=", (uint8_t *) &packet->siaddr); + sprint_nip(*curr, "siaddr=", (uint8_t *) &packet->siaddr_nip); putenv(*curr++); } if (!(over & FILE_FIELD) && packet->file[0]) { -- cgit v1.2.3