summaryrefslogtreecommitdiff
path: root/networking/udhcp
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp')
-rw-r--r--networking/udhcp/arpping.c7
-rw-r--r--networking/udhcp/packet.c3
-rw-r--r--networking/udhcp/socket.c7
3 files changed, 7 insertions, 10 deletions
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index 471e36d..9c8b9c5 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -44,9 +44,7 @@ struct arpMsg {
/* FIXME: match response against chaddr */
int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
{
-
int timeout = 2;
- int optval = 1;
int s; /* socket */
int rv = 1; /* return value */
struct sockaddr addr; /* for interface name */
@@ -56,12 +54,13 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
time_t prevTime;
- if ((s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP))) == -1) {
+ s = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP));
+ if (s == -1) {
bb_perror_msg(bb_msg_can_not_create_raw_socket);
return -1;
}
- if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) {
+ if (setsockopt_broadcast(s) == -1) {
bb_perror_msg("cannot setsocketopt on raw socket");
close(s);
return -1;
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 8591044..dec9d0a 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -173,7 +173,6 @@ int udhcp_kernel_packet(struct dhcpMessage *payload,
uint32_t source_ip, int source_port,
uint32_t dest_ip, int dest_port)
{
- int n = 1;
int fd, result;
struct sockaddr_in client;
@@ -181,7 +180,7 @@ int udhcp_kernel_packet(struct dhcpMessage *payload,
if (fd < 0)
return -1;
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1) {
+ if (setsockopt_reuseaddr(fd) == -1) {
close(fd);
return -1;
}
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index c19131d..b27dca3 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -93,7 +93,6 @@ int listen_socket(uint32_t ip, int port, char *inf)
struct ifreq interface;
int fd;
struct sockaddr_in addr;
- int n = 1;
DEBUG("Opening listen socket on 0x%08x:%d %s", ip, port, inf);
fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -107,17 +106,17 @@ int listen_socket(uint32_t ip, int port, char *inf)
addr.sin_port = htons(port);
addr.sin_addr.s_addr = ip;
- if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1) {
+ if (setsockopt_reuseaddr(fd) == -1) {
close(fd);
return -1;
}
- if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char *) &n, sizeof(n)) == -1) {
+ if (setsockopt_broadcast(fd) == -1) {
close(fd);
return -1;
}
strncpy(interface.ifr_name, inf, IFNAMSIZ);
- if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,(char *)&interface, sizeof(interface)) < 0) {
+ if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, (char *)&interface, sizeof(interface)) < 0) {
close(fd);
return -1;
}