summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/arping.c4
-rw-r--r--networking/dnsd.c4
-rw-r--r--networking/ether-wake.c12
-rw-r--r--networking/fakeidentd.c18
-rw-r--r--networking/httpd.c40
-rw-r--r--networking/ifconfig.c14
-rw-r--r--networking/nc.c17
-rw-r--r--networking/route.c15
-rw-r--r--networking/telnetd.c12
-rw-r--r--networking/tftp.c54
-rw-r--r--networking/traceroute.c12
-rw-r--r--networking/vconfig.c26
12 files changed, 65 insertions, 163 deletions
diff --git a/networking/arping.c b/networking/arping.c
index 48c14f1..7213682 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -1,4 +1,4 @@
-/* vi:set ts=4:*/
+/* vi: set sw=4 ts=4: */
/*
* arping.c - Ping hosts by ARP requests/replies
*
@@ -358,7 +358,7 @@ int arping_main(int argc, char **argv)
if (!(cfg&dad) || src.s_addr) {
struct sockaddr_in saddr;
- int probe_fd = socket(AF_INET, SOCK_DGRAM, 0);
+ int probe_fd = socket(AF_INET, SOCK_DGRAM, 0); /* maybe use bb_xsocket? */
if (probe_fd < 0) {
bb_error_msg_and_die("socket");
diff --git a/networking/dnsd.c b/networking/dnsd.c
index a815860..9c51938 100644
--- a/networking/dnsd.c
+++ b/networking/dnsd.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* Mini DNS server implementation for busybox
*
@@ -204,8 +205,7 @@ listen_socket(char *iface_addr, int listen_port)
char msg[100];
int s;
int yes = 1;
- if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
- bb_perror_msg_and_die("socket() failed");
+ s = bb_xsocket(PF_INET, SOCK_DGRAM, 0);
#ifdef SO_REUSEADDR
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes)) < 0)
bb_perror_msg_and_die("setsockopt() failed");
diff --git a/networking/ether-wake.c b/networking/ether-wake.c
index 7d5f79b..b4fb0c2 100644
--- a/networking/ether-wake.c
+++ b/networking/ether-wake.c
@@ -1,10 +1,8 @@
+/* vi: set sw=4 ts=4: */
/*
* ether-wake.c - Send a magic packet to wake up sleeping machines.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* Author: Donald Becker, http://www.scyld.com/"; http://www.scyld.com/wakeonlan.html
* Busybox port: Christian Volkmann <haveaniceday@online.de>
@@ -95,10 +93,10 @@
*/
#ifdef PF_PACKET
# define whereto_t sockaddr_ll
-# define make_socket() socket(PF_PACKET, SOCK_RAW, 0)
+# define make_socket() bb_xsocket(PF_PACKET, SOCK_RAW, 0)
#else
# define whereto_t sockaddr
-# define make_socket() socket(AF_INET, SOCK_PACKET, SOCK_PACKET)
+# define make_socket() bb_xsocket(AF_INET, SOCK_PACKET, SOCK_PACKET)
#endif
#ifdef DEBUG
@@ -145,8 +143,6 @@ int etherwake_main(int argc, char *argv[])
/* create the raw socket */
s = make_socket();
- if (s < 0)
- bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
/* now that we have a raw socket we can drop root */
setuid(getuid());
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c
index 5442c22..26efdcb 100644
--- a/networking/fakeidentd.c
+++ b/networking/fakeidentd.c
@@ -6,20 +6,7 @@
* Original Author: Tomi Ollila <too@iki.fi>
* http://www.guru-group.fi/~too/sw/
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <unistd.h>
@@ -117,8 +104,7 @@ static void inetbind(void)
else
port = se->s_port;
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- bb_perror_msg_and_die("Cannot create server socket");
+ s = bb_xsocket(AF_INET, SOCK_STREAM, 0);
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
diff --git a/networking/httpd.c b/networking/httpd.c
index c89073a..fde8ae4 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -6,19 +6,7 @@
*
* simplify patch stolen from libbb without using strdup
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*****************************************************************************
*
@@ -959,25 +947,21 @@ static int openServer(void)
memset(&lsocket, 0, sizeof(lsocket));
lsocket.sin_family = AF_INET;
lsocket.sin_addr.s_addr = INADDR_ANY;
- lsocket.sin_port = htons(config->port) ;
- fd = socket(AF_INET, SOCK_STREAM, 0);
- if (fd >= 0) {
- /* tell the OS it's OK to reuse a previous address even though */
- /* it may still be in a close down state. Allows bind to succeed. */
- int on = 1;
+ lsocket.sin_port = htons(config->port);
+ fd = bb_xsocket(AF_INET, SOCK_STREAM, 0);
+ /* tell the OS it's OK to reuse a previous address even though */
+ /* it may still be in a close down state. Allows bind to succeed. */
+ int on = 1;
#ifdef SO_REUSEPORT
- setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) ;
+ setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on)) ;
#else
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ;
+ setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) ;
#endif
- if (bind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)) == 0) {
- listen(fd, 9);
- signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */
- } else {
- bb_perror_msg_and_die("bind");
- }
+ if (bind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket)) == 0) {
+ listen(fd, 9);
+ signal(SIGCHLD, SIG_IGN); /* prevent zombie (defunct) processes */
} else {
- bb_perror_msg_and_die("create socket");
+ bb_perror_msg_and_die("bind");
}
return fd;
}
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index 1e1bd83..7b358c4 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/* ifconfig
*
* Similar to the standard Unix ifconfig, but with only the necessary
@@ -9,14 +10,7 @@
* Authors of the original ifconfig was:
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
*
- * This program is free software; you can redistribute it
- * and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * $Id: ifconfig.c,v 1.30 2004/03/31 11:30:08 andersen Exp $
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/*
@@ -335,9 +329,7 @@ int ifconfig_main(int argc, char **argv)
}
/* Create a channel to the NET kernel. */
- if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- bb_perror_msg_and_die("socket");
- }
+ sockfd = bb_xsocket(AF_INET, SOCK_DGRAM, 0);
/* get interface name */
safe_strncpy(ifr.ifr_name, *argv, IFNAMSIZ);
diff --git a/networking/nc.c b/networking/nc.c
index 85148c4..86f0b99 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -10,19 +10,7 @@
19990512 Uses Select. Charles P. Wright
19990513 Fixes stdin stupidity and uses buffers. Charles P. Wright
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
@@ -87,8 +75,7 @@ int nc_main(int argc, char **argv)
if ((do_listen && optind != argc) || (!do_listen && optind + 2 != argc))
bb_show_usage();
- if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- bb_perror_msg_and_die("socket");
+ sfd = bb_xsocket(AF_INET, SOCK_STREAM, 0);
x = 1;
if (setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &x, sizeof (x)) == -1)
bb_perror_msg_and_die("reuseaddr");
diff --git a/networking/route.c b/networking/route.c
index 8ae0da1..e7e8f1c 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/* route
*
* Similar to the standard Unix route, but with only the necessary
@@ -9,11 +10,7 @@
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* (derived from FvK's 'route.c 1.70 01/04/94')
*
- * This program is free software; you can redistribute it
- * and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at
- * your option) any later version.
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* $Id: route.c,v 1.26 2004/03/19 23:27:08 mjn3 Exp $
*
@@ -338,9 +335,7 @@ static void INET_setroute(int action, char **args)
}
/* Create a socket to the INET kernel. */
- if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- bb_perror_msg_and_die("socket");
- }
+ skfd = bb_xsocket(AF_INET, SOCK_DGRAM, 0);
if (ioctl(skfd, ((action==RTACTION_ADD) ? SIOCADDRT : SIOCDELRT), &rt)<0) {
bb_perror_msg_and_die("SIOC[ADD|DEL]RT");
@@ -434,9 +429,7 @@ static void INET6_setroute(int action, char **args)
}
/* Create a socket to the INET6 kernel. */
- if ((skfd = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
- bb_perror_msg_and_die("socket");
- }
+ skfd = bb_xsocket(AF_INET6, SOCK_DGRAM, 0);
rt.rtmsg_ifindex = 0;
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 8943b2e..3e4b42c 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -1,10 +1,9 @@
-/* $Id: telnetd.c,v 1.13 2004/09/14 17:24:58 bug1 Exp $
- *
+/* vi:set ts=4:*/
+/*
* Simple telnet server
* Bjorn Wesen, Axis Communications AB (bjornw@axis.com)
*
- * This file is distributed under the Gnu Public License (GPL),
- * please see the file LICENSE for further information.
+ * Licensed under GPL, see file LICENSE in this tarball for details.
*
* ---------------------------------------------------------------------------
* (C) Copyright 2000, Axis Communications AB, LUND, SWEDEN
@@ -446,10 +445,7 @@ telnetd_main(int argc, char **argv)
/* Grab a TCP socket. */
- master_fd = socket(SOCKET_TYPE, SOCK_STREAM, 0);
- if (master_fd < 0) {
- bb_perror_msg_and_die("socket");
- }
+ master_fd = bb_xsocket(SOCKET_TYPE, SOCK_STREAM, 0);
(void)setsockopt(master_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
/* Set it to listen to specified port. */
diff --git a/networking/tftp.c b/networking/tftp.c
index ddcb522..b830f18 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -1,35 +1,23 @@
-/* ------------------------------------------------------------------------- */
-/* tftp.c */
-/* */
-/* A simple tftp client for busybox. */
-/* Tries to follow RFC1350. */
-/* Only "octet" mode supported. */
-/* Optional blocksize negotiation (RFC2347 + RFC2348) */
-/* */
-/* Copyright (C) 2001 Magnus Damm <damm@opensource.se> */
-/* */
-/* Parts of the code based on: */
-/* */
-/* atftp: Copyright (C) 2000 Jean-Pierre Lefebvre <helix@step.polymtl.ca> */
-/* and Remi Lefebvre <remi@debian.org> */
-/* */
-/* utftp: Copyright (C) 1999 Uwe Ohse <uwe@ohse.de> */
-/* */
-/* This program is free software; you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation; either version 2 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* This program is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
-/* General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with this program; if not, write to the Free Software */
-/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-/* */
-/* ------------------------------------------------------------------------- */
+/* vi: set sw=4 ts=4: */
+/* -------------------------------------------------------------------------
+ * tftp.c
+ *
+ * A simple tftp client for busybox.
+ * Tries to follow RFC1350.
+ * Only "octet" mode supported.
+ * Optional blocksize negotiation (RFC2347 + RFC2348)
+ *
+ * Copyright (C) 2001 Magnus Damm <damm@opensource.se>
+ *
+ * Parts of the code based on:
+ *
+ * atftp: Copyright (C) 2000 Jean-Pierre Lefebvre <helix@step.polymtl.ca>
+ * and Remi Lefebvre <remi@debian.org>
+ *
+ * utftp: Copyright (C) 1999 Uwe Ohse <uwe@ohse.de>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ * ------------------------------------------------------------------------- */
#include <stdio.h>
#include <stdlib.h>
@@ -177,7 +165,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
tftp_bufsize += 4;
- if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
+ if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) { /* bb_xsocket? */
bb_perror_msg("socket");
return EXIT_FAILURE;
}
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 22d27f2..0abd904 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
* Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000
* The Regents of the University of California. All rights reserved.
@@ -359,9 +360,7 @@ ifaddrlist(struct IFADDRLIST **ipaddrp)
struct ifreq ibuf[(32 * 1024) / sizeof(struct ifreq)], ifr;
struct IFADDRLIST *st_ifaddrlist;
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (fd < 0)
- bb_perror_msg_and_die("socket");
+ fd = bb_xsocket(AF_INET, SOCK_DGRAM, 0);
ifc.ifc_len = sizeof(ibuf);
ifc.ifc_buf = (caddr_t)ibuf;
@@ -1091,8 +1090,7 @@ traceroute_main(int argc, char *argv[])
if (n > 2)
close(n);
- if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0)
- bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
+ s = bb_xsocket(AF_INET, SOCK_RAW, pe->p_proto);
#ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG
if (op & USAGE_OP_DEBUG)
@@ -1103,9 +1101,7 @@ traceroute_main(int argc, char *argv[])
(void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on,
sizeof(on));
- sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
- if (sndsock < 0)
- bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
+ sndsock = bb_xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW);
#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
#if defined(IP_OPTIONS)
diff --git a/networking/vconfig.c b/networking/vconfig.c
index 36458f7..72729c7 100644
--- a/networking/vconfig.c
+++ b/networking/vconfig.c
@@ -4,20 +4,7 @@
*
* Copyright (C) 2001 Manuel Novoa III <mjn3@codepoet.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 N/A */
@@ -136,9 +123,7 @@ int vconfig_main(int argc, char **argv)
}
/* Don't bother closing the filedes. It will be closed on cleanup. */
- if (open(conf_file_name, O_RDONLY) < 0) { /* Is 802.1q is present? */
- bb_perror_msg_and_die("open %s", conf_file_name);
- }
+ bb_xopen(conf_file_name, O_RDONLY); /* Will die if 802.1q is not present */
memset(&ifr, 0, sizeof(struct vlan_ioctl_args));
@@ -173,10 +158,9 @@ int vconfig_main(int argc, char **argv)
}
}
- if (((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
- || (ioctl(fd, SIOCSIFVLAN, &ifr) < 0)
- ) {
- bb_perror_msg_and_die("socket or ioctl error for %s", *argv);
+ fd = bb_xsocket(AF_INET, SOCK_STREAM, 0);
+ if (ioctl(fd, SIOCSIFVLAN, &ifr) < 0) {
+ bb_perror_msg_and_die("ioctl error for %s", *argv);
}
return 0;