Skip to content

Commit

Permalink
canceled unintended commit (XXX)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinmei committed Sep 3, 2004
1 parent 9ef0d09 commit fb5dd69
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 65 deletions.
6 changes: 4 additions & 2 deletions 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.
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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 *));
Expand Down
75 changes: 38 additions & 37 deletions 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.
Expand Down Expand Up @@ -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 */
Expand All @@ -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));
Expand All @@ -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 *));

Expand All @@ -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());
Expand Down Expand Up @@ -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");
Expand All @@ -205,7 +201,9 @@ main(argc, argv)
fclose(pidfp);
}

client6_startall();
client6_init();
ifinit_all();

client6_mainloop();
exit(0);
}
Expand All @@ -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)) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -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. */
}
}
Expand Down Expand 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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions 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.
Expand Down Expand Up @@ -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 *));
4 changes: 2 additions & 2 deletions 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.
Expand Down Expand Up @@ -530,7 +530,7 @@ remove_ia(ia)

free(ia);

(void)client6_start(ifp);
(void)client6_ifinit(ifp);
}

static struct dhcp6_timer *
Expand Down
12 changes: 6 additions & 6 deletions 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.
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -332,6 +331,7 @@ client6_init()
dprintf(LOG_ERR, FNAME, "interface %s not configured", device);
exit(1);
}
ifp->outsock = outsock;
}

int
Expand Down Expand Up @@ -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));
Expand Down
5 changes: 2 additions & 3 deletions 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.
Expand Down Expand Up @@ -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");
Expand Down
23 changes: 10 additions & 13 deletions 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.
Expand Down Expand Up @@ -51,40 +51,40 @@ extern int errno;

struct dhcp6_if *dhcp6_if;

struct dhcp6_if *
void
ifinit(ifname)
char *ifname;
{
struct dhcp6_if *ifp;

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));

TAILQ_INIT(&ifp->event_list);

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 */
Expand All @@ -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 *
Expand Down

0 comments on commit fb5dd69

Please sign in to comment.