diff options
author | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-12 17:55:51 +0000 |
---|---|---|
committer | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-04-12 17:55:51 +0000 |
commit | 00657c96b9b3963230d89ccc3dc2959d034673e7 (patch) | |
tree | 0e4c34863628d79fdad0c6217f4deb0ca0a91c33 /networking | |
parent | fa6199c4ed8fdbb6901f43a06fb22d37e6e9b9e1 (diff) | |
download | busybox-w32-00657c96b9b3963230d89ccc3dc2959d034673e7.tar.gz busybox-w32-00657c96b9b3963230d89ccc3dc2959d034673e7.tar.bz2 busybox-w32-00657c96b9b3963230d89ccc3dc2959d034673e7.zip |
- patch from Denis Vlasenko to add and use bb_xsocket() and to use
bb_xopen some more while at it.
Also use shorter boilerplate while at it.
git-svn-id: svn://busybox.net/trunk/busybox@14833 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r-- | networking/arping.c | 4 | ||||
-rw-r--r-- | networking/dnsd.c | 4 | ||||
-rw-r--r-- | networking/ether-wake.c | 12 | ||||
-rw-r--r-- | networking/fakeidentd.c | 18 | ||||
-rw-r--r-- | networking/httpd.c | 40 | ||||
-rw-r--r-- | networking/ifconfig.c | 14 | ||||
-rw-r--r-- | networking/nc.c | 17 | ||||
-rw-r--r-- | networking/route.c | 15 | ||||
-rw-r--r-- | networking/telnetd.c | 12 | ||||
-rw-r--r-- | networking/tftp.c | 54 | ||||
-rw-r--r-- | networking/traceroute.c | 12 | ||||
-rw-r--r-- | networking/vconfig.c | 26 |
12 files changed, 65 insertions, 163 deletions
diff --git a/networking/arping.c b/networking/arping.c index 48c14f15c..721368273 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* vi:set ts=4:*/ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * arping.c - Ping hosts by ARP requests/replies | 3 | * arping.c - Ping hosts by ARP requests/replies |
4 | * | 4 | * |
@@ -358,7 +358,7 @@ int arping_main(int argc, char **argv) | |||
358 | 358 | ||
359 | if (!(cfg&dad) || src.s_addr) { | 359 | if (!(cfg&dad) || src.s_addr) { |
360 | struct sockaddr_in saddr; | 360 | struct sockaddr_in saddr; |
361 | int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); | 361 | int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); /* maybe use bb_xsocket? */ |
362 | 362 | ||
363 | if (probe_fd < 0) { | 363 | if (probe_fd < 0) { |
364 | bb_error_msg_and_die("socket"); | 364 | bb_error_msg_and_die("socket"); |
diff --git a/networking/dnsd.c b/networking/dnsd.c index a815860ab..9c5193820 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * Mini DNS server implementation for busybox | 3 | * Mini DNS server implementation for busybox |
3 | * | 4 | * |
@@ -204,8 +205,7 @@ listen_socket(char *iface_addr, int listen_port) | |||
204 | char msg[100]; | 205 | char msg[100]; |
205 | int s; | 206 | int s; |
206 | int yes = 1; | 207 | int yes = 1; |
207 | if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0) | 208 | s = bb_xsocket(PF_INET, SOCK_DGRAM, 0); |
208 | bb_perror_msg_and_die("socket() failed"); | ||
209 | #ifdef SO_REUSEADDR | 209 | #ifdef SO_REUSEADDR |
210 | if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes)) < 0) | 210 | if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes)) < 0) |
211 | bb_perror_msg_and_die("setsockopt() failed"); | 211 | bb_perror_msg_and_die("setsockopt() failed"); |
diff --git a/networking/ether-wake.c b/networking/ether-wake.c index 7d5f79b6a..b4fb0c2d1 100644 --- a/networking/ether-wake.c +++ b/networking/ether-wake.c | |||
@@ -1,10 +1,8 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * ether-wake.c - Send a magic packet to wake up sleeping machines. | 3 | * ether-wake.c - Send a magic packet to wake up sleeping machines. |
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or | 5 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | * | 6 | * |
9 | * Author: Donald Becker, http://www.scyld.com/"; http://www.scyld.com/wakeonlan.html | 7 | * Author: Donald Becker, http://www.scyld.com/"; http://www.scyld.com/wakeonlan.html |
10 | * Busybox port: Christian Volkmann <haveaniceday@online.de> | 8 | * Busybox port: Christian Volkmann <haveaniceday@online.de> |
@@ -95,10 +93,10 @@ | |||
95 | */ | 93 | */ |
96 | #ifdef PF_PACKET | 94 | #ifdef PF_PACKET |
97 | # define whereto_t sockaddr_ll | 95 | # define whereto_t sockaddr_ll |
98 | # define make_socket() socket(PF_PACKET, SOCK_RAW, 0) | 96 | # define make_socket() bb_xsocket(PF_PACKET, SOCK_RAW, 0) |
99 | #else | 97 | #else |
100 | # define whereto_t sockaddr | 98 | # define whereto_t sockaddr |
101 | # define make_socket() socket(AF_INET, SOCK_PACKET, SOCK_PACKET) | 99 | # define make_socket() bb_xsocket(AF_INET, SOCK_PACKET, SOCK_PACKET) |
102 | #endif | 100 | #endif |
103 | 101 | ||
104 | #ifdef DEBUG | 102 | #ifdef DEBUG |
@@ -145,8 +143,6 @@ int etherwake_main(int argc, char *argv[]) | |||
145 | 143 | ||
146 | /* create the raw socket */ | 144 | /* create the raw socket */ |
147 | s = make_socket(); | 145 | s = make_socket(); |
148 | if (s < 0) | ||
149 | bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket); | ||
150 | 146 | ||
151 | /* now that we have a raw socket we can drop root */ | 147 | /* now that we have a raw socket we can drop root */ |
152 | setuid(getuid()); | 148 | setuid(getuid()); |
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c index 5442c22c2..26efdcb34 100644 --- a/networking/fakeidentd.c +++ b/networking/fakeidentd.c | |||
@@ -6,20 +6,7 @@ | |||
6 | * Original Author: Tomi Ollila <too@iki.fi> | 6 | * Original Author: Tomi Ollila <too@iki.fi> |
7 | * http://www.guru-group.fi/~too/sw/ | 7 | * http://www.guru-group.fi/~too/sw/ |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | ||
23 | */ | 10 | */ |
24 | 11 | ||
25 | #include <unistd.h> | 12 | #include <unistd.h> |
@@ -117,8 +104,7 @@ static void inetbind(void) | |||
117 | else | 104 | else |
118 | port = se->s_port; | 105 | port = se->s_port; |
119 | 106 | ||
120 | if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) | 107 | s = bb_xsocket(AF_INET, SOCK_STREAM, 0); |
121 | bb_perror_msg_and_die("Cannot create server socket"); | ||
122 | 108 | ||
123 | setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); | 109 | setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); |
124 | 110 | ||
diff --git a/networking/httpd.c b/networking/httpd.c index c89073a2a..fde8ae4bd 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -6,19 +6,7 @@ | |||
6 | * | 6 | * |
7 | * simplify patch stolen from libbb without using strdup | 7 | * simplify patch stolen from libbb without using strdup |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
22 | * | 10 | * |
23 | ***************************************************************************** | 11 | ***************************************************************************** |
24 | * | 12 | * |
@@ -959,25 +947,21 @@ static int openServer(void) | |||
959 | memset(&lsocket, 0, sizeof(lsocket)); | 947 | memset(&lsocket, 0, sizeof(lsocket)); |
960 | lsocket.sin_family = AF_INET; | 948 | lsocket.sin_family = AF_INET; |
961 | lsocket.sin_addr.s_addr = INADDR_ANY; | 949 | lsocket.sin_addr.s_addr = INADDR_ANY; |
962 | lsocket.sin_port = htons(config->port) ; | 950 | lsocket.sin_port = htons(config->port); |
963 | fd = socket(AF_INET, SOCK_STREAM, 0); | 951 | fd = bb_xsocket(AF_INET, SOCK_STREAM, 0); |
964 | if (fd >= 0) { | 952 | /* tell the OS it's OK to reuse a previous address even though */ |
965 | /* tell the OS it's OK to reuse a previous address even though */ | 953 | /* it may still be in a close down state. Allows bind to succeed. */ |
966 | /* it may still be in a close down state. Allows bind to succeed. */ | 954 | int on = 1; |
967 | int on = 1; | ||
968 | #ifdef SO_REUSEPORT | 955 | #ifdef SO_REUSEPORT |
969 | setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) ; | 956 | setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) ; |
970 | #else | 957 | #else |
971 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ; | 958 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ; |
972 | #endif | 959 | #endif |
973 | if (bind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)) == 0) { | 960 | if (bind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)) == 0) { |
974 | listen(fd, 9); | 961 | listen(fd, 9); |
975 | signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ | 962 | signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */ |
976 | } else { | ||
977 | bb_perror_msg_and_die("bind"); | ||
978 | } | ||
979 | } else { | 963 | } else { |
980 | bb_perror_msg_and_die("create socket"); | 964 | bb_perror_msg_and_die("bind"); |
981 | } | 965 | } |
982 | return fd; | 966 | return fd; |
983 | } | 967 | } |
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 1e1bd83ee..7b358c43f 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* ifconfig | 2 | /* ifconfig |
2 | * | 3 | * |
3 | * Similar to the standard Unix ifconfig, but with only the necessary | 4 | * Similar to the standard Unix ifconfig, but with only the necessary |
@@ -9,14 +10,7 @@ | |||
9 | * Authors of the original ifconfig was: | 10 | * Authors of the original ifconfig was: |
10 | * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> | 11 | * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> |
11 | * | 12 | * |
12 | * This program is free software; you can redistribute it | 13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
13 | * and/or modify it under the terms of the GNU General | ||
14 | * Public License as published by the Free Software | ||
15 | * Foundation; either version 2 of the License, or (at | ||
16 | * your option) any later version. | ||
17 | * | ||
18 | * $Id: ifconfig.c,v 1.30 2004/03/31 11:30:08 andersen Exp $ | ||
19 | * | ||
20 | */ | 14 | */ |
21 | 15 | ||
22 | /* | 16 | /* |
@@ -335,9 +329,7 @@ int ifconfig_main(int argc, char **argv) | |||
335 | } | 329 | } |
336 | 330 | ||
337 | /* Create a channel to the NET kernel. */ | 331 | /* Create a channel to the NET kernel. */ |
338 | if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { | 332 | sockfd = bb_xsocket(AF_INET, SOCK_DGRAM, 0); |
339 | bb_perror_msg_and_die("socket"); | ||
340 | } | ||
341 | 333 | ||
342 | /* get interface name */ | 334 | /* get interface name */ |
343 | safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ); | 335 | safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ); |
diff --git a/networking/nc.c b/networking/nc.c index 85148c4a7..86f0b99df 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -10,19 +10,7 @@ | |||
10 | 19990512 Uses Select. Charles P. Wright | 10 | 19990512 Uses Select. Charles P. Wright |
11 | 19990513 Fixes stdin stupidity and uses buffers. Charles P. Wright | 11 | 19990513 Fixes stdin stupidity and uses buffers. Charles P. Wright |
12 | 12 | ||
13 | This program is free software; you can redistribute it and/or modify | 13 | Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
14 | it under the terms of the GNU General Public License as published by | ||
15 | the Free Software Foundation; either version 2 of the License, or | ||
16 | (at your option) any later version. | ||
17 | |||
18 | This program is distributed in the hope that it will be useful, | ||
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | GNU General Public License for more details. | ||
22 | |||
23 | You should have received a copy of the GNU General Public License | ||
24 | along with this program; if not, write to the Free Software | ||
25 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
26 | */ | 14 | */ |
27 | 15 | ||
28 | #include <stdio.h> | 16 | #include <stdio.h> |
@@ -87,8 +75,7 @@ int nc_main(int argc, char **argv) | |||
87 | if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc)) | 75 | if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc)) |
88 | bb_show_usage(); | 76 | bb_show_usage(); |
89 | 77 | ||
90 | if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) | 78 | sfd = bb_xsocket(AF_INET, SOCK_STREAM, 0); |
91 | bb_perror_msg_and_die("socket"); | ||
92 | x = 1; | 79 | x = 1; |
93 | if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) | 80 | if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1) |
94 | bb_perror_msg_and_die("reuseaddr"); | 81 | bb_perror_msg_and_die("reuseaddr"); |
diff --git a/networking/route.c b/networking/route.c index 8ae0da182..e7e8f1c02 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* route | 2 | /* route |
2 | * | 3 | * |
3 | * Similar to the standard Unix route, but with only the necessary | 4 | * Similar to the standard Unix route, but with only the necessary |
@@ -9,11 +10,7 @@ | |||
9 | * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> | 10 | * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> |
10 | * (derived from FvK's 'route.c 1.70 01/04/94') | 11 | * (derived from FvK's 'route.c 1.70 01/04/94') |
11 | * | 12 | * |
12 | * This program is free software; you can redistribute it | 13 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
13 | * and/or modify it under the terms of the GNU General | ||
14 | * Public License as published by the Free Software | ||
15 | * Foundation; either version 2 of the License, or (at | ||
16 | * your option) any later version. | ||
17 | * | 14 | * |
18 | * $Id: route.c,v 1.26 2004/03/19 23:27:08 mjn3 Exp $ | 15 | * $Id: route.c,v 1.26 2004/03/19 23:27:08 mjn3 Exp $ |
19 | * | 16 | * |
@@ -338,9 +335,7 @@ static void INET_setroute(int action, char **args) | |||
338 | } | 335 | } |
339 | 336 | ||
340 | /* Create a socket to the INET kernel. */ | 337 | /* Create a socket to the INET kernel. */ |
341 | if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { | 338 | skfd = bb_xsocket(AF_INET, SOCK_DGRAM, 0); |
342 | bb_perror_msg_and_die("socket"); | ||
343 | } | ||
344 | 339 | ||
345 | if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) { | 340 | if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) { |
346 | bb_perror_msg_and_die("SIOC[ADD|DEL]RT"); | 341 | bb_perror_msg_and_die("SIOC[ADD|DEL]RT"); |
@@ -434,9 +429,7 @@ static void INET6_setroute(int action, char **args) | |||
434 | } | 429 | } |
435 | 430 | ||
436 | /* Create a socket to the INET6 kernel. */ | 431 | /* Create a socket to the INET6 kernel. */ |
437 | if ((skfd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { | 432 | skfd = bb_xsocket(AF_INET6, SOCK_DGRAM, 0); |
438 | bb_perror_msg_and_die("socket"); | ||
439 | } | ||
440 | 433 | ||
441 | rt.rtmsg_ifindex = 0; | 434 | rt.rtmsg_ifindex = 0; |
442 | 435 | ||
diff --git a/networking/telnetd.c b/networking/telnetd.c index 8943b2e3b..3e4b42cfa 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -1,10 +1,9 @@ | |||
1 | /* $Id: telnetd.c,v 1.13 2004/09/14 17:24:58 bug1 Exp $ | 1 | /* vi:set ts=4:*/ |
2 | * | 2 | /* |
3 | * Simple telnet server | 3 | * Simple telnet server |
4 | * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) | 4 | * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) |
5 | * | 5 | * |
6 | * This file is distributed under the Gnu Public License (GPL), | 6 | * Licensed under GPL, see file LICENSE in this tarball for details. |
7 | * please see the file LICENSE for further information. | ||
8 | * | 7 | * |
9 | * --------------------------------------------------------------------------- | 8 | * --------------------------------------------------------------------------- |
10 | * (C) Copyright 2000, Axis Communications AB, LUND, SWEDEN | 9 | * (C) Copyright 2000, Axis Communications AB, LUND, SWEDEN |
@@ -446,10 +445,7 @@ telnetd_main(int argc, char **argv) | |||
446 | 445 | ||
447 | /* Grab a TCP socket. */ | 446 | /* Grab a TCP socket. */ |
448 | 447 | ||
449 | master_fd = socket(SOCKET_TYPE, SOCK_STREAM, 0); | 448 | master_fd = bb_xsocket(SOCKET_TYPE, SOCK_STREAM, 0); |
450 | if (master_fd < 0) { | ||
451 | bb_perror_msg_and_die("socket"); | ||
452 | } | ||
453 | (void)setsockopt(master_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); | 449 | (void)setsockopt(master_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); |
454 | 450 | ||
455 | /* Set it to listen to specified port. */ | 451 | /* Set it to listen to specified port. */ |
diff --git a/networking/tftp.c b/networking/tftp.c index ddcb5225f..b830f18a5 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -1,35 +1,23 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* tftp.c */ | 2 | /* ------------------------------------------------------------------------- |
3 | /* */ | 3 | * tftp.c |
4 | /* A simple tftp client for busybox. */ | 4 | * |
5 | /* Tries to follow RFC1350. */ | 5 | * A simple tftp client for busybox. |
6 | /* Only "octet" mode supported. */ | 6 | * Tries to follow RFC1350. |
7 | /* Optional blocksize negotiation (RFC2347 + RFC2348) */ | 7 | * Only "octet" mode supported. |
8 | /* */ | 8 | * Optional blocksize negotiation (RFC2347 + RFC2348) |
9 | /* Copyright (C) 2001 Magnus Damm <damm@opensource.se> */ | 9 | * |
10 | /* */ | 10 | * Copyright (C) 2001 Magnus Damm <damm@opensource.se> |
11 | /* Parts of the code based on: */ | 11 | * |
12 | /* */ | 12 | * Parts of the code based on: |
13 | /* atftp: Copyright (C) 2000 Jean-Pierre Lefebvre <helix@step.polymtl.ca> */ | 13 | * |
14 | /* and Remi Lefebvre <remi@debian.org> */ | 14 | * atftp: Copyright (C) 2000 Jean-Pierre Lefebvre <helix@step.polymtl.ca> |
15 | /* */ | 15 | * and Remi Lefebvre <remi@debian.org> |
16 | /* utftp: Copyright (C) 1999 Uwe Ohse <uwe@ohse.de> */ | 16 | * |
17 | /* */ | 17 | * utftp: Copyright (C) 1999 Uwe Ohse <uwe@ohse.de> |
18 | /* This program is free software; you can redistribute it and/or modify */ | 18 | * |
19 | /* it under the terms of the GNU General Public License as published by */ | 19 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
20 | /* the Free Software Foundation; either version 2 of the License, or */ | 20 | * ------------------------------------------------------------------------- */ |
21 | /* (at your option) any later version. */ | ||
22 | /* */ | ||
23 | /* This program is distributed in the hope that it will be useful, */ | ||
24 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ | ||
25 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ | ||
26 | /* General Public License for more details. */ | ||
27 | /* */ | ||
28 | /* You should have received a copy of the GNU General Public License */ | ||
29 | /* along with this program; if not, write to the Free Software */ | ||
30 | /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
31 | /* */ | ||
32 | /* ------------------------------------------------------------------------- */ | ||
33 | 21 | ||
34 | #include <stdio.h> | 22 | #include <stdio.h> |
35 | #include <stdlib.h> | 23 | #include <stdlib.h> |
@@ -177,7 +165,7 @@ static inline int tftp(const int cmd, const struct hostent *host, | |||
177 | 165 | ||
178 | tftp_bufsize += 4; | 166 | tftp_bufsize += 4; |
179 | 167 | ||
180 | if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { | 168 | if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { /* bb_xsocket? */ |
181 | bb_perror_msg("socket"); | 169 | bb_perror_msg("socket"); |
182 | return EXIT_FAILURE; | 170 | return EXIT_FAILURE; |
183 | } | 171 | } |
diff --git a/networking/traceroute.c b/networking/traceroute.c index 22d27f240..0abd9047d 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -1,3 +1,4 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
1 | /* | 2 | /* |
2 | * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000 | 3 | * Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000 |
3 | * The Regents of the University of California. All rights reserved. | 4 | * The Regents of the University of California. All rights reserved. |
@@ -359,9 +360,7 @@ ifaddrlist(struct IFADDRLIST **ipaddrp) | |||
359 | struct ifreq ibuf[(32 * 1024) / sizeof(struct ifreq)], ifr; | 360 | struct ifreq ibuf[(32 * 1024) / sizeof(struct ifreq)], ifr; |
360 | struct IFADDRLIST *st_ifaddrlist; | 361 | struct IFADDRLIST *st_ifaddrlist; |
361 | 362 | ||
362 | fd = socket(AF_INET, SOCK_DGRAM, 0); | 363 | fd = bb_xsocket(AF_INET, SOCK_DGRAM, 0); |
363 | if (fd < 0) | ||
364 | bb_perror_msg_and_die("socket"); | ||
365 | 364 | ||
366 | ifc.ifc_len = sizeof(ibuf); | 365 | ifc.ifc_len = sizeof(ibuf); |
367 | ifc.ifc_buf = (caddr_t)ibuf; | 366 | ifc.ifc_buf = (caddr_t)ibuf; |
@@ -1091,8 +1090,7 @@ traceroute_main(int argc, char *argv[]) | |||
1091 | if (n > 2) | 1090 | if (n > 2) |
1092 | close(n); | 1091 | close(n); |
1093 | 1092 | ||
1094 | if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0) | 1093 | s = bb_xsocket(AF_INET, SOCK_RAW, pe->p_proto); |
1095 | bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket); | ||
1096 | 1094 | ||
1097 | #ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG | 1095 | #ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG |
1098 | if (op & USAGE_OP_DEBUG) | 1096 | if (op & USAGE_OP_DEBUG) |
@@ -1103,9 +1101,7 @@ traceroute_main(int argc, char *argv[]) | |||
1103 | (void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on, | 1101 | (void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on, |
1104 | sizeof(on)); | 1102 | sizeof(on)); |
1105 | 1103 | ||
1106 | sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); | 1104 | sndsock = bb_xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); |
1107 | if (sndsock < 0) | ||
1108 | bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket); | ||
1109 | 1105 | ||
1110 | #ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE | 1106 | #ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE |
1111 | #if defined(IP_OPTIONS) | 1107 | #if defined(IP_OPTIONS) |
diff --git a/networking/vconfig.c b/networking/vconfig.c index 36458f784..72729c7ed 100644 --- a/networking/vconfig.c +++ b/networking/vconfig.c | |||
@@ -4,20 +4,7 @@ | |||
4 | * | 4 | * |
5 | * Copyright (C) 2001 Manuel Novoa III <mjn3@codepoet.org> | 5 | * Copyright (C) 2001 Manuel Novoa III <mjn3@codepoet.org> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
20 | * | ||
21 | */ | 8 | */ |
22 | 9 | ||
23 | /* BB_AUDIT SUSv3 N/A */ | 10 | /* BB_AUDIT SUSv3 N/A */ |
@@ -136,9 +123,7 @@ int vconfig_main(int argc, char **argv) | |||
136 | } | 123 | } |
137 | 124 | ||
138 | /* Don't bother closing the filedes. It will be closed on cleanup. */ | 125 | /* Don't bother closing the filedes. It will be closed on cleanup. */ |
139 | if (open(conf_file_name, O_RDONLY) < 0) { /* Is 802.1q is present? */ | 126 | bb_xopen(conf_file_name, O_RDONLY); /* Will die if 802.1q is not present */ |
140 | bb_perror_msg_and_die("open %s", conf_file_name); | ||
141 | } | ||
142 | 127 | ||
143 | memset(&ifr, 0, sizeof(struct vlan_ioctl_args)); | 128 | memset(&ifr, 0, sizeof(struct vlan_ioctl_args)); |
144 | 129 | ||
@@ -173,10 +158,9 @@ int vconfig_main(int argc, char **argv) | |||
173 | } | 158 | } |
174 | } | 159 | } |
175 | 160 | ||
176 | if (((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) | 161 | fd = bb_xsocket(AF_INET, SOCK_STREAM, 0); |
177 | || (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) | 162 | if (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) { |
178 | ) { | 163 | bb_perror_msg_and_die("ioctl error for %s", *argv); |
179 | bb_perror_msg_and_die("socket or ioctl error for %s", *argv); | ||
180 | } | 164 | } |
181 | 165 | ||
182 | return 0; | 166 | return 0; |