1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
From e21d256cded13a625bc28d3fe812141a202be696 Mon Sep 17 00:00:00 2001
From: Mike Gilbert <floppym@gentoo.org>
Date: Thu, 13 Apr 2023 14:59:35 -0400
Subject: [PATCH 1/3] Convert sys_errlist to strerror
---
dhcpc.c | 8 ++++----
packet.c | 6 +++---
socket.c | 14 +++++++-------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/dhcpc.c b/dhcpc.c
index fcff8b9..ff83b53 100644
--- a/dhcpc.c
+++ b/dhcpc.c
@@ -144,7 +144,7 @@ void change_mode(int new_mode)
fd = raw_socket(client_config.ifindex);
if (listen_mode != LISTEN_NONE && fd < 0) {
- fatal("DHCPC: couldn't listen on socket, %s", sys_errlist[errno]);
+ fatal("DHCPC: couldn't listen on socket, %s", strerror(errno));
}
}
@@ -208,7 +208,7 @@ void dhcp_rx(void *dummy) {
len = get_packet(&packet, fd);
if (len == -1 && errno != EINTR) {
- dbglog("DHCPC: error on read, %s, reopening socket", sys_errlist[errno]);
+ dbglog("DHCPC: error on read, %s, reopening socket", strerror(errno));
change_mode(LISTEN_KERNEL);
}
if (len < 0) continue;
@@ -380,7 +380,7 @@ void dhcp_request_new() {
else len = get_raw_packet(&packet, fd);
if (len == -1 && errno != EINTR) {
- dbglog("DHCPC: error on read, %s, reopening socket", sys_errlist[errno]);
+ dbglog("DHCPC: error on read, %s, reopening socket", strerror(errno));
change_mode(listen_mode); /* just close and reopen */
}
if (len < 0) continue;
@@ -445,7 +445,7 @@ void dhcp_request_new() {
} else {
/* An error occured */
- dbglog("DHCPC: error on select, %s, reopening socket", sys_errlist[errno]);
+ dbglog("DHCPC: error on select, %s, reopening socket", strerror(errno));
change_mode(listen_mode); /* just close and reopen */
}
diff --git a/packet.c b/packet.c
index 00b5202..07a1aac 100644
--- a/packet.c
+++ b/packet.c
@@ -125,7 +125,7 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
return kernel_packet(payload,payload->giaddr,CLIENT_PORT,dest_ip,dest_port);
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
- DEBUG(LOG_ERR, "socket call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "socket call failed: %s", strerror(errno));
return -1;
}
@@ -138,7 +138,7 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
dest.sll_halen = 6;
memcpy(dest.sll_addr, dest_arp, 6);
if (bind(fd, (struct sockaddr *)&dest, sizeof(struct sockaddr_ll)) < 0) {
- DEBUG(LOG_ERR, "bind call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "bind call failed: %s", strerror(errno));
close(fd);
return -1;
}
@@ -161,7 +161,7 @@ int raw_packet(struct dhcpMessage *payload, u_int32_t source_ip, int source_port
result = sendto(fd, &packet, sizeof(struct udp_dhcp_packet), 0, (struct sockaddr *) &dest, sizeof(dest));
if (result <= 0) {
- DEBUG(LOG_ERR, "write on socket failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "write on socket failed: %s", strerror(errno));
}
close(fd);
return result;
diff --git a/socket.c b/socket.c
index 0234350..a6799d5 100644
--- a/socket.c
+++ b/socket.c
@@ -60,7 +60,7 @@ int read_interface(char *interface, int *ifindex, u_int32_t *addr, unsigned char
*addr = sin->sin_addr.s_addr;
DEBUG(LOG_INFO, "%s (our ip) = %s", ifr.ifr_name, inet_ntoa(sin->sin_addr));
} else {
- LOG(LOG_ERR, "SIOCGIFADDR failed!: %s", sys_errlist[errno]);
+ LOG(LOG_ERR, "SIOCGIFADDR failed!: %s", strerror(errno));
return -1;
}
}
@@ -69,7 +69,7 @@ int read_interface(char *interface, int *ifindex, u_int32_t *addr, unsigned char
DEBUG(LOG_INFO, "adapter index %d", ifr.ifr_ifindex);
*ifindex = ifr.ifr_ifindex;
} else {
- LOG(LOG_ERR, "SIOCGIFINDEX failed!: %s", sys_errlist[errno]);
+ LOG(LOG_ERR, "SIOCGIFINDEX failed!: %s", strerror(errno));
return -1;
}
if (ioctl(fd, SIOCGIFHWADDR, &ifr) == 0) {
@@ -77,11 +77,11 @@ int read_interface(char *interface, int *ifindex, u_int32_t *addr, unsigned char
DEBUG(LOG_INFO, "adapter hardware address %02x:%02x:%02x:%02x:%02x:%02x",
arp[0], arp[1], arp[2], arp[3], arp[4], arp[5]);
} else {
- LOG(LOG_ERR, "SIOCGIFHWADDR failed!: %s", sys_errlist[errno]);
+ LOG(LOG_ERR, "SIOCGIFHWADDR failed!: %s", strerror(errno));
return -1;
}
} else {
- LOG(LOG_ERR, "socket failed!: %s", sys_errlist[errno]);
+ LOG(LOG_ERR, "socket failed!: %s", strerror(errno));
return -1;
}
close(fd);
@@ -98,7 +98,7 @@ int listen_socket(unsigned int ip, int port, char *inf)
DEBUG(LOG_INFO, "Opening listen socket on 0x%08x:%d %s\n", ip, port, inf ? inf : "*");
if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- DEBUG(LOG_ERR, "socket call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "socket call failed: %s", strerror(errno));
return -1;
}
@@ -144,7 +144,7 @@ int raw_socket(int ifindex)
DEBUG(LOG_INFO, "Opening raw socket on ifindex %d\n", ifindex);
if ((fd = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
- DEBUG(LOG_ERR, "socket call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "socket call failed: %s", strerror(errno));
return -1;
}
@@ -152,7 +152,7 @@ int raw_socket(int ifindex)
sock.sll_protocol = htons(ETH_P_IP);
sock.sll_ifindex = ifindex;
if (bind(fd, (struct sockaddr *) &sock, sizeof(sock)) < 0) {
- DEBUG(LOG_ERR, "bind call failed: %s", sys_errlist[errno]);
+ DEBUG(LOG_ERR, "bind call failed: %s", strerror(errno));
close(fd);
return -1;
}
--
2.40.0
|