[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [BusyBox] Support routines for ping6
From: Bart Visscher <magick () Linux-Fan ! com>
Date: 2002-04-28 8:53:44
[Download RAW message or body]
Changelog:
* Add support routines for ping6:
- xgethostbyname2
- create_icmp6_socket
Remark:
Maybe the code should move to ping6.c, it isn't yet used elsewhere.
["02-libbb-ping.patch" (text/x-patch)]
diff -ru -X exclude -P busybox-new-1/include/libbb.h busybox-new-0/include/libbb.h
--- busybox-new-1/include/libbb.h Wed Apr 24 22:27:17 2002
+++ busybox-new-0/include/libbb.h Thu Apr 25 20:30:26 2002
@@ -221,7 +221,9 @@
extern FILE *gz_open(FILE *compressed_file, int *pid);
extern struct hostent *xgethostbyname(const char *name);
+extern struct hostent *xgethostbyname2(const char *name, int af);
extern int create_icmp_socket(void);
+extern int create_icmp6_socket(void);
char *dirname (char *path);
diff -ru -X exclude -P busybox-new-1/libbb/Makefile.in \
busybox-new-0/libbb/Makefile.in
--- busybox-new-1/libbb/Makefile.in Wed Apr 24 22:27:17 2002
+++ busybox-new-0/libbb/Makefile.in Thu Apr 25 20:30:26 2002
@@ -38,7 +38,8 @@
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
dirname.c make_directory.c create_icmp_socket.c u_signal_names.c arith.c \
- simplify_path.c inet_common.c inode_hash.c
+ simplify_path.c inet_common.c inode_hash.c xgethostbyname2.c \
+ create_icmp6_socket.c
LIBBB_OBJS=$(patsubst %.c,$(LIBBB_DIR)%.o, $(LIBBB_SRC))
LIBBB_MSRC:=$(LIBBB_DIR)messages.c
diff -ru -X exclude -P busybox-new-1/libbb/create_icmp6_socket.c \
busybox-new-0/libbb/create_icmp6_socket.c
--- busybox-new-1/libbb/create_icmp6_socket.c Thu Jan 1 01:00:00 1970
+++ busybox-new-0/libbb/create_icmp6_socket.c Thu Apr 25 20:32:07 2002
@@ -0,0 +1,37 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routines.
+ *
+ * create raw socket for icmp (IPv6 version) protocol test permision
+ * and drop root privilegies if running setuid
+ *
+ */
+
+#include <sys/types.h>
+#include <netdb.h>
+#include <sys/socket.h>
+#include <errno.h>
+#include <unistd.h>
+#include "libbb.h"
+
+int create_icmp6_socket(void)
+{
+ struct protoent *proto;
+ int sock;
+
+ proto = getprotobyname("ipv6-icmp");
+ /* if getprotobyname failed, just silently force
+ * proto->p_proto to have the correct value for "ipv6-icmp" */
+ if ((sock = socket(AF_INET6, SOCK_RAW,
+ (proto ? proto->p_proto : IPPROTO_ICMPV6))) < 0) {
+ if (errno == EPERM)
+ error_msg_and_die("permission denied. (are you root?)");
+ else
+ perror_msg_and_die(can_not_create_raw_socket);
+ }
+
+ /* drop root privs if running setuid */
+ setuid(getuid());
+
+ return sock;
+}
diff -ru -X exclude -P busybox-new-1/libbb/xgethostbyname2.c \
busybox-new-0/libbb/xgethostbyname2.c
--- busybox-new-1/libbb/xgethostbyname2.c Thu Jan 1 01:00:00 1970
+++ busybox-new-0/libbb/xgethostbyname2.c Thu Apr 25 20:32:35 2002
@@ -0,0 +1,35 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Mini xgethostbyname2 implementation.
+ *
+ * Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>.
+ *
+ * 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
+ *
+ */
+
+#include <netdb.h>
+#include "libbb.h"
+
+
+struct hostent *xgethostbyname2(const char *name, int af)
+{
+ struct hostent *retval;
+
+ if ((retval = gethostbyname2(name, af)) == NULL)
+ herror_msg_and_die("%s", name);
+
+ return retval;
+}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic