Skip to content

Commit

Permalink
- Code clean up
Browse files Browse the repository at this point in the history
- compile on darwin
  • Loading branch information
t-momose committed Apr 10, 2006
1 parent 5ad10ea commit a362a4c
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 64 deletions.
10 changes: 5 additions & 5 deletions kame/kame/shisad/binding.c
@@ -1,4 +1,4 @@
/* $KAME: binding.c,v 1.26 2006/03/02 11:35:37 t-momose Exp $ */
/* $KAME: binding.c,v 1.27 2006/04/10 15:30:52 t-momose Exp $ */

/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
Expand Down Expand Up @@ -42,16 +42,16 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__APPLE__)
#include <net/if_var.h>
#endif
#include <net/mipsock.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include <netinet/ip6mh.h>
#include <netinet/in_var.h>
#include <netinet/in.h>
#include <arpa/inet.h>
//#include <netinet/in_var.h>
//#include <netinet/in.h>
//#include <arpa/inet.h>

#ifdef MIP_MN
#include <sys/sockio.h>
Expand Down
5 changes: 4 additions & 1 deletion kame/kame/shisad/callout.c
@@ -1,4 +1,4 @@
/* $KAME: callout.c,v 1.5 2006/01/26 08:47:21 t-momose Exp $ */
/* $KAME: callout.c,v 1.6 2006/04/10 15:30:52 t-momose Exp $ */

/*
* Copyright (C) 2004 WIDE Project.
Expand Down Expand Up @@ -45,6 +45,9 @@
#include "callout.h"

#define timermilisec(tvp) ((tvp)->tv_usec / 1000 + (tvp)->tv_sec * 1000)
#ifndef INFTIM
#define INFTIM (-1)
#endif

struct callout_queue_t_head callout_head;

Expand Down
4 changes: 2 additions & 2 deletions kame/kame/shisad/command.c
@@ -1,4 +1,4 @@
/* $KAME: command.c,v 1.4 2006/02/10 07:45:50 t-momose Exp $ */
/* $KAME: command.c,v 1.5 2006/04/10 15:30:52 t-momose Exp $ */

/*
* Copyright (C) 2004 WIDE Project.
Expand Down Expand Up @@ -129,7 +129,7 @@ new_connection(s)
{
int ss;
struct sockaddr_in6 sin6;
size_t sin6len;
socklen_t sin6len;

sin6len = sizeof(struct sockaddr_in6);
if ((ss = accept(s, (struct sockaddr *)&sin6, &sin6len)) < 0) {
Expand Down
30 changes: 1 addition & 29 deletions kame/kame/shisad/common.c
@@ -1,4 +1,4 @@
/* $KAME: common.c,v 1.27 2006/02/22 11:03:50 mitsuya Exp $ */
/* $KAME: common.c,v 1.28 2006/04/10 15:30:53 t-momose Exp $ */

/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
Expand Down Expand Up @@ -66,15 +66,6 @@

extern struct mip6_mipif_list mipifhead;

static const struct in6_addr haanyaddr_ifid64 = {
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe }}
};
static const struct in6_addr haanyaddr_ifidnn = {
{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe }}
};

#ifdef MIP_MN
//static struct sockaddr_dl *get_sockdl_from_ifindex(struct sockaddr_dl *, u_int16_t);
#endif
Expand Down Expand Up @@ -551,25 +542,6 @@ icmp6_input_common(fd)
}


#ifdef MIP_MN
int
mip6_icmp6_create_haanyaddr(haanyaddr, mpfx, mpfx_len)
struct in6_addr *haanyaddr;
struct in6_addr *mpfx;
int mpfx_len;
{
if (mpfx == NULL)
return (EINVAL);

if (mpfx_len == 64)
mip6_create_addr(haanyaddr, &haanyaddr_ifid64, mpfx, mpfx_len);
else
mip6_create_addr(haanyaddr, &haanyaddr_ifidnn, mpfx, mpfx_len);

return (0);
}
#endif /* MIP_HA */

void
mip6_create_addr(addr, ifid, prefix, prefixlen)
struct in6_addr *addr;
Expand Down
12 changes: 6 additions & 6 deletions kame/kame/shisad/hal.c
@@ -1,4 +1,4 @@
/* $KAME: hal.c,v 1.9 2006/03/02 11:11:10 t-momose Exp $ */
/* $KAME: hal.c,v 1.10 2006/04/10 15:30:53 t-momose Exp $ */

/*
* Copyright (C) 2005 WIDE Project. All rights reserved.
Expand Down Expand Up @@ -114,8 +114,8 @@ had_add_hal(hpfx_entry, gladdr, lladdr, lifetime, preference, flag)
struct mip6_hpfxl *hpfx_entry;
struct in6_addr *gladdr;
struct in6_addr *lladdr;
uint16_t lifetime;
uint16_t preference;
u_int16_t lifetime;
u_int16_t preference;
int flag;
{
struct home_agent_list *hal = NULL, *h;
Expand Down Expand Up @@ -382,9 +382,9 @@ receive_ra(ra, ralen, receivedifindex, in6_lladdr, in6_gladdr)
struct mip6_hpfx_list *hpfxhead = NULL;
struct nd_opt_hdr *pt;

uint16_t hai_preference = 0;
uint16_t hai_lifetime = 0;
uint8_t hai_pfxlen = 0;
u_int16_t hai_preference = 0;
u_int16_t hai_lifetime = 0;
u_int8_t hai_pfxlen = 0;

/* parse nd_options */
memset(&ndopts, 0, sizeof(ndopts));
Expand Down
36 changes: 18 additions & 18 deletions kame/kame/shisad/mh.c
@@ -1,4 +1,4 @@
/* $KAME: mh.c,v 1.49 2006/03/01 11:02:03 t-momose Exp $ */
/* $KAME: mh.c,v 1.50 2006/04/10 15:30:53 t-momose Exp $ */
/*
* Copyright (C) 2004 WIDE Project. All rights reserved.
*
Expand Down Expand Up @@ -974,8 +974,8 @@ send_brr(src, dst)
brr.ip6mhbr_hdr.ip6mh_proto = IPPROTO_NONE;
brr.ip6mhbr_hdr.ip6mh_len = (sizeof(brr) >> 3) - 1;
brr.ip6mhbr_hdr.ip6mh_type = IP6_MH_TYPE_BRR;
brr.ip6mhbr_hdr.ip6mh_cksum = checksum_p((uint16_t *)src, (uint16_t *)dst,
(uint16_t *)&brr, sizeof(brr), IPPROTO_MH);
brr.ip6mhbr_hdr.ip6mh_cksum = checksum_p((u_int16_t *)src, (u_int16_t *)dst,
(u_int16_t *)&brr, sizeof(brr), IPPROTO_MH);

error = sendmessage((char *)&brr, sizeof(brr), 0, src, dst, NULL, NULL);
return (error);
Expand Down Expand Up @@ -1009,8 +1009,8 @@ send_hoti(bul)
sizeof(hoti.ip6mhhti_cookie));

hoti.ip6mhhti_hdr.ip6mh_cksum =
checksum_p((uint16_t *)&bul->bul_hoainfo->hinfo_hoa,
(uint16_t *)&bul->bul_peeraddr, (uint16_t *)&hoti,
checksum_p((u_int16_t *)&bul->bul_hoainfo->hinfo_hoa,
(u_int16_t *)&bul->bul_peeraddr, (u_int16_t *)&hoti,
sizeof(hoti), IPPROTO_MH);

err = sendmessage((char *)&hoti, sizeof(hoti), 0,
Expand Down Expand Up @@ -1046,8 +1046,8 @@ send_coti(bul)
sizeof(coti.ip6mhcti_cookie));

coti.ip6mhcti_hdr.ip6mh_cksum =
checksum_p((uint16_t *)&bul->bul_coa,
(uint16_t *)&bul->bul_peeraddr, (uint16_t *)&coti,
checksum_p((u_int16_t *)&bul->bul_coa,
(u_int16_t *)&bul->bul_peeraddr, (u_int16_t *)&coti,
sizeof(coti), IPPROTO_MH);

err = sendmessage((char *)&coti, sizeof(coti),
Expand Down Expand Up @@ -1094,8 +1094,8 @@ send_hot(hoti, dst, src)
create_keygentoken(dst, nonce, (u_int8_t *)hot.ip6mhht_keygen, 0);

hot.ip6mhht_hdr.ip6mh_cksum =
checksum_p((uint16_t *)src,
(uint16_t *)dst, (uint16_t *)&hot,
checksum_p((u_int16_t *)src,
(u_int16_t *)dst, (u_int16_t *)&hot,
sizeof(hot), IPPROTO_MH);

err = sendmessage((char *)&hot, sizeof(hot), 0, src, dst, NULL, NULL);
Expand Down Expand Up @@ -1138,8 +1138,8 @@ send_cot(coti, dst, src)

/*cot.ip6mhct_hdr.ip6mh_cksum = 0a*/
cot.ip6mhct_hdr.ip6mh_cksum =
checksum_p((uint16_t *)src,
(uint16_t *)dst, (uint16_t *)&cot,
checksum_p((u_int16_t *)src,
(u_int16_t *)dst, (u_int16_t *)&cot,
sizeof(cot), IPPROTO_MH);

err = sendmessage((char *)&cot, sizeof(cot), 0, src, dst, NULL, NULL);
Expand Down Expand Up @@ -1453,9 +1453,9 @@ send_bu(bul)
bup->ip6mhbu_hdr.ip6mh_len = (buflen >> 3) - 1;
bup->ip6mhbu_hdr.ip6mh_cksum = 0;
bup->ip6mhbu_hdr.ip6mh_cksum =
checksum_p((uint16_t *)&bul->bul_hoainfo->hinfo_hoa,
(uint16_t *)&bul->bul_peeraddr,
(uint16_t *)bufp, buflen, IPPROTO_MH);
checksum_p((u_int16_t *)&bul->bul_hoainfo->hinfo_hoa,
(u_int16_t *)&bul->bul_peeraddr,
(u_int16_t *)bufp, buflen, IPPROTO_MH);
if (bul->bul_hoainfo->hinfo_location == MNINFO_MN_HOME)
error = sendmessage((char *)bufp, buflen, bul->bul_home_ifindex,
&bul->bul_hoainfo->hinfo_hoa, &bul->bul_peeraddr,
Expand Down Expand Up @@ -1667,8 +1667,8 @@ send_ba(src, coa, acoa, hoa, flags, kbm_p, status, seqno, lifetime, refresh, bid
bap->ip6mhba_hdr.ip6mh_len = (buflen >> 3) - 1;
bap->ip6mhba_hdr.ip6mh_cksum = 0;
bap->ip6mhba_hdr.ip6mh_cksum =
checksum_p((uint16_t *)src, (uint16_t *)hoa,
(uint16_t *)bufp, buflen, IPPROTO_MH);
checksum_p((u_int16_t *)src, (u_int16_t *)hoa,
(u_int16_t *)bufp, buflen, IPPROTO_MH);

if (debug) {
syslog(LOG_INFO, "BA is sent");
Expand Down Expand Up @@ -1729,8 +1729,8 @@ send_be(dst, src, home, status)
0, sizeof(struct in6_addr));

be.ip6mhbe_hdr.ip6mh_cksum =
checksum_p((uint16_t *)src, (uint16_t *)dst,
(uint16_t *)&be, (be.ip6mhbe_hdr.ip6mh_len + 1) << 3, IPPROTO_MH);
checksum_p((u_int16_t *)src, (u_int16_t *)dst,
(u_int16_t *)&be, (be.ip6mhbe_hdr.ip6mh_len + 1) << 3, IPPROTO_MH);

err = sendmessage((char *)&be, sizeof(be),
0, src, dst, NULL, NULL);
Expand Down
29 changes: 28 additions & 1 deletion kame/kame/shisad/mnd.c
@@ -1,4 +1,4 @@
/* $KAME: mnd.c,v 1.32 2006/02/22 11:03:51 mitsuya Exp $ */
/* $KAME: mnd.c,v 1.33 2006/04/10 15:30:53 t-momose Exp $ */

/*
* Copyright (C) 2004 WIDE Project.
Expand Down Expand Up @@ -102,6 +102,7 @@ static void show_current_config(int, char *);
static void mn_lists_init(void);
static int mipsock_recv_rr_hint(struct mip_msghdr *);
static void mnd_init_homeprefix(struct mip6_mipif *);
int mip6_icmp6_create_haanyaddr(struct in6_addr *, struct in6_addr *, int);
static struct mip6_mipif *mnd_add_mipif(char *);
static void terminate(int);
static int mipsock_md_dereg_bul_fl(struct in6_addr *, struct in6_addr *,
Expand Down Expand Up @@ -1138,6 +1139,32 @@ send_haadreq(hoainfo, hoa_plen, src)
return (errno);
}

int
mip6_icmp6_create_haanyaddr(haanyaddr, mpfx, mpfx_len)
struct in6_addr *haanyaddr;
struct in6_addr *mpfx;
int mpfx_len;
{
static const struct in6_addr haanyaddr_ifid64 = {
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe }}
};
static const struct in6_addr haanyaddr_ifidnn = {
{{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe }}
};

if (mpfx == NULL)
return (EINVAL);

if (mpfx_len == 64)
mip6_create_addr(haanyaddr, &haanyaddr_ifid64, mpfx, mpfx_len);
else
mip6_create_addr(haanyaddr, &haanyaddr_ifidnn, mpfx, mpfx_len);

return (0);
}

int
send_unsolicited_na(ifindex, target)
int ifindex;
Expand Down
3 changes: 1 addition & 2 deletions kame/kame/shisad/shisad.h
@@ -1,4 +1,4 @@
/* $KAME: shisad.h,v 1.35 2006/03/02 11:11:10 t-momose Exp $ */
/* $KAME: shisad.h,v 1.36 2006/04/10 15:30:54 t-momose Exp $ */

/*
* Copyright (C) 2004 WIDE Project.
Expand Down Expand Up @@ -420,7 +420,6 @@ void mhsock_close(void);
int mh_input_common(int);
int get_mobility_options(struct ip6_mh *, int, int,
struct mip6_mobility_options *);
int mip6_icmp6_create_haanyaddr(struct in6_addr *, struct in6_addr *, int);
int in6_mask2len(struct in6_addr *, u_char *);
int mh_input(struct in6_addr *, struct in6_addr *,
struct in6_addr *, struct in6_addr *, struct ip6_mh *, int);
Expand Down

0 comments on commit a362a4c

Please sign in to comment.