diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-21 20:53:50 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-21 20:53:50 +0000 |
commit | f6bad5ef766b0447158e3de2f55c35f1f6cecb58 (patch) | |
tree | f5ec7ac45234c25794c97f87e9a6daa8a551e57c /networking | |
parent | 72394258b6509b40e0fa08594ac86215a558dfd8 (diff) | |
parent | 8d0e0cdadf726beab28ccdc7d69738c1534e1f74 (diff) | |
download | busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.tar.gz busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.tar.bz2 busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.zip |
Merge commit '8d0e0cdadf726beab28ccdc7d69738c1534e1f74' into merge
Conflicts:
include/platform.h
libbb/Kbuild.src
libbb/messages.c
Diffstat (limited to 'networking')
-rw-r--r-- | networking/httpd.c | 1 | ||||
-rw-r--r-- | networking/ifplugd.c | 26 | ||||
-rw-r--r-- | networking/nbd-client.c | 2 | ||||
-rw-r--r-- | networking/ping.c | 6 | ||||
-rw-r--r-- | networking/route.c | 71 | ||||
-rw-r--r-- | networking/telnetd.c | 4 | ||||
-rw-r--r-- | networking/tftp.c | 39 | ||||
-rw-r--r-- | networking/traceroute.c | 3 | ||||
-rw-r--r-- | networking/udhcp/dhcprelay.c | 2 | ||||
-rw-r--r-- | networking/udhcp/dumpleases.c | 2 | ||||
-rw-r--r-- | networking/udhcp/socket.c | 25 |
11 files changed, 88 insertions, 93 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index fa42d9850..b8113a843 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -1522,6 +1522,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what) | |||
1522 | struct stat sb; | 1522 | struct stat sb; |
1523 | fstat(fd, &sb); | 1523 | fstat(fd, &sb); |
1524 | file_size = sb.st_size; | 1524 | file_size = sb.st_size; |
1525 | last_mod = sb.st_mtime; | ||
1525 | } else { | 1526 | } else { |
1526 | IF_FEATURE_HTTPD_GZIP(content_gzip = 0;) | 1527 | IF_FEATURE_HTTPD_GZIP(content_gzip = 0;) |
1527 | fd = open(url, O_RDONLY); | 1528 | fd = open(url, O_RDONLY); |
diff --git a/networking/ifplugd.c b/networking/ifplugd.c index 58f56dbf1..8dd0a5bd8 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c | |||
@@ -131,18 +131,21 @@ static int network_ioctl(int request, void* data, const char *errmsg) | |||
131 | 131 | ||
132 | static smallint detect_link_mii(void) | 132 | static smallint detect_link_mii(void) |
133 | { | 133 | { |
134 | struct ifreq ifreq; | 134 | /* char buffer instead of bona-fide struct avoids aliasing warning */ |
135 | struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; | 135 | char buf[sizeof(struct ifreq)]; |
136 | struct ifreq *const ifreq = (void *)buf; | ||
136 | 137 | ||
137 | set_ifreq_to_ifname(&ifreq); | 138 | struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data; |
139 | |||
140 | set_ifreq_to_ifname(ifreq); | ||
138 | 141 | ||
139 | if (network_ioctl(SIOCGMIIPHY, &ifreq, "SIOCGMIIPHY") < 0) { | 142 | if (network_ioctl(SIOCGMIIPHY, ifreq, "SIOCGMIIPHY") < 0) { |
140 | return IFSTATUS_ERR; | 143 | return IFSTATUS_ERR; |
141 | } | 144 | } |
142 | 145 | ||
143 | mii->reg_num = 1; | 146 | mii->reg_num = 1; |
144 | 147 | ||
145 | if (network_ioctl(SIOCGMIIREG, &ifreq, "SIOCGMIIREG") < 0) { | 148 | if (network_ioctl(SIOCGMIIREG, ifreq, "SIOCGMIIREG") < 0) { |
146 | return IFSTATUS_ERR; | 149 | return IFSTATUS_ERR; |
147 | } | 150 | } |
148 | 151 | ||
@@ -151,18 +154,21 @@ static smallint detect_link_mii(void) | |||
151 | 154 | ||
152 | static smallint detect_link_priv(void) | 155 | static smallint detect_link_priv(void) |
153 | { | 156 | { |
154 | struct ifreq ifreq; | 157 | /* char buffer instead of bona-fide struct avoids aliasing warning */ |
155 | struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; | 158 | char buf[sizeof(struct ifreq)]; |
159 | struct ifreq *const ifreq = (void *)buf; | ||
156 | 160 | ||
157 | set_ifreq_to_ifname(&ifreq); | 161 | struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data; |
162 | |||
163 | set_ifreq_to_ifname(ifreq); | ||
158 | 164 | ||
159 | if (network_ioctl(SIOCDEVPRIVATE, &ifreq, "SIOCDEVPRIVATE") < 0) { | 165 | if (network_ioctl(SIOCDEVPRIVATE, ifreq, "SIOCDEVPRIVATE") < 0) { |
160 | return IFSTATUS_ERR; | 166 | return IFSTATUS_ERR; |
161 | } | 167 | } |
162 | 168 | ||
163 | mii->reg_num = 1; | 169 | mii->reg_num = 1; |
164 | 170 | ||
165 | if (network_ioctl(SIOCDEVPRIVATE+1, &ifreq, "SIOCDEVPRIVATE+1") < 0) { | 171 | if (network_ioctl(SIOCDEVPRIVATE+1, ifreq, "SIOCDEVPRIVATE+1") < 0) { |
166 | return IFSTATUS_ERR; | 172 | return IFSTATUS_ERR; |
167 | } | 173 | } |
168 | 174 | ||
diff --git a/networking/nbd-client.c b/networking/nbd-client.c index 8b856eda7..cadda5261 100644 --- a/networking/nbd-client.c +++ b/networking/nbd-client.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <netinet/tcp.h> | 7 | #include <netinet/tcp.h> |
8 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
9 | 9 | ||
10 | //applet:IF_NBDCLIENT(APPLET_ODDNAME(nbd-client, nbdclient, _BB_DIR_USR_SBIN, _BB_SUID_DROP, nbdclient)) | 10 | //applet:IF_NBDCLIENT(APPLET_ODDNAME(nbd-client, nbdclient, BB_DIR_USR_SBIN, BB_SUID_DROP, nbdclient)) |
11 | 11 | ||
12 | //kbuild:lib-$(CONFIG_NBDCLIENT) += nbd-client.o | 12 | //kbuild:lib-$(CONFIG_NBDCLIENT) += nbd-client.o |
13 | 13 | ||
diff --git a/networking/ping.c b/networking/ping.c index 366a98668..11ce24eb5 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -52,9 +52,9 @@ | |||
52 | //config: Make the output from the ping applet include statistics, and at the | 52 | //config: Make the output from the ping applet include statistics, and at the |
53 | //config: same time provide full support for ICMP packets. | 53 | //config: same time provide full support for ICMP packets. |
54 | 54 | ||
55 | /* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore _BB_SUID_MAYBE: */ | 55 | /* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore BB_SUID_MAYBE: */ |
56 | //applet:IF_PING(APPLET(ping, _BB_DIR_BIN, _BB_SUID_MAYBE)) | 56 | //applet:IF_PING(APPLET(ping, BB_DIR_BIN, BB_SUID_MAYBE)) |
57 | //applet:IF_PING6(APPLET(ping6, _BB_DIR_BIN, _BB_SUID_MAYBE)) | 57 | //applet:IF_PING6(APPLET(ping6, BB_DIR_BIN, BB_SUID_MAYBE)) |
58 | 58 | ||
59 | //kbuild:lib-$(CONFIG_PING) += ping.o | 59 | //kbuild:lib-$(CONFIG_PING) += ping.o |
60 | //kbuild:lib-$(CONFIG_PING6) += ping.o | 60 | //kbuild:lib-$(CONFIG_PING6) += ping.o |
diff --git a/networking/route.c b/networking/route.c index 98567aaee..b7d08dd63 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -153,7 +153,10 @@ static int kw_lookup(const char *kwtbl, char ***pargs) | |||
153 | 153 | ||
154 | static NOINLINE void INET_setroute(int action, char **args) | 154 | static NOINLINE void INET_setroute(int action, char **args) |
155 | { | 155 | { |
156 | struct rtentry rt; | 156 | /* char buffer instead of bona-fide struct avoids aliasing warning */ |
157 | char rt_buf[sizeof(struct rtentry)]; | ||
158 | struct rtentry *const rt = (void *)rt_buf; | ||
159 | |||
157 | const char *netmask = NULL; | 160 | const char *netmask = NULL; |
158 | int skfd, isnet, xflag; | 161 | int skfd, isnet, xflag; |
159 | 162 | ||
@@ -166,7 +169,7 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
166 | } | 169 | } |
167 | 170 | ||
168 | /* Clean out the RTREQ structure. */ | 171 | /* Clean out the RTREQ structure. */ |
169 | memset(&rt, 0, sizeof(rt)); | 172 | memset(rt, 0, sizeof(*rt)); |
170 | 173 | ||
171 | { | 174 | { |
172 | const char *target = *args++; | 175 | const char *target = *args++; |
@@ -178,17 +181,17 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
178 | int prefix_len; | 181 | int prefix_len; |
179 | 182 | ||
180 | prefix_len = xatoul_range(prefix+1, 0, 32); | 183 | prefix_len = xatoul_range(prefix+1, 0, 32); |
181 | mask_in_addr(rt) = htonl( ~(0xffffffffUL >> prefix_len)); | 184 | mask_in_addr(*rt) = htonl( ~(0xffffffffUL >> prefix_len)); |
182 | *prefix = '\0'; | 185 | *prefix = '\0'; |
183 | #if HAVE_NEW_ADDRT | 186 | #if HAVE_NEW_ADDRT |
184 | rt.rt_genmask.sa_family = AF_INET; | 187 | rt->rt_genmask.sa_family = AF_INET; |
185 | #endif | 188 | #endif |
186 | } else { | 189 | } else { |
187 | /* Default netmask. */ | 190 | /* Default netmask. */ |
188 | netmask = "default"; | 191 | netmask = "default"; |
189 | } | 192 | } |
190 | /* Prefer hostname lookup is -host flag (xflag==1) was given. */ | 193 | /* Prefer hostname lookup is -host flag (xflag==1) was given. */ |
191 | isnet = INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst, | 194 | isnet = INET_resolve(target, (struct sockaddr_in *) &rt->rt_dst, |
192 | (xflag & HOST_FLAG)); | 195 | (xflag & HOST_FLAG)); |
193 | if (isnet < 0) { | 196 | if (isnet < 0) { |
194 | bb_error_msg_and_die("resolving %s", target); | 197 | bb_error_msg_and_die("resolving %s", target); |
@@ -204,20 +207,20 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
204 | } | 207 | } |
205 | 208 | ||
206 | /* Fill in the other fields. */ | 209 | /* Fill in the other fields. */ |
207 | rt.rt_flags = ((isnet) ? RTF_UP : (RTF_UP | RTF_HOST)); | 210 | rt->rt_flags = ((isnet) ? RTF_UP : (RTF_UP | RTF_HOST)); |
208 | 211 | ||
209 | while (*args) { | 212 | while (*args) { |
210 | int k = kw_lookup(tbl_ipvx, &args); | 213 | int k = kw_lookup(tbl_ipvx, &args); |
211 | const char *args_m1 = args[-1]; | 214 | const char *args_m1 = args[-1]; |
212 | 215 | ||
213 | if (k & KW_IPVx_FLAG_ONLY) { | 216 | if (k & KW_IPVx_FLAG_ONLY) { |
214 | rt.rt_flags |= flags_ipvx[k & 3]; | 217 | rt->rt_flags |= flags_ipvx[k & 3]; |
215 | continue; | 218 | continue; |
216 | } | 219 | } |
217 | 220 | ||
218 | #if HAVE_NEW_ADDRT | 221 | #if HAVE_NEW_ADDRT |
219 | if (k == KW_IPVx_METRIC) { | 222 | if (k == KW_IPVx_METRIC) { |
220 | rt.rt_metric = xatoul(args_m1) + 1; | 223 | rt->rt_metric = xatoul(args_m1) + 1; |
221 | continue; | 224 | continue; |
222 | } | 225 | } |
223 | #endif | 226 | #endif |
@@ -225,7 +228,7 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
225 | if (k == KW_IPVx_NETMASK) { | 228 | if (k == KW_IPVx_NETMASK) { |
226 | struct sockaddr mask; | 229 | struct sockaddr mask; |
227 | 230 | ||
228 | if (mask_in_addr(rt)) { | 231 | if (mask_in_addr(*rt)) { |
229 | bb_show_usage(); | 232 | bb_show_usage(); |
230 | } | 233 | } |
231 | 234 | ||
@@ -234,18 +237,18 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
234 | if (isnet < 0) { | 237 | if (isnet < 0) { |
235 | bb_error_msg_and_die("resolving %s", netmask); | 238 | bb_error_msg_and_die("resolving %s", netmask); |
236 | } | 239 | } |
237 | rt.rt_genmask = full_mask(mask); | 240 | rt->rt_genmask = full_mask(mask); |
238 | continue; | 241 | continue; |
239 | } | 242 | } |
240 | 243 | ||
241 | if (k == KW_IPVx_GATEWAY) { | 244 | if (k == KW_IPVx_GATEWAY) { |
242 | if (rt.rt_flags & RTF_GATEWAY) { | 245 | if (rt->rt_flags & RTF_GATEWAY) { |
243 | bb_show_usage(); | 246 | bb_show_usage(); |
244 | } | 247 | } |
245 | 248 | ||
246 | isnet = INET_resolve(args_m1, | 249 | isnet = INET_resolve(args_m1, |
247 | (struct sockaddr_in *) &rt.rt_gateway, 1); | 250 | (struct sockaddr_in *) &rt->rt_gateway, 1); |
248 | rt.rt_flags |= RTF_GATEWAY; | 251 | rt->rt_flags |= RTF_GATEWAY; |
249 | 252 | ||
250 | if (isnet) { | 253 | if (isnet) { |
251 | if (isnet < 0) { | 254 | if (isnet < 0) { |
@@ -257,24 +260,24 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
257 | } | 260 | } |
258 | 261 | ||
259 | if (k == KW_IPVx_MSS) { /* Check valid MSS bounds. */ | 262 | if (k == KW_IPVx_MSS) { /* Check valid MSS bounds. */ |
260 | rt.rt_flags |= RTF_MSS; | 263 | rt->rt_flags |= RTF_MSS; |
261 | rt.rt_mss = xatoul_range(args_m1, 64, 32768); | 264 | rt->rt_mss = xatoul_range(args_m1, 64, 32768); |
262 | continue; | 265 | continue; |
263 | } | 266 | } |
264 | 267 | ||
265 | if (k == KW_IPVx_WINDOW) { /* Check valid window bounds. */ | 268 | if (k == KW_IPVx_WINDOW) { /* Check valid window bounds. */ |
266 | rt.rt_flags |= RTF_WINDOW; | 269 | rt->rt_flags |= RTF_WINDOW; |
267 | rt.rt_window = xatoul_range(args_m1, 128, INT_MAX); | 270 | rt->rt_window = xatoul_range(args_m1, 128, INT_MAX); |
268 | continue; | 271 | continue; |
269 | } | 272 | } |
270 | 273 | ||
271 | #ifdef RTF_IRTT | 274 | #ifdef RTF_IRTT |
272 | if (k == KW_IPVx_IRTT) { | 275 | if (k == KW_IPVx_IRTT) { |
273 | rt.rt_flags |= RTF_IRTT; | 276 | rt->rt_flags |= RTF_IRTT; |
274 | rt.rt_irtt = xatoul(args_m1); | 277 | rt->rt_irtt = xatoul(args_m1); |
275 | rt.rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ | 278 | rt->rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ |
276 | #if 0 /* FIXME: do we need to check anything of this? */ | 279 | #if 0 /* FIXME: do we need to check anything of this? */ |
277 | if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) { | 280 | if (rt->rt_irtt < 1 || rt->rt_irtt > (120 * HZ)) { |
278 | bb_error_msg_and_die("bad irtt"); | 281 | bb_error_msg_and_die("bad irtt"); |
279 | } | 282 | } |
280 | #endif | 283 | #endif |
@@ -284,9 +287,9 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
284 | 287 | ||
285 | /* Device is special in that it can be the last arg specified | 288 | /* Device is special in that it can be the last arg specified |
286 | * and doesn't requre the dev/device keyword in that case. */ | 289 | * and doesn't requre the dev/device keyword in that case. */ |
287 | if (!rt.rt_dev && ((k == KW_IPVx_DEVICE) || (!k && !*++args))) { | 290 | if (!rt->rt_dev && ((k == KW_IPVx_DEVICE) || (!k && !*++args))) { |
288 | /* Don't use args_m1 here since args may have changed! */ | 291 | /* Don't use args_m1 here since args may have changed! */ |
289 | rt.rt_dev = args[-1]; | 292 | rt->rt_dev = args[-1]; |
290 | continue; | 293 | continue; |
291 | } | 294 | } |
292 | 295 | ||
@@ -295,41 +298,41 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
295 | } | 298 | } |
296 | 299 | ||
297 | #ifdef RTF_REJECT | 300 | #ifdef RTF_REJECT |
298 | if ((rt.rt_flags & RTF_REJECT) && !rt.rt_dev) { | 301 | if ((rt->rt_flags & RTF_REJECT) && !rt->rt_dev) { |
299 | rt.rt_dev = (char*)"lo"; | 302 | rt->rt_dev = (char*)"lo"; |
300 | } | 303 | } |
301 | #endif | 304 | #endif |
302 | 305 | ||
303 | /* sanity checks.. */ | 306 | /* sanity checks.. */ |
304 | if (mask_in_addr(rt)) { | 307 | if (mask_in_addr(*rt)) { |
305 | uint32_t mask = mask_in_addr(rt); | 308 | uint32_t mask = mask_in_addr(*rt); |
306 | 309 | ||
307 | mask = ~ntohl(mask); | 310 | mask = ~ntohl(mask); |
308 | if ((rt.rt_flags & RTF_HOST) && mask != 0xffffffff) { | 311 | if ((rt->rt_flags & RTF_HOST) && mask != 0xffffffff) { |
309 | bb_error_msg_and_die("netmask %.8x and host route conflict", | 312 | bb_error_msg_and_die("netmask %.8x and host route conflict", |
310 | (unsigned int) mask); | 313 | (unsigned int) mask); |
311 | } | 314 | } |
312 | if (mask & (mask + 1)) { | 315 | if (mask & (mask + 1)) { |
313 | bb_error_msg_and_die("bogus netmask %s", netmask); | 316 | bb_error_msg_and_die("bogus netmask %s", netmask); |
314 | } | 317 | } |
315 | mask = ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr; | 318 | mask = ((struct sockaddr_in *) &rt->rt_dst)->sin_addr.s_addr; |
316 | if (mask & ~(uint32_t)mask_in_addr(rt)) { | 319 | if (mask & ~(uint32_t)mask_in_addr(*rt)) { |
317 | bb_error_msg_and_die("netmask and route address conflict"); | 320 | bb_error_msg_and_die("netmask and route address conflict"); |
318 | } | 321 | } |
319 | } | 322 | } |
320 | 323 | ||
321 | /* Fill out netmask if still unset */ | 324 | /* Fill out netmask if still unset */ |
322 | if ((action == RTACTION_ADD) && (rt.rt_flags & RTF_HOST)) { | 325 | if ((action == RTACTION_ADD) && (rt->rt_flags & RTF_HOST)) { |
323 | mask_in_addr(rt) = 0xffffffff; | 326 | mask_in_addr(*rt) = 0xffffffff; |
324 | } | 327 | } |
325 | 328 | ||
326 | /* Create a socket to the INET kernel. */ | 329 | /* Create a socket to the INET kernel. */ |
327 | skfd = xsocket(AF_INET, SOCK_DGRAM, 0); | 330 | skfd = xsocket(AF_INET, SOCK_DGRAM, 0); |
328 | 331 | ||
329 | if (action == RTACTION_ADD) | 332 | if (action == RTACTION_ADD) |
330 | xioctl(skfd, SIOCADDRT, &rt); | 333 | xioctl(skfd, SIOCADDRT, rt); |
331 | else | 334 | else |
332 | xioctl(skfd, SIOCDELRT, &rt); | 335 | xioctl(skfd, SIOCDELRT, rt); |
333 | 336 | ||
334 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); | 337 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); |
335 | } | 338 | } |
diff --git a/networking/telnetd.c b/networking/telnetd.c index 07c6a6a73..eec4417ca 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -31,10 +31,6 @@ | |||
31 | #endif | 31 | #endif |
32 | #include <arpa/telnet.h> | 32 | #include <arpa/telnet.h> |
33 | 33 | ||
34 | #if ENABLE_FEATURE_UTMP | ||
35 | # include <utmp.h> /* LOGIN_PROCESS */ | ||
36 | #endif | ||
37 | |||
38 | 34 | ||
39 | struct tsession { | 35 | struct tsession { |
40 | struct tsession *next; | 36 | struct tsession *next; |
diff --git a/networking/tftp.c b/networking/tftp.c index 04c8f0ebb..fcd933f6a 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -105,39 +105,22 @@ struct BUG_G_too_big { | |||
105 | #define error_pkt_str (error_pkt + 4) | 105 | #define error_pkt_str (error_pkt + 4) |
106 | 106 | ||
107 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR | 107 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR |
108 | /* SIGALRM logic nicked from the wget applet */ | 108 | static void tftp_progress_update(void) |
109 | static void progress_meter(int flag) | ||
110 | { | 109 | { |
111 | /* We can be called from signal handler */ | ||
112 | int save_errno = errno; | ||
113 | |||
114 | if (flag == -1) { /* first call to progress_meter */ | ||
115 | bb_progress_init(&G.pmt); | ||
116 | } | ||
117 | |||
118 | bb_progress_update(&G.pmt, G.file, 0, G.pos, G.size); | 110 | bb_progress_update(&G.pmt, G.file, 0, G.pos, G.size); |
119 | |||
120 | if (flag == 0) { | ||
121 | /* last call to progress_meter */ | ||
122 | alarm(0); | ||
123 | bb_putchar_stderr('\n'); | ||
124 | } else { | ||
125 | if (flag == -1) { /* first call to progress_meter */ | ||
126 | signal_SA_RESTART_empty_mask(SIGALRM, progress_meter); | ||
127 | } | ||
128 | alarm(1); | ||
129 | } | ||
130 | |||
131 | errno = save_errno; | ||
132 | } | 111 | } |
133 | static void tftp_progress_init(void) | 112 | static void tftp_progress_init(void) |
134 | { | 113 | { |
135 | progress_meter(-1); | 114 | bb_progress_init(&G.pmt); |
115 | tftp_progress_update(); | ||
136 | } | 116 | } |
137 | static void tftp_progress_done(void) | 117 | static void tftp_progress_done(void) |
138 | { | 118 | { |
139 | if (G.pmt.inited) | 119 | if (G.pmt.inited) { |
140 | progress_meter(0); | 120 | tftp_progress_update(); |
121 | bb_putchar_stderr('\n'); | ||
122 | G.pmt.inited = 0; | ||
123 | } | ||
141 | } | 124 | } |
142 | #else | 125 | #else |
143 | # define tftp_progress_init() ((void)0) | 126 | # define tftp_progress_init() ((void)0) |
@@ -460,9 +443,10 @@ static int tftp_protocol( | |||
460 | xsendto(socket_fd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len); | 443 | xsendto(socket_fd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len); |
461 | 444 | ||
462 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR | 445 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR |
463 | if (ENABLE_TFTP && remote_file) { /* tftp */ | 446 | if (ENABLE_TFTP && remote_file) /* tftp */ |
464 | G.pos = (block_nr - 1) * (uoff_t)blksize; | 447 | G.pos = (block_nr - 1) * (uoff_t)blksize; |
465 | } | 448 | if (G.pmt.inited) |
449 | tftp_progress_update(); | ||
466 | #endif | 450 | #endif |
467 | /* Was it final ACK? then exit */ | 451 | /* Was it final ACK? then exit */ |
468 | if (finished && (opcode == TFTP_ACK)) | 452 | if (finished && (opcode == TFTP_ACK)) |
@@ -479,6 +463,7 @@ static int tftp_protocol( | |||
479 | case 0: | 463 | case 0: |
480 | retries--; | 464 | retries--; |
481 | if (retries == 0) { | 465 | if (retries == 0) { |
466 | tftp_progress_done(); | ||
482 | bb_error_msg("timeout"); | 467 | bb_error_msg("timeout"); |
483 | goto ret; /* no err packet sent */ | 468 | goto ret; /* no err packet sent */ |
484 | } | 469 | } |
diff --git a/networking/traceroute.c b/networking/traceroute.c index c18fba8d0..82bb0118c 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -751,7 +751,8 @@ print(int read_len, const struct sockaddr *from, const struct sockaddr *to) | |||
751 | } else | 751 | } else |
752 | #endif | 752 | #endif |
753 | { | 753 | { |
754 | read_len -= ((struct ip*)recv_pkt)->ip_hl << 2; | 754 | struct ip *ip4packet = (struct ip*)recv_pkt; |
755 | read_len -= ip4packet->ip_hl << 2; | ||
755 | } | 756 | } |
756 | printf(" %d bytes to %s", read_len, ina); | 757 | printf(" %d bytes to %s", read_len, ina); |
757 | free(ina); | 758 | free(ina); |
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index 759a4ba03..86ef04a62 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c | |||
@@ -25,7 +25,7 @@ struct xid_item { | |||
25 | uint32_t xid; | 25 | uint32_t xid; |
26 | struct sockaddr_in ip; | 26 | struct sockaddr_in ip; |
27 | struct xid_item *next; | 27 | struct xid_item *next; |
28 | }; | 28 | } FIX_ALIASING; |
29 | 29 | ||
30 | #define dhcprelay_xid_list (*(struct xid_item*)&bb_common_bufsiz1) | 30 | #define dhcprelay_xid_list (*(struct xid_item*)&bb_common_bufsiz1) |
31 | 31 | ||
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c index a15e409cc..21d62a2d2 100644 --- a/networking/udhcp/dumpleases.c +++ b/networking/udhcp/dumpleases.c | |||
@@ -57,7 +57,7 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv) | |||
57 | addr.s_addr = lease.lease_nip; | 57 | addr.s_addr = lease.lease_nip; |
58 | #if ENABLE_UNICODE_SUPPORT | 58 | #if ENABLE_UNICODE_SUPPORT |
59 | { | 59 | { |
60 | char *uni_name = unicode_conv_to_printable_fixedwidth(NULL, lease.hostname, 19); | 60 | char *uni_name = unicode_conv_to_printable_fixedwidth(/*NULL,*/ lease.hostname, 19); |
61 | printf(" %-16s%s ", inet_ntoa(addr), uni_name); | 61 | printf(" %-16s%s ", inet_ntoa(addr), uni_name); |
62 | free(uni_name); | 62 | free(uni_name); |
63 | } | 63 | } |
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c index 0ed7ad1c6..39f1cec54 100644 --- a/networking/udhcp/socket.c +++ b/networking/udhcp/socket.c | |||
@@ -36,42 +36,45 @@ | |||
36 | 36 | ||
37 | int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *mac) | 37 | int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *mac) |
38 | { | 38 | { |
39 | /* char buffer instead of bona-fide struct avoids aliasing warning */ | ||
40 | char ifr_buf[sizeof(struct ifreq)]; | ||
41 | struct ifreq *const ifr = (void *)ifr_buf; | ||
42 | |||
39 | int fd; | 43 | int fd; |
40 | struct ifreq ifr; | ||
41 | struct sockaddr_in *our_ip; | 44 | struct sockaddr_in *our_ip; |
42 | 45 | ||
43 | memset(&ifr, 0, sizeof(ifr)); | 46 | memset(ifr, 0, sizeof(*ifr)); |
44 | fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); | 47 | fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); |
45 | 48 | ||
46 | ifr.ifr_addr.sa_family = AF_INET; | 49 | ifr->ifr_addr.sa_family = AF_INET; |
47 | strncpy_IFNAMSIZ(ifr.ifr_name, interface); | 50 | strncpy_IFNAMSIZ(ifr->ifr_name, interface); |
48 | if (nip) { | 51 | if (nip) { |
49 | if (ioctl_or_perror(fd, SIOCGIFADDR, &ifr, | 52 | if (ioctl_or_perror(fd, SIOCGIFADDR, ifr, |
50 | "is interface %s up and configured?", interface) | 53 | "is interface %s up and configured?", interface) |
51 | ) { | 54 | ) { |
52 | close(fd); | 55 | close(fd); |
53 | return -1; | 56 | return -1; |
54 | } | 57 | } |
55 | our_ip = (struct sockaddr_in *) &ifr.ifr_addr; | 58 | our_ip = (struct sockaddr_in *) &ifr->ifr_addr; |
56 | *nip = our_ip->sin_addr.s_addr; | 59 | *nip = our_ip->sin_addr.s_addr; |
57 | log1("IP %s", inet_ntoa(our_ip->sin_addr)); | 60 | log1("IP %s", inet_ntoa(our_ip->sin_addr)); |
58 | } | 61 | } |
59 | 62 | ||
60 | if (ifindex) { | 63 | if (ifindex) { |
61 | if (ioctl_or_warn(fd, SIOCGIFINDEX, &ifr) != 0) { | 64 | if (ioctl_or_warn(fd, SIOCGIFINDEX, ifr) != 0) { |
62 | close(fd); | 65 | close(fd); |
63 | return -1; | 66 | return -1; |
64 | } | 67 | } |
65 | log1("Adapter index %d", ifr.ifr_ifindex); | 68 | log1("Adapter index %d", ifr->ifr_ifindex); |
66 | *ifindex = ifr.ifr_ifindex; | 69 | *ifindex = ifr->ifr_ifindex; |
67 | } | 70 | } |
68 | 71 | ||
69 | if (mac) { | 72 | if (mac) { |
70 | if (ioctl_or_warn(fd, SIOCGIFHWADDR, &ifr) != 0) { | 73 | if (ioctl_or_warn(fd, SIOCGIFHWADDR, ifr) != 0) { |
71 | close(fd); | 74 | close(fd); |
72 | return -1; | 75 | return -1; |
73 | } | 76 | } |
74 | memcpy(mac, ifr.ifr_hwaddr.sa_data, 6); | 77 | memcpy(mac, ifr->ifr_hwaddr.sa_data, 6); |
75 | log1("MAC %02x:%02x:%02x:%02x:%02x:%02x", | 78 | log1("MAC %02x:%02x:%02x:%02x:%02x:%02x", |
76 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); | 79 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
77 | } | 80 | } |