Permalink
Browse files

added IPv4 mobile network prefix support code. (not tested)

the code is never used unless MIP_IPV4MNPSUPPORT is set.
  • Loading branch information...
1 parent c3e2ff2 commit b836be9e9548307e943c7d8796648cd182fe888a keiichi committed Sep 30, 2005
@@ -31,7 +31,9 @@ SRCS= had.c callout.c common.c mh.c \
binding.c fdlist.c command.c network.c nemo_var.c util.c hal.c
SRCS+= config.c cfparse.y cftoken.l
CFLAGS+= -g -Wall -Werror -DTEST -DMIP_HA
-#CFLAGS+= -g -Wall -Werror -DTEST -DMIP_HA -DMIP_NEMO -DMIP_MCOA
+#CFLAGS+= -DMIP_NEMO
+#CFLAGS+= -DMIP_MCOA
+#CFLAGS+= -DMIP_IPV4MNPSUPPORT
CFLAGS+= -I${.OBJDIR} -I${SRCDIR}
LDADD+= -L${.OBJDIR}/../../../lib/libinet6 \
@@ -29,8 +29,9 @@ SRCDIR= ${.CURDIR}/../../../kame/shisad
PROG= mrd
SRCS= mnd.c rr.c callout.c mh.c fsm.c binding.c network.c common.c fdlist.c command.c nemo_var.c util.c hal.c
SRCS+= config.c cfparse.y cftoken.l
-#CFLAGS+= -g -Wall -Werror -DMIP_MN -DMIP_NEMO -DMIP_MCOA
CFLAGS+= -g -Wall -Werror -DMIP_MN -DMIP_NEMO
+#CFLAGS+= -DMIP_MCOA
+#CFLAGS+= -DMIP_IPV4MNPSUPPORT
CFLAGS+= -I${.OBJDIR} -I${SRCDIR}
LDADD+= -L${.OBJDIR}/../../../lib/libinet6 \
@@ -29,8 +29,9 @@ SRCDIR= ${.CURDIR}/../../../kame/shisad
PROG= nemonetd
SRCS= nemo_netconfig.c network.c util.c
SRCS+= config.c cfparse.y cftoken.l
-#CFLAGS+= -g -Wall -Werror -DMIP_NEMO -DMIP_MCOA
CFLAGS+= -g -Wall -Werror -DMIP_NEMO
+#CFLAGS+= -DMIP_MCOA
+#CFLAGS+= -DMIP_IPV4MNPSUPPORT
CFLAGS+= -I${.OBJDIR} -I${SRCDIR}
#LDADD+= -L${.OBJDIR}/../../../lib/libinet6 \
@@ -1,4 +1,4 @@
-/* $Id: babymdd.c,v 1.11 2005/06/21 12:53:12 keiichi Exp $ */
+/* $Id: babymdd.c,v 1.12 2005/09/30 12:01:55 keiichi Exp $ */
/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
@@ -436,7 +436,7 @@ baby_md_reg(coa, bid)
hoa.sin6_len = sizeof(struct sockaddr_in6);
/* do not send md_info msg for an address generated at a home link */
- if (mip6_are_prefix_equal(&hoa.sin6_addr, &coa->sin6_addr, 64))
+ if (inet_are_prefix_equal(&hoa.sin6_addr, &coa->sin6_addr, 64))
return (0);
len = sizeof(*mdinfo) + sizeof(hoa) + sizeof(*coa);
@@ -500,7 +500,7 @@ baby_mipmsg(mipm, msglen)
hoainfo_next = LIST_NEXT(hoainfo, hoainfo_entry);
if (miphome->mipmhh_prefix &&
- mip6_are_prefix_equal(
+ inet_are_prefix_equal(
&((struct sockaddr_in6 *)miphome->mipmhh_prefix)->sin6_addr,
&storage2sin6(&hoainfo->hoa)->sin6_addr,
miphome->mipmhh_prefixlen)) {
@@ -604,7 +604,7 @@ baby_rtmsg(rtm, msglen)
hoainfo_next = LIST_NEXT(hoainfo, hoainfo_entry);
if ((ifinfo == babyinfo.coaif) &&
- (mip6_are_prefix_equal(&storage2sin6(&hoainfo->hoa)->sin6_addr,
+ (inet_are_prefix_equal(&storage2sin6(&hoainfo->hoa)->sin6_addr,
&sin6->sin6_addr, 64))) {
memset(&ifinfo->coa, 0,
View
@@ -1,4 +1,4 @@
-/* $KAME: cfparse.y,v 1.6 2005/08/24 03:12:53 keiichi Exp $ */
+/* $KAME: cfparse.y,v 1.7 2005/09/30 12:01:55 keiichi Exp $ */
%{
/*
@@ -35,6 +35,7 @@
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -64,6 +65,7 @@ static void free_cfe(struct config_entry *);
%token HOMEREGISTRATIONLIFETIME
%token PREFERENCE
%token KEYMANAGEMENT
+%token IPV4MNPSUPPORT
%token PREFIXTABLE EXPLICIT IMPLICIT
%token STATICTUNNEL
@@ -74,7 +76,7 @@ static void free_cfe(struct config_entry *);
}
%type <string> ADDRSTRING
-%type <string> MIPIFNAME IFNAME
+%type <string> IFNAME
%type <string> registration_mode EXPLICIT IMPLICIT
%type <number> INTEGER
%type <cfe> statements statement
@@ -84,6 +86,7 @@ static void free_cfe(struct config_entry *);
%type <cfe> interface_statement
%type <cfe> preference_statement
%type <cfe> keymanagement_statement
+%type <cfe> ipv4mnpsupport_statement
%type <cfe> prefixtable_config
%type <cfe> prefixtable_statements prefixtable_statement
%type <cfe> statictunnel_config
@@ -126,6 +129,7 @@ statement:
| homeregistrationlifetime_statement
| preference_statement
| keymanagement_statement
+ | ipv4mnpsupport_statement
| prefixtable_config
| statictunnel_config
;
@@ -229,6 +233,20 @@ keymanagement_statement:
}
;
+ipv4mnpsupport_statement:
+ IPV4MNPSUPPORT INTEGER EOS
+ {
+ struct config_entry *cfe;
+
+ cfe = alloc_cfe(CFT_IPV4MNPSUPPORT);
+ if (cfe == NULL)
+ return (-1);
+ cfe->cfe_number = (($2 == 0) ? 0 : 1);
+
+ $$ = cfe;
+ }
+ ;
+
prefixtable_config:
PREFIXTABLE BCL prefixtable_statements ECL EOS
{
@@ -276,22 +294,30 @@ prefixtable_statement:
{
struct config_entry *cfe;
struct config_prefixtable *cfpt;
+ struct addrinfo hints, *res0;
cfpt = (struct config_prefixtable *)
malloc(sizeof(struct config_prefixtable));
if (cfpt == NULL)
return (-1);
if (inet_pton(AF_INET6, $1,
- &cfpt->cfpt_homeaddress) <= 0) {
+ &cfpt->cfpt_homeaddress) <= 0) {
free(cfpt);
- return (-1);
+ return(-1);
}
- if (inet_pton(AF_INET6, $2,
- &cfpt->cfpt_prefix) <= 0) {
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_flags = AI_NUMERICHOST;
+ if (getaddrinfo($2, NULL, &hints, &res0)) {
+ printf("invalid prefix %s\n", $1);
free(cfpt);
return (-1);
}
+ memcpy(&cfpt->cfpt_ss_prefix, res0->ai_addr,
+ res0->ai_addrlen);
+ freeaddrinfo(res0);
cfpt->cfpt_prefixlen = $4;
if (strcmp($5, "explicit") == 0)
cfpt->cfpt_mode = CFPT_EXPLICIT;
@@ -312,22 +338,30 @@ prefixtable_statement:
{
struct config_entry *cfe;
struct config_prefixtable *cfpt;
+ struct addrinfo hints, *res0;
cfpt = (struct config_prefixtable *)
malloc(sizeof(struct config_prefixtable));
if (cfpt == NULL)
return (-1);
if (inet_pton(AF_INET6, $1,
- &cfpt->cfpt_homeaddress) <= 0) {
+ &cfpt->cfpt_homeaddress) <= 0) {
free(cfpt);
- return (-1);
+ return(-1);
}
- if (inet_pton(AF_INET6, $2,
- &cfpt->cfpt_prefix) <= 0) {
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_flags = AI_NUMERICHOST;
+ if (getaddrinfo($2, NULL, &hints, &res0)) {
+ printf("invalid prefix %s\n", $1);
free(cfpt);
return (-1);
}
+ memcpy(&cfpt->cfpt_ss_prefix, res0->ai_addr,
+ res0->ai_addrlen);
+ freeaddrinfo(res0);
cfpt->cfpt_prefixlen = $4;
if (strcmp($5, "explicit") == 0)
cfpt->cfpt_mode = CFPT_EXPLICIT;
@@ -1,4 +1,4 @@
-/* $KAME: cftoken.l,v 1.6 2005/08/24 03:12:53 keiichi Exp $ */
+/* $KAME: cftoken.l,v 1.7 2005/09/30 12:01:55 keiichi Exp $ */
%{
/*
@@ -58,7 +58,7 @@ slash \/
comment \#.*
digit [0-9]
integer {digit}+
-addrstring [a-zA-Z0-9:\._][a-zA-Z0-9:\._]*
+addrstring [a-zA-Z0-9:\.][a-zA-Z0-9:\.]*
ifname [a-zA-Z]+[0-9]+
mipifname mip[0-9]+
@@ -82,6 +82,7 @@ mipifname mip[0-9]+
<S_CONFIG>preference { D; return (PREFERENCE); }
<S_CONFIG>interface { D; BEGIN S_INTERFACE; return (INTERFACE); }
<S_CONFIG>key-management { D; return (KEYMANAGEMENT); }
+<S_CONFIG>ipv4-mnp-support { D; return (IPV4MNPSUPPORT); }
<S_INTERFACE>{ifname} {
D;
BEGIN S_CONFIG;
@@ -1,4 +1,4 @@
-/* $KAME: config.h,v 1.5 2005/08/24 03:12:53 keiichi Exp $ */
+/* $KAME: config.h,v 1.6 2005/09/30 12:01:55 keiichi Exp $ */
/*
* Copyright (C) 2005 WIDE Project.
@@ -42,6 +42,7 @@ enum {
CFT_INTERFACE,
CFT_PREFERENCE,
CFT_KEYMANAGEMENT,
+ CFT_IPV4MNPSUPPORT,
CFT_PREFIXTABLELIST, CFT_PREFIXTABLE,
CFT_STATICTUNNELLIST, CFT_STATICTUNNEL
};
@@ -61,7 +62,7 @@ struct config_entry {
struct config_prefixtable {
struct in6_addr cfpt_homeaddress;
- struct in6_addr cfpt_prefix;
+ struct sockaddr_storage cfpt_ss_prefix;
int cfpt_prefixlen;
int cfpt_mode;
int cfpt_binding_id;
View
@@ -1,4 +1,4 @@
-/* $KAME: had.c,v 1.26 2005/09/07 08:18:18 t-momose Exp $ */
+/* $KAME: had.c,v 1.27 2005/09/30 12:01:55 keiichi Exp $ */
/*
* Copyright (C) 2004 WIDE Project.
@@ -78,6 +78,9 @@ int namelookup = 1;
int command_port = HAD_COMMAND_PORT;
int preference = 0;
int keymanagement = 0;
+#ifdef MIP_IPV4MNPSUPPORT
+int ipv4mnpsupport = 0;
+#endif /* MIP_IPV4MNPSUPPORT */
struct mip6stat mip6stat;
struct mip6_hpfx_list hpfx_head;
@@ -315,7 +318,7 @@ had_is_myhomenet(hoa)
struct mip6_hpfxl *hpfx = NULL;
LIST_FOREACH(hpfx, &hpfx_head, hpfx_entry) {
- if (mip6_are_prefix_equal(&hpfx->hpfx_prefix, hoa, hpfx->hpfx_prefixlen))
+ if (inet_are_prefix_equal(&hpfx->hpfx_prefix, hoa, hpfx->hpfx_prefixlen))
return (hpfx);
}
View
@@ -1,4 +1,4 @@
-/* $KAME: hal.c,v 1.2 2005/08/23 08:24:53 t-momose Exp $ */
+/* $KAME: hal.c,v 1.3 2005/09/30 12:01:55 keiichi Exp $ */
/*
* Copyright (C) 2005 WIDE Project. All rights reserved.
@@ -71,7 +71,7 @@ mip6_find_hal(hoainfo)
return (NULL);
LIST_FOREACH(hpfx, &mipif->mipif_hprefx_head, hpfx_entry) {
- if (mip6_are_prefix_equal(&hoainfo->hinfo_hoa,
+ if (inet_are_prefix_equal(&hoainfo->hinfo_hoa,
&hpfx->hpfx_prefix, hpfx->hpfx_prefixlen)) {
return (LIST_FIRST(&hpfx->hpfx_hal_head));
}
@@ -301,7 +301,7 @@ mip6_get_hpfxlist(prefix, prefixlen, hpfxhead)
if (prefixlen != hpl->hpfx_prefixlen)
continue;
- if (mip6_are_prefix_equal(prefix, &hpl->hpfx_prefix, prefixlen))
+ if (inet_are_prefix_equal(prefix, &hpl->hpfx_prefix, prefixlen))
return (hpl);
}
return (NULL);
Oops, something went wrong.

0 comments on commit b836be9

Please sign in to comment.