Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
b9605676
Commit
b9605676
authored
Jun 27, 2014
by
Matthieu Boutier
Committed by
Juliusz Chroboczek
Jun 28, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix all indentation problems in babeld.
parent
6385f477
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
129 additions
and
129 deletions
+129
-129
babeld.c
babeld.c
+3
-3
configuration.c
configuration.c
+2
-2
interface.c
interface.c
+3
-3
kernel_netlink.c
kernel_netlink.c
+63
-63
kernel_socket.c
kernel_socket.c
+48
-48
message.c
message.c
+5
-5
neighbour.c
neighbour.c
+1
-1
route.c
route.c
+2
-2
util.c
util.c
+2
-2
No files found.
babeld.c
View file @
b9605676
...
...
@@ -1120,11 +1120,11 @@ reopen_logfile()
static
int
kernel_routes_callback
(
int
changed
,
void
*
closure
)
{
if
(
changed
&
CHANGE_LINK
)
if
(
changed
&
CHANGE_LINK
)
kernel_link_changed
=
1
;
if
(
changed
&
CHANGE_ADDR
)
if
(
changed
&
CHANGE_ADDR
)
kernel_addr_changed
=
1
;
if
(
changed
&
CHANGE_ROUTE
)
if
(
changed
&
CHANGE_ROUTE
)
kernel_routes_changed
=
1
;
return
1
;
}
configuration.c
View file @
b9605676
...
...
@@ -246,7 +246,7 @@ getid(int c, unsigned char **id_r, gnc_t gnc, void *closure)
static
int
getnet
(
int
c
,
unsigned
char
**
p_r
,
unsigned
char
*
plen_r
,
int
*
af_r
,
gnc_t
gnc
,
void
*
closure
)
gnc_t
gnc
,
void
*
closure
)
{
char
*
t
;
unsigned
char
*
ip
;
...
...
@@ -808,7 +808,7 @@ gnc_file(struct file_state *s)
int
c
;
c
=
fgetc
(
s
->
f
);
if
(
c
==
'\n'
)
s
->
line
++
;
s
->
line
++
;
return
c
;
}
...
...
interface.c
View file @
b9605676
...
...
@@ -164,7 +164,7 @@ check_interface_channel(struct interface *ifp)
if
(
channel
<
0
)
fprintf
(
stderr
,
"Couldn't determine channel of interface %s: %s.
\n
"
,
ifp
->
name
,
strerror
(
errno
));
ifp
->
name
,
strerror
(
errno
));
if
(
channel
<=
0
)
channel
=
IF_CHANNEL_INTERFERING
;
}
...
...
@@ -303,7 +303,7 @@ interface_up(struct interface *ifp, int up)
ifp
->
update_interval
=
IF_CONF
(
ifp
,
update_interval
)
>
0
?
IF_CONF
(
ifp
,
update_interval
)
:
ifp
->
hello_interval
*
4
;
ifp
->
hello_interval
*
4
;
ifp
->
rtt_decay
=
IF_CONF
(
ifp
,
rtt_decay
)
>
0
?
...
...
@@ -429,7 +429,7 @@ interface_ll_address(struct interface *ifp, const unsigned char *address)
for
(
i
=
0
;
i
<
ifp
->
numll
;
i
++
)
if
(
memcmp
(
ifp
->
ll
[
i
],
address
,
16
)
==
0
)
return
1
;
return
1
;
return
0
;
}
...
...
kernel_netlink.c
View file @
b9605676
...
...
@@ -42,7 +42,7 @@ THE SOFTWARE.
#include <linux/if_bridge.h>
#include <netinet/ether.h>
#if
(__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 5)
#if(__GLIBC__ < 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 5)
#define RTA_TABLE 15
#endif
...
...
@@ -327,8 +327,8 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer,
}
else
if
(
answer
&&
(
nh
->
nlmsg_pid
!=
nl
->
sockaddr
.
nl_pid
||
nh
->
nlmsg_seq
!=
nl
->
seqno
))
{
kdebugf
(
"(wrong seqno %d %d /pid %d %d), "
,
nh
->
nlmsg_seq
,
nl
->
seqno
,
nh
->
nlmsg_pid
,
nl
->
sockaddr
.
nl_pid
);
nh
->
nlmsg_seq
,
nl
->
seqno
,
nh
->
nlmsg_pid
,
nl
->
sockaddr
.
nl_pid
);
continue
;
}
else
if
(
nh
->
nlmsg_type
==
NLMSG_DONE
)
{
kdebugf
(
"(done)
\n
"
);
...
...
@@ -359,7 +359,7 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer,
if
(
msg
.
msg_flags
&
MSG_TRUNC
)
fprintf
(
stderr
,
"netlink_read: message truncated
\n
"
);
}
while
(
!
done
);
}
while
(
!
done
);
return
interesting
;
...
...
@@ -1082,7 +1082,7 @@ parse_kernel_route_rta(struct rtmsg *rtm, int len, struct kernel_route *route)
} while(0)
while
(
RTA_OK
(
rta
,
len
))
{
switch
(
rta
->
rta_type
)
{
switch
(
rta
->
rta_type
)
{
case
RTA_DST
:
COPY_ADDR
(
route
->
prefix
,
RTA_DATA
(
rta
));
break
;
...
...
@@ -1097,7 +1097,7 @@ parse_kernel_route_rta(struct rtmsg *rtm, int len, struct kernel_route *route)
if
(
route
->
metric
<
0
||
route
->
metric
>
KERNEL_INFINITY
)
route
->
metric
=
KERNEL_INFINITY
;
break
;
case
RTA_TABLE
:
case
RTA_TABLE
:
table
=
*
(
int
*
)
RTA_DATA
(
rta
);
break
;
default:
...
...
@@ -1204,7 +1204,7 @@ filter_kernel_routes(struct nlmsghdr *nh, void *data)
}
}
if
(
data
)
*
found
=
(
*
found
)
+
1
;
if
(
data
)
*
found
=
(
*
found
)
+
1
;
return
1
;
...
...
@@ -1261,7 +1261,7 @@ parse_ifname_rta(struct ifinfomsg *info, int len)
len
-=
NLMSG_ALIGN
(
sizeof
(
*
info
));
while
(
RTA_OK
(
rta
,
len
))
{
switch
(
rta
->
rta_type
)
{
switch
(
rta
->
rta_type
)
{
case
IFLA_IFNAME
:
ifname
=
RTA_DATA
(
rta
);
break
;
...
...
@@ -1280,27 +1280,27 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res)
len
-=
NLMSG_ALIGN
(
sizeof
(
*
addr
));
rta
=
IFA_RTA
(
addr
);
while
(
RTA_OK
(
rta
,
len
))
{
while
(
RTA_OK
(
rta
,
len
))
{
switch
(
rta
->
rta_type
)
{
case
IFA_LOCAL
:
case
IFA_ADDRESS
:
switch
(
addr
->
ifa_family
)
{
case
AF_INET
:
if
(
res
)
v4tov6
(
res
->
s6_addr
,
RTA_DATA
(
rta
));
break
;
case
AF_INET6
:
if
(
res
)
memcpy
(
res
->
s6_addr
,
RTA_DATA
(
rta
),
16
);
break
;
default:
kdebugf
(
"ifaddr: unexpected address family %d
\n
"
,
addr
->
ifa_family
);
return
-
1
;
break
;
}
case
IFA_LOCAL
:
case
IFA_ADDRESS
:
switch
(
addr
->
ifa_family
)
{
case
AF_INET
:
if
(
res
)
v4tov6
(
res
->
s6_addr
,
RTA_DATA
(
rta
));
break
;
case
AF_INET6
:
if
(
res
)
memcpy
(
res
->
s6_addr
,
RTA_DATA
(
rta
),
16
);
break
;
default:
kdebugf
(
"ifaddr: unexpected address family %d
\n
"
,
addr
->
ifa_family
);
return
-
1
;
break
;
}
break
;
default:
break
;
}
rta
=
RTA_NEXT
(
rta
,
len
);
}
...
...
@@ -1334,7 +1334,7 @@ filter_link(struct nlmsghdr *nh, void *data)
kdebugf
(
"filter_interfaces: link change on if %s(%d): 0x%x
\n
"
,
ifname
,
ifindex
,
(
unsigned
)
ifflags
);
FOR_ALL_INTERFACES
(
ifp
)
{
if
(
strcmp
(
ifp
->
name
,
ifname
)
==
0
)
if
(
strcmp
(
ifp
->
name
,
ifname
)
==
0
)
return
1
;
}
return
0
;
...
...
@@ -1354,7 +1354,7 @@ filter_addresses(struct nlmsghdr *nh, void *data)
int
ifindex
=
0
;
int
ll
=
0
;
if
(
data
)
{
if
(
data
)
{
void
**
args
=
(
void
**
)
data
;
maxroutes
=
*
(
int
*
)
args
[
0
];
routes
=
(
struct
kernel_route
*
)
args
[
1
];
...
...
@@ -1365,31 +1365,31 @@ filter_addresses(struct nlmsghdr *nh, void *data)
len
=
nh
->
nlmsg_len
;
if
(
data
&&
*
found
>=
maxroutes
)
if
(
data
&&
*
found
>=
maxroutes
)
return
0
;
if
(
nh
->
nlmsg_type
!=
RTM_NEWADDR
&&
(
data
||
nh
->
nlmsg_type
!=
RTM_DELADDR
))
if
(
nh
->
nlmsg_type
!=
RTM_NEWADDR
&&
(
data
||
nh
->
nlmsg_type
!=
RTM_DELADDR
))
return
0
;
ifa
=
(
struct
ifaddrmsg
*
)
NLMSG_DATA
(
nh
);
len
-=
NLMSG_LENGTH
(
0
);
rc
=
parse_addr_rta
(
ifa
,
len
,
&
addr
);
if
(
rc
<
0
)
if
(
rc
<
0
)
return
0
;
if
(
ll
==
!
IN6_IS_ADDR_LINKLOCAL
(
&
addr
))
if
(
ll
==
!
IN6_IS_ADDR_LINKLOCAL
(
&
addr
))
return
0
;
if
(
ifindex
&&
ifa
->
ifa_index
!=
ifindex
)
if
(
ifindex
&&
ifa
->
ifa_index
!=
ifindex
)
return
0
;
kdebugf
(
"found address on interface %s(%d): %s
\n
"
,
if_indextoname
(
ifa
->
ifa_index
,
ifname
),
ifa
->
ifa_index
,
format_address
(
addr
.
s6_addr
));
if
(
data
)
{
if
(
data
)
{
struct
kernel_route
*
route
=
&
routes
[
*
found
];
memcpy
(
route
->
prefix
,
addr
.
s6_addr
,
16
);
route
->
plen
=
128
;
...
...
@@ -1409,29 +1409,29 @@ filter_netlink(struct nlmsghdr *nh, void *data)
int
rc
;
int
*
changed
=
data
;
switch
(
nh
->
nlmsg_type
)
{
case
RTM_NEWROUTE
:
case
RTM_DELROUTE
:
rc
=
filter_kernel_routes
(
nh
,
NULL
);
if
(
changed
&&
rc
>
0
)
*
changed
|=
CHANGE_ROUTE
;
return
rc
;
case
RTM_NEWLINK
:
case
RTM_DELLINK
:
rc
=
filter_link
(
nh
,
NULL
);
if
(
changed
&&
rc
>
0
)
*
changed
|=
CHANGE_LINK
;
return
rc
;
case
RTM_NEWADDR
:
case
RTM_DELADDR
:
rc
=
filter_addresses
(
nh
,
NULL
);
if
(
changed
&&
rc
>
0
)
*
changed
|=
CHANGE_ADDR
;
return
rc
;
default:
kdebugf
(
"filter_netlink: unexpected message type %d
\n
"
,
nh
->
nlmsg_type
);
break
;
switch
(
nh
->
nlmsg_type
)
{
case
RTM_NEWROUTE
:
case
RTM_DELROUTE
:
rc
=
filter_kernel_routes
(
nh
,
NULL
);
if
(
changed
&&
rc
>
0
)
*
changed
|=
CHANGE_ROUTE
;
return
rc
;
case
RTM_NEWLINK
:
case
RTM_DELLINK
:
rc
=
filter_link
(
nh
,
NULL
);
if
(
changed
&&
rc
>
0
)
*
changed
|=
CHANGE_LINK
;
return
rc
;
case
RTM_NEWADDR
:
case
RTM_DELADDR
:
rc
=
filter_addresses
(
nh
,
NULL
);
if
(
changed
&&
rc
>
0
)
*
changed
|=
CHANGE_ADDR
;
return
rc
;
default:
kdebugf
(
"filter_netlink: unexpected message type %d
\n
"
,
nh
->
nlmsg_type
);
break
;
}
return
0
;
}
...
...
@@ -1446,15 +1446,15 @@ kernel_addresses(char *ifname, int ifindex, int ll,
struct
rtgenmsg
g
;
int
rc
;
if
(
!
nl_setup
)
{
if
(
!
nl_setup
)
{
fprintf
(
stderr
,
"kernel_addresses: netlink not initialized.
\n
"
);
errno
=
ENOSYS
;
return
-
1
;
}
if
(
nl_command
.
sock
<
0
)
{
if
(
nl_command
.
sock
<
0
)
{
rc
=
netlink_socket
(
&
nl_command
,
0
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
int
save
=
errno
;
perror
(
"kernel_addresses: netlink_socket()"
);
errno
=
save
;
...
...
@@ -1465,12 +1465,12 @@ kernel_addresses(char *ifname, int ifindex, int ll,
memset
(
&
g
,
0
,
sizeof
(
g
));
g
.
rtgen_family
=
AF_UNSPEC
;
rc
=
netlink_send_dump
(
RTM_GETADDR
,
&
g
,
sizeof
(
g
));
if
(
rc
<
0
)
if
(
rc
<
0
)
return
-
1
;
rc
=
netlink_read
(
&
nl_command
,
NULL
,
1
,
filter_addresses
,
(
void
*
)
data
);
if
(
rc
<
0
)
if
(
rc
<
0
)
return
-
1
;
return
found
;
...
...
@@ -1494,7 +1494,7 @@ kernel_callback(int (*fn)(int, void*), void *closure)
rc
=
netlink_read
(
&
nl_listen
,
&
nl_command
,
0
,
filter_netlink
,
&
changed
);
if
(
rc
<
0
&&
nl_listen
.
sock
<
0
)
kernel_setup_socket
(
1
);
kernel_setup_socket
(
1
);
/* if netlink return 0 (found something interesting) */
/* or -1 (i.e. IO error), we call... back ! */
...
...
kernel_socket.c
View file @
b9605676
...
...
@@ -64,14 +64,14 @@ if_eui64(char *ifname, int ifindex, unsigned char *eui)
{
struct
sockaddr_dl
sdl
;
char
*
tmp
=
NULL
;
if
(
get_sdl
(
&
sdl
,
ifname
)
<
0
)
{
if
(
get_sdl
(
&
sdl
,
ifname
)
<
0
)
{
return
-
1
;
}
tmp
=
sdl
.
sdl_data
+
sdl
.
sdl_nlen
;
if
(
sdl
.
sdl_alen
==
8
)
{
if
(
sdl
.
sdl_alen
==
8
)
{
memcpy
(
eui
,
tmp
,
8
);
eui
[
0
]
^=
2
;
}
else
if
(
sdl
.
sdl_alen
==
6
)
{
}
else
if
(
sdl
.
sdl_alen
==
6
)
{
memcpy
(
eui
,
tmp
,
3
);
eui
[
3
]
=
0xFF
;
eui
[
4
]
=
0xFE
;
...
...
@@ -116,18 +116,18 @@ get_sdl(struct sockaddr_dl *sdl, char *ifname)
goto
fail
;
offset
=
0
;
while
(
offset
<
(
int
)
buf_len
)
{
while
(
offset
<
(
int
)
buf_len
)
{
ifm
=
(
struct
if_msghdr
*
)
&
buffer
[
offset
];
switch
(
ifm
->
ifm_type
)
{
case
RTM_IFINFO
:
tmp_sdl
=
(
struct
sockaddr_dl
*
)
(
ifm
+
1
);
if
(
strncmp
(
ifname
,
tmp_sdl
->
sdl_data
,
tmp_sdl
->
sdl_nlen
)
==
0
&&
strlen
(
ifname
)
==
tmp_sdl
->
sdl_nlen
)
{
memcpy
(
sdl
,
tmp_sdl
,
sizeof
(
struct
sockaddr_dl
));
return
0
;
}
default:
break
;
switch
(
ifm
->
ifm_type
)
{
case
RTM_IFINFO
:
tmp_sdl
=
(
struct
sockaddr_dl
*
)
(
ifm
+
1
);
if
(
strncmp
(
ifname
,
tmp_sdl
->
sdl_data
,
tmp_sdl
->
sdl_nlen
)
==
0
&&
strlen
(
ifname
)
==
tmp_sdl
->
sdl_nlen
)
{
memcpy
(
sdl
,
tmp_sdl
,
sizeof
(
struct
sockaddr_dl
));
return
0
;
}
default:
break
;
}
offset
+=
ifm
->
ifm_msglen
;
}
...
...
@@ -143,7 +143,7 @@ fail:
do { \
(a).s6_addr[2] = ((i) >> 8) & 0xff; \
(a).s6_addr[3] = (i) & 0xff; \
} while
(0)
} while(0)
#if defined(__APPLE__)
#define ROUNDUP(a) \
...
...
@@ -171,7 +171,7 @@ mask2len(const unsigned char *p, const int size)
}
if
(
j
<
size
)
{
switch
(
*
p
)
{
#define MASKLEN(m, l) case m: do { i += l; break; } while
(0)
#define MASKLEN(m, l) case m: do { i += l; break; } while(0)
MASKLEN
(
0xfe
,
7
);
break
;
MASKLEN
(
0xfc
,
6
);
break
;
MASKLEN
(
0xf8
,
5
);
break
;
...
...
@@ -197,8 +197,8 @@ plen2mask(int n, struct in6_addr *dest)
memset
(
dest
,
0
,
sizeof
(
struct
in6_addr
));
p
=
(
u_char
*
)
dest
;
for
(
i
=
0
;
i
<
16
;
i
++
,
p
++
,
n
-=
8
)
{
if
(
n
>=
8
)
{
for
(
i
=
0
;
i
<
16
;
i
++
,
p
++
,
n
-=
8
)
{
if
(
n
>=
8
)
{
*
p
=
0xff
;
continue
;
}
...
...
@@ -224,13 +224,13 @@ kernel_setup(int setup)
mib
[
2
]
=
IPPROTO_IPV6
;
mib
[
3
]
=
IPV6CTL_FORWARDING
;
datasize
=
sizeof
(
old_forwarding
);
if
(
setup
)
if
(
setup
)
rc
=
sysctl
(
mib
,
4
,
&
old_forwarding
,
&
datasize
,
&
forwarding
,
datasize
);
else
if
(
old_forwarding
>=
0
)
else
if
(
old_forwarding
>=
0
)
rc
=
sysctl
(
mib
,
4
,
NULL
,
NULL
,
&
old_forwarding
,
datasize
);
if
(
rc
==
-
1
)
{
if
(
rc
==
-
1
)
{
perror
(
"Couldn't tweak forwarding knob."
);
return
-
1
;
}
...
...
@@ -243,13 +243,13 @@ kernel_setup(int setup)
mib
[
3
]
=
ICMPV6CTL_REDIRACCEPT
;
#endif
datasize
=
sizeof
(
old_accept_redirects
);
if
(
setup
)
if
(
setup
)
rc
=
sysctl
(
mib
,
4
,
&
old_accept_redirects
,
&
datasize
,
&
accept_redirects
,
datasize
);
else
if
(
old_accept_redirects
>=
0
)
else
if
(
old_accept_redirects
>=
0
)
rc
=
sysctl
(
mib
,
4
,
NULL
,
NULL
,
&
old_accept_redirects
,
datasize
);
if
(
rc
==
-
1
)
{
if
(
rc
==
-
1
)
{
perror
(
"Couldn't tweak accept_redirects knob."
);
return
-
1
;
}
...
...
@@ -267,9 +267,9 @@ kernel_setup_socket(int setup)
if
(
kernel_socket
<
0
)
return
-
1
;
}
rc
=
setsockopt
(
kernel_socket
,
SOL_SOCKET
,
SO_USELOOPBACK
,
rc
=
setsockopt
(
kernel_socket
,
SOL_SOCKET
,
SO_USELOOPBACK
,
&
zero
,
sizeof
(
zero
));
if
(
rc
<
0
)
if
(
rc
<
0
)
goto
error
;
return
1
;
}
else
{
...
...
@@ -370,9 +370,9 @@ kernel_interface_wireless(const char *ifname, int ifindex)
strncpy
(
ifmr
.
ifm_name
,
ifname
,
sizeof
(
ifmr
.
ifm_name
));
rc
=
ioctl
(
s
,
SIOCGIFMEDIA
,
(
caddr_t
)
&
ifmr
);
close
(
s
);
if
(
rc
<
0
)
if
(
rc
<
0
)
return
rc
;
if
((
ifmr
.
ifm_active
&
IFM_NMASK
)
==
IFM_IEEE80211
)
if
((
ifmr
.
ifm_active
&
IFM_NMASK
)
==
IFM_IEEE80211
)
return
1
;
else
return
0
;
...
...
@@ -392,8 +392,8 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
unsigned
int
newmetric
)
{
struct
{
struct
rt_msghdr
m_rtm
;
char
m_space
[
512
];
struct
rt_msghdr
m_rtm
;
char
m_space
[
512
];
}
msg
;
char
*
data
=
msg
.
m_space
;
int
rc
,
ipv4
;
...
...
@@ -418,9 +418,9 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
ipv4
=
0
;
}
if
(
operation
==
ROUTE_MODIFY
&&
newmetric
==
metric
&&
if
(
operation
==
ROUTE_MODIFY
&&
newmetric
==
metric
&&
memcmp
(
newgate
,
gate
,
16
)
==
0
&&
newifindex
==
ifindex
)
return
0
;
return
0
;
if
(
operation
==
ROUTE_MODIFY
)
{
...
...
@@ -479,7 +479,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
if(get_sdl(sdl, ifname) < 0) \
return -1; \
data = data + ROUNDUP(sdl->sdl_len); \
} while
(0)
} while(0)
#define PUSHADDR(src) \
do { struct sockaddr_in *sin = (struct sockaddr_in*) data; \
...
...
@@ -487,7 +487,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
sin->sin_family = AF_INET; \
memcpy(&sin->sin_addr, (src) + 12, 4); \
data = data + ROUNDUP(sin->sin_len); \
} while
(0)
} while(0)
#define PUSHADDR6(src) \
do { struct sockaddr_in6 *sin6 = (struct sockaddr_in6*) data; \
...
...
@@ -495,16 +495,16 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
sin6->sin6_family = AF_INET6; \
memcpy(&sin6->sin6_addr, (src), 16); \
if(IN6_IS_ADDR_LINKLOCAL (&sin6->sin6_addr)) \
SET_IN6_LINKLOCAL_IFINDEX (sin6->sin6_addr, ifindex); \
SET_IN6_LINKLOCAL_IFINDEX (sin6->sin6_addr, ifindex); \
data = data + ROUNDUP(sin6->sin6_len); \
} while
(0)
} while(0)
/* KAME ipv6 stack does not support IPv4 mapped IPv6, so we have to
* duplicate the codepath */
if
(
ipv4
)
{
PUSHADDR
(
dest
);
if
(
metric
==
KERNEL_INFINITY
)
{
if
(
metric
==
KERNEL_INFINITY
)
{
PUSHADDR
(
**
local4
);
}
else
if
(
plen
==
128
&&
memcmp
(
dest
+
12
,
gate
+
12
,
4
)
==
0
)
{
#if defined(RTF_CLONING)
...
...
@@ -524,7 +524,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
}
else
{
PUSHADDR6
(
dest
);
if
(
metric
==
KERNEL_INFINITY
)
{
if
(
metric
==
KERNEL_INFINITY
)
{
PUSHADDR6
(
**
local6
);
}
else
{
msg
.
m_rtm
.
rtm_flags
|=
RTF_GATEWAY
;
...
...
@@ -544,7 +544,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
msg
.
m_rtm
.
rtm_msglen
=
data
-
(
char
*
)
&
msg
;
rc
=
write
(
kernel_socket
,
(
char
*
)
&
msg
,
msg
.
m_rtm
.
rtm_msglen
);
if
(
rc
<
msg
.
m_rtm
.
rtm_msglen
)
if
(
rc
<
msg
.
m_rtm
.
rtm_msglen
)
return
-
1
;
return
1
;
...
...
@@ -556,7 +556,7 @@ print_kernel_route(int add, struct kernel_route *route)
char
ifname
[
IFNAMSIZ
];
if
(
!
if_indextoname
(
route
->
ifindex
,
ifname
))
memcpy
(
ifname
,
"unk"
,
4
);
memcpy
(
ifname
,
"unk"
,
4
);
fprintf
(
stderr
,
"%s kernel route: dest: %s gw: %s metric: %d if: %s(%d)
\n
"
,
...
...
@@ -605,11 +605,11 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
sa
=
(
struct
sockaddr
*
)
rta
;
rta
+=
ROUNDUP
(
sa
->
sa_len
);
if
(
sa
->
sa_family
==
AF_INET6
)
{
struct
sockaddr_in6
*
sin6
=
(
struct
sockaddr_in6
*
)
sa
;
struct
sockaddr_in6
*
sin6
=
(
struct
sockaddr_in6
*
)
sa
;
memcpy
(
route
->
prefix
,
&
sin6
->
sin6_addr
,
16
);
if
(
IN6_IS_ADDR_LINKLOCAL
(
&
sin6
->
sin6_addr
)
||
IN6_IS_ADDR_MC_LINKLOCAL
(
&
sin6
->
sin6_addr
))
return
-
1
;
||
IN6_IS_ADDR_MC_LINKLOCAL
(
&
sin6
->
sin6_addr
))
return
-
1
;
}
else
if
(
sa
->
sa_family
==
AF_INET
)
{
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
sa
;
#if defined(IN_LINKLOCAL)
...
...
@@ -629,7 +629,7 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
sa
=
(
struct
sockaddr
*
)
rta
;
rta
+=
ROUNDUP
(
sa
->
sa_len
);
if
(
sa
->
sa_family
==
AF_INET6
)
{
struct
sockaddr_in6
*
sin6
=
(
struct
sockaddr_in6
*
)
sa
;
struct
sockaddr_in6
*
sin6
=
(
struct
sockaddr_in6
*
)
sa
;
memcpy
(
route
->
gw
,
&
sin6
->
sin6_addr
,
16
);
if
(
IN6_IS_ADDR_LINKLOCAL
(
&
sin6
->
sin6_addr
))
{
route
->
ifindex
=
IN6_LINKLOCAL_IFINDEX
(
sin6
->
sin6_addr
);
...
...
@@ -677,7 +677,7 @@ kernel_routes(struct kernel_route *routes, int maxroutes)
mib
[
5
]
=
0
;
/* No flags */
rc
=
sysctl
(
mib
,
6
,
NULL
,
&
len
,
NULL
,
0
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
perror
(
"kernel_routes(len)"
);
return
-
1
;
}
...
...
@@ -689,7 +689,7 @@ kernel_routes(struct kernel_route *routes, int maxroutes)
}
rc
=
sysctl
(
mib
,
6
,
buf
,
&
len
,
NULL
,
0
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
perror
(
"kernel_routes(dump)"
);
goto
fail
;
}
...
...
@@ -721,7 +721,7 @@ kernel_routes(struct kernel_route *routes, int maxroutes)
}
static
int
socket_read
(
int
sock
)
socket_read
(
int
sock
)
{
int
rc
;
struct
{
...
...
@@ -741,7 +741,7 @@ socket_read(int sock)
}
if
(
buf
.
rtm
.
rtm_type
==
RTM_ADD
||
buf
.
rtm
.
rtm_type
==
RTM_DELETE
||
buf
.
rtm
.
rtm_type
==
RTM_DELETE
||
buf
.
rtm
.
rtm_type
==
RTM_CHANGE
)
{
struct
kernel_route
route
;
...
...
message.c
View file @
b9605676
...
...
@@ -89,7 +89,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
return
-
1
;
memcpy
(
prefix
,
v4prefix
,
12
);
if
(
omitted
)
{
if
(
dp
==
NULL
||
!
v4mapped
(
dp
))
return
-
1
;
if
(
dp
==
NULL
||
!
v4mapped
(
dp
))
return
-
1
;
memcpy
(
prefix
,
dp
,
12
+
omitted
);
}
if
(
pb
>
omitted
)
memcpy
(
prefix
+
12
+
omitted
,
p
,
pb
-
omitted
);
...
...
@@ -98,7 +98,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
case
2
:
if
(
omitted
>
16
||
(
pb
>
omitted
&&
len
<
pb
-
omitted
))
return
-
1
;
if
(
omitted
)
{
if
(
dp
==
NULL
||
v4mapped
(
dp
))
return
-
1
;
if
(
dp
==
NULL
||
v4mapped
(
dp
))
return
-
1
;
memcpy
(
prefix
,
dp
,
omitted
);
}
if
(
pb
>
omitted
)
memcpy
(
prefix
+
omitted
,
p
,
pb
-
omitted
);
...
...
@@ -620,7 +620,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
format_address
(
from
),
ifp
->
name
,
rtt
);
old_rttcost
=
neighbour_rttcost
(
neigh
);
if
(
valid_rtt
(
neigh
))
{
if
(
valid_rtt
(
neigh
))
{
/* Running exponential average. */
smoothed_rtt
=
(
ifp
->
rtt_decay
*
rtt
+
(
256
-
ifp
->
rtt_decay
)
*
neigh
->
rtt
);
...
...
@@ -1475,7 +1475,7 @@ send_ihu(struct neighbour *neigh, struct interface *ifp)
accumulate_bytes
(
ifp
,
neigh
->
address
+
8
,
8
);
else
accumulate_bytes
(
ifp
,
neigh
->
address
,
16
);
if
(
send_rtt_data
)
{
if
(
send_rtt_data
)
{
accumulate_byte
(
ifp
,
SUBTLV_TIMESTAMP
);
accumulate_byte
(
ifp
,
8
);
accumulate_int
(
ifp
,
neigh
->
hello_send_us
);
...
...
@@ -1494,7 +1494,7 @@ send_ihu(struct neighbour *neigh, struct interface *ifp)
accumulate_unicast_bytes
(
neigh
,
neigh
->
address
+
8
,
8
);
else
accumulate_unicast_bytes
(
neigh
,
neigh
->
address
,
16
);
if
(
send_rtt_data
)
{
if
(
send_rtt_data
)
{
accumulate_unicast_byte
(
neigh
,
SUBTLV_TIMESTAMP
);
accumulate_unicast_byte
(
neigh
,
8
);
accumulate_unicast_int
(
neigh
,
neigh
->
hello_send_us
);
...
...
neighbour.c
View file @
b9605676
...
...
@@ -128,7 +128,7 @@ update_neighbour(struct neighbour *neigh, int hello, int hello_interval)
if
(
missed_hellos
<=
0
)
return
rc
;
timeval_add_msec
(
&
neigh
->
hello_time
,
&
neigh
->
hello_time
,
missed_hellos
*
neigh
->
hello_interval
*
10
);
missed_hellos
*
neigh
->
hello_interval
*
10
);
}
else
{
if
(
neigh
->
hello_seqno
>=
0
&&
neigh
->
reach
>
0
)
{
missed_hellos
=
seqno_minus
(
hello
,
neigh
->
hello_seqno
)
-
1
;
...
...
route.c
View file @
b9605676
...
...
@@ -57,7 +57,7 @@ static int two_to_the_one_over_hl = 0; /* 2^(1/hl) * 0x10000 */
static
int
route_compare
(
const
unsigned
char
*
prefix
,
unsigned
char
plen
,
struct
babel_route
*
route
)
struct
babel_route
*
route
)
{
int
i
=
memcmp
(
prefix
,
route
->
src
->
prefix
,
16
);
if
(
i
!=
0
)
...
...
@@ -260,7 +260,7 @@ flush_all_routes()
i
=
route_slots
-
1
;
while
(
i
>=
0
)
{
while
(
i
<
route_slots
)
{
/* Uninstall first, to avoid calling route_lost. */
/* Uninstall first, to avoid calling route_lost. */
if
(
routes
[
i
]
->
installed
)
uninstall_route
(
routes
[
i
]);
flush_route
(
routes
[
i
]);
...
...
util.c
View file @
b9605676
...
...
@@ -258,9 +258,9 @@ format_address(const unsigned char *address)
static
int
i
=
0
;
i
=
(
i
+
1
)
%
4
;
if
(
v4mapped
(
address
))
inet_ntop
(
AF_INET
,
address
+
12
,
buf
[
i
],
INET6_ADDRSTRLEN
);
inet_ntop
(
AF_INET
,
address
+
12
,
buf
[
i
],
INET6_ADDRSTRLEN
);
else
inet_ntop
(
AF_INET6
,
address
,
buf
[
i
],
INET6_ADDRSTRLEN
);
inet_ntop
(
AF_INET6
,
address
,
buf
[
i
],
INET6_ADDRSTRLEN
);
return
buf
[
i
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment