Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

canceled unintended commit (XXX)

  • Loading branch information...
commit fb5dd6900efbf9181b049ff7e5778af062178a38 1 parent 9ef0d09
jinmei authored
View
6 kame/kame/dhcp6/config.h
@@ -1,4 +1,4 @@
-/* $KAME: config.h,v 1.34 2004/09/03 10:52:35 jinmei Exp $ */
+/* $KAME: config.h,v 1.35 2004/09/03 11:02:15 jinmei Exp $ */
/*
* Copyright (C) 2002 WIDE Project.
@@ -37,6 +37,8 @@ TAILQ_HEAD(pifc_list, prefix_ifconf);
struct dhcp6_if {
struct dhcp6_if *next;
+ int outsock;
+
/* timer for the interface */
struct dhcp6_timer *timer;
@@ -259,7 +261,7 @@ extern struct dhcp6_list dnsnamelist;
extern struct dhcp6_list ntplist;
extern long long optlifetime;
-extern struct dhcp6_if *ifinit __P((char *));
+extern void ifinit __P((char *));
extern int configure_interface __P((struct cf_namelist *));
extern int configure_host __P((struct cf_namelist *));
extern int configure_keys __P((struct cf_namelist *));
View
75 kame/kame/dhcp6/dhcp6c.c
@@ -1,4 +1,4 @@
-/* $KAME: dhcp6c.c,v 1.142 2004/09/03 10:52:35 jinmei Exp $ */
+/* $KAME: dhcp6c.c,v 1.143 2004/09/03 11:02:15 jinmei Exp $ */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@@ -83,6 +83,8 @@ static u_long sig_flags = 0;
const dhcp6_mode_t dhcp6_mode = DHCP6_MODE_CLIENT;
+char *device = NULL;
+
int insock; /* inbound udp port */
int outsock; /* outbound udp port */
int rtsock; /* routing socket */
@@ -93,8 +95,7 @@ static char *pid_file = DHCP6C_PIDFILE;
static void usage __P((void));
static void client6_init __P((void));
-static int client6_ifinit __P((struct dhcp6_if *));
-static void client6_startall __P((void));
+static void ifinit_all __P((void));
static void free_resources __P((void));
static void client6_mainloop __P((void));
static void check_exit __P((void));
@@ -121,7 +122,7 @@ static int process_auth __P((struct authparam *, struct dhcp6 *dh6, ssize_t,
static int set_auth __P((struct dhcp6_event *, struct dhcp6_optinfo *));
struct dhcp6_timer *client6_timo __P((void *));
-int client6_start __P((struct dhcp6_if *));
+int client6_ifinit __P((struct dhcp6_if *));
extern int client6_script __P((char *, int, struct dhcp6_optinfo *));
@@ -135,7 +136,6 @@ main(argc, argv)
int ch, pid;
char *progname, *conffile = DHCP6C_CONF;
FILE *pidfp;
- struct dhcp6_if *ifp;
#ifndef HAVE_ARC4RANDOM
srandom(time(NULL) & getpid());
@@ -175,18 +175,14 @@ main(argc, argv)
usage();
exit(0);
}
+ device = argv[0];
if (foreground == 0)
openlog(progname, LOG_NDELAY|LOG_PID, LOG_DAEMON);
setloglevel(debug);
- client6_init();
- while (argc-- > 0) {
- ifp = ifinit(argv[0]);
- client6_ifinit(ifp);
- argv++;
- }
+ ifinit(device);
if ((cfparse(conffile)) != 0) {
dprintf(LOG_ERR, FNAME, "failed to parse configuration file");
@@ -205,7 +201,9 @@ main(argc, argv)
fclose(pidfp);
}
- client6_startall();
+ client6_init();
+ ifinit_all();
+
client6_mainloop();
exit(0);
}
@@ -226,6 +224,14 @@ client6_init()
struct addrinfo hints, *res;
static struct sockaddr_in6 sa6_allagent_storage;
int error, on = 1;
+ struct dhcp6_if *ifp;
+ int ifidx;
+
+ ifidx = if_nametoindex(device);
+ if (ifidx == 0) {
+ dprintf(LOG_ERR, FNAME, "if_nametoindex(%s)", device);
+ exit(1);
+ }
/* get our DUID */
if (get_duid(DUID_FILE, &client_duid)) {
@@ -297,6 +303,13 @@ client6_init()
strerror(errno));
exit(1);
}
+ if (setsockopt(outsock, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+ &ifidx, sizeof(ifidx)) < 0) {
+ dprintf(LOG_ERR, FNAME,
+ "setsockopt(outbound, IPV6_MULTICAST_IF): %s",
+ strerror(errno));
+ exit(1);
+ }
if (setsockopt(outsock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &on,
sizeof(on)) < 0) {
dprintf(LOG_ERR, FNAME,
@@ -368,6 +381,13 @@ client6_init()
sa6_allagent = (const struct sockaddr_in6 *)&sa6_allagent_storage;
freeaddrinfo(res);
+ /* client interface configuration */
+ if ((ifp = find_ifconfbyname(device)) == NULL) {
+ dprintf(LOG_ERR, FNAME, "interface %s not configured", device);
+ exit(1);
+ }
+ ifp->outsock = outsock;
+
if (signal(SIGHUP, client6_signal) == SIG_ERR) {
dprintf(LOG_WARNING, FNAME, "failed to set signal: %s",
strerror(errno));
@@ -380,27 +400,8 @@ client6_init()
}
}
-static int
-client6_ifinit(ifp)
- struct dhcp6_if *ifp;
-{
- int ifidx;
-
- ifidx = ifp->ifid;
-
- if (setsockopt(outsock, IPPROTO_IPV6, IPV6_MULTICAST_IF,
- &ifidx, sizeof(ifidx)) < 0) {
- dprintf(LOG_ERR, FNAME,
- "setsockopt(outbound, IPV6_MULTICAST_IF): %s",
- strerror(errno));
- return (-1);
- }
-
- return (0);
-}
-
int
-client6_start(ifp)
+client6_ifinit(ifp)
struct dhcp6_if *ifp;
{
struct dhcp6_event *ev;
@@ -436,12 +437,12 @@ client6_start(ifp)
}
static void
-client6_startall()
+ifinit_all()
{
struct dhcp6_if *ifp;
for (ifp = dhcp6_if; ifp; ifp = ifp->next) {
- if (client6_start(ifp))
+ if (client6_ifinit(ifp))
exit(1); /* initialization failure. we give up. */
}
}
@@ -507,7 +508,7 @@ process_signals()
if ((sig_flags & SIGF_HUP)) {
dprintf(LOG_INFO, FNAME, "restarting");
free_resources();
- client6_startall();
+ ifinit_all();
}
sig_flags = 0;
@@ -556,7 +557,7 @@ client6_expire_lifetime(arg)
dprintf(LOG_DEBUG, FNAME, "lifetime on %s expired", ifp->ifname);
dhcp6_remove_timer(&ifp->timer);
- client6_start(ifp);
+ client6_ifinit(ifp);
return (NULL);
}
@@ -1056,7 +1057,7 @@ client6_send(ev)
dst = *sa6_allagent;
dst.sin6_scope_id = ifp->linkid;
- if (sendto(outsock, buf, len, 0, (struct sockaddr *)&dst,
+ if (sendto(ifp->outsock, buf, len, 0, (struct sockaddr *)&dst,
((struct sockaddr *)&dst)->sa_len) == -1) {
dprintf(LOG_ERR, FNAME,
"transmit failed: %s", strerror(errno));
View
4 kame/kame/dhcp6/dhcp6c.h
@@ -1,4 +1,4 @@
-/* $KAME: dhcp6c.h,v 1.4 2004/09/03 10:52:35 jinmei Exp $ */
+/* $KAME: dhcp6c.h,v 1.5 2004/09/03 11:02:15 jinmei Exp $ */
/*
* Copyright (C) 2003 WIDE Project.
@@ -33,5 +33,5 @@
#define DUID_FILE LOCALDBDIR "/dhcp6c_duid"
extern struct dhcp6_timer *client6_timo __P((void *));
-extern int client6_start __P((struct dhcp6_if *));
+extern int client6_ifinit __P((struct dhcp6_if *));
extern void client6_send __P((struct dhcp6_event *));
View
4 kame/kame/dhcp6/dhcp6c_ia.c
@@ -1,4 +1,4 @@
-/* $KAME: dhcp6c_ia.c,v 1.23 2004/09/03 10:52:35 jinmei Exp $ */
+/* $KAME: dhcp6c_ia.c,v 1.24 2004/09/03 11:02:15 jinmei Exp $ */
/*
* Copyright (C) 2003 WIDE Project.
@@ -530,7 +530,7 @@ remove_ia(ia)
free(ia);
- (void)client6_start(ifp);
+ (void)client6_ifinit(ifp);
}
static struct dhcp6_timer *
View
12 kame/kame/dhcp6/dhcp6lc.c
@@ -1,4 +1,4 @@
-/* $KAME: dhcp6lc.c,v 1.3 2004/09/03 10:52:35 jinmei Exp $ */
+/* $KAME: dhcp6lc.c,v 1.4 2004/09/03 11:02:15 jinmei Exp $ */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@@ -144,16 +144,15 @@ main(argc, argv)
exit(0);
}
if (script == NULL || strlen(script) == 0) {
- fprintf(stderr, "Just stateless DHCPv6 protocol messages "
- "are exchanged.\n");
+ printf("Just stateless DHCPv6 protocol messages"
+ "are exchanged.\n");
}
device = argv[0];
openlog(progname, LOG_NDELAY|LOG_PID, LOG_DAEMON);
setloglevel(debug);
- if (ifinit(device) == NULL)
- exit(1);
+ ifinit(device);
client6_init();
ifinit_all();
@@ -332,6 +331,7 @@ client6_init()
dprintf(LOG_ERR, FNAME, "interface %s not configured", device);
exit(1);
}
+ ifp->outsock = outsock;
}
int
@@ -512,7 +512,7 @@ client6_send(ev)
dst = *sa6_allagent;
dst.sin6_scope_id = ifp->linkid;
- if (sendto(outsock, buf, len, 0, (struct sockaddr *)&dst,
+ if (sendto(ifp->outsock, buf, len, 0, (struct sockaddr *)&dst,
((struct sockaddr *)&dst)->sa_len) == -1) {
dprintf(LOG_ERR, FNAME,
"transmit failed: %s", strerror(errno));
View
5 kame/kame/dhcp6/dhcp6s.c
@@ -1,4 +1,4 @@
-/* $KAME: dhcp6s.c,v 1.134 2004/09/03 10:52:35 jinmei Exp $ */
+/* $KAME: dhcp6s.c,v 1.135 2004/09/03 11:02:15 jinmei Exp $ */
/*
* Copyright (C) 1998 and 1999 WIDE Project.
* All rights reserved.
@@ -278,8 +278,7 @@ main(argc, argv)
setloglevel(debug);
- if (ifinit(device) == NULL)
- exit(1);
+ ifinit(device);
if ((cfparse(conffile)) != 0) {
dprintf(LOG_ERR, FNAME, "failed to parse configuration file");
View
23 kame/kame/dhcp6/if.c
@@ -1,4 +1,4 @@
-/* $KAME: if.c,v 1.3 2004/09/03 10:52:36 jinmei Exp $ */
+/* $KAME: if.c,v 1.4 2004/09/03 11:02:15 jinmei Exp $ */
/*
* Copyright (C) 2002 WIDE Project.
@@ -51,7 +51,7 @@ extern int errno;
struct dhcp6_if *dhcp6_if;
-struct dhcp6_if *
+void
ifinit(ifname)
char *ifname;
{
@@ -59,12 +59,12 @@ ifinit(ifname)
if ((ifp = find_ifconfbyname(ifname)) != NULL) {
dprintf(LOG_NOTICE, FNAME, "duplicated interface: %s", ifname);
- return (NULL);
+ return;
}
if ((ifp = malloc(sizeof(*ifp))) == NULL) {
dprintf(LOG_ERR, FNAME, "malloc failed");
- goto fail;
+ goto die;
}
memset(ifp, 0, sizeof(*ifp));
@@ -72,19 +72,19 @@ ifinit(ifname)
if ((ifp->ifname = strdup(ifname)) == NULL) {
dprintf(LOG_ERR, FNAME, "failed to copy ifname");
- goto fail;
+ goto die;
}
if ((ifp->ifid = if_nametoindex(ifname)) == 0) {
dprintf(LOG_ERR, FNAME, "invalid interface(%s): %s",
ifname, strerror(errno));
- goto fail;
+ goto die;
}
#ifdef HAVE_SCOPELIB
if (inet_zoneid(AF_INET6, 2, ifname, &ifp->linkid)) {
dprintf(LOG_ERR, FNAME, "failed to get link ID for %s",
ifname);
- goto fail;
+ goto die;
}
#else
ifp->linkid = ifp->ifid; /* XXX */
@@ -99,13 +99,10 @@ ifinit(ifname)
ifp->next = dhcp6_if;
dhcp6_if = ifp;
- return (ifp);
+ return;
- fail:
- if (ifp->ifname != NULL)
- free(ifp->ifname);
- free(ifp);
- return (NULL);
+ die:
+ exit(1);
}
struct dhcp6_if *
Please sign in to comment.
Something went wrong with that request. Please try again.