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
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
124 additions
and
124 deletions
+124
-124
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
No files found.
babeld.c
View file @
b9605676
...
@@ -1120,11 +1120,11 @@ reopen_logfile()
...
@@ -1120,11 +1120,11 @@ reopen_logfile()
static
int
static
int
kernel_routes_callback
(
int
changed
,
void
*
closure
)
kernel_routes_callback
(
int
changed
,
void
*
closure
)
{
{
if
(
changed
&
CHANGE_LINK
)
if
(
changed
&
CHANGE_LINK
)
kernel_link_changed
=
1
;
kernel_link_changed
=
1
;
if
(
changed
&
CHANGE_ADDR
)
if
(
changed
&
CHANGE_ADDR
)
kernel_addr_changed
=
1
;
kernel_addr_changed
=
1
;
if
(
changed
&
CHANGE_ROUTE
)
if
(
changed
&
CHANGE_ROUTE
)
kernel_routes_changed
=
1
;
kernel_routes_changed
=
1
;
return
1
;
return
1
;
}
}
configuration.c
View file @
b9605676
interface.c
View file @
b9605676
kernel_netlink.c
View file @
b9605676
...
@@ -42,7 +42,7 @@ THE SOFTWARE.
...
@@ -42,7 +42,7 @@ THE SOFTWARE.
#include <linux/if_bridge.h>
#include <linux/if_bridge.h>
#include <netinet/ether.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
#define RTA_TABLE 15
#endif
#endif
...
@@ -359,7 +359,7 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer,
...
@@ -359,7 +359,7 @@ netlink_read(struct netlink *nl, struct netlink *nl_ignore, int answer,
if
(
msg
.
msg_flags
&
MSG_TRUNC
)
if
(
msg
.
msg_flags
&
MSG_TRUNC
)
fprintf
(
stderr
,
"netlink_read: message truncated
\n
"
);
fprintf
(
stderr
,
"netlink_read: message truncated
\n
"
);
}
while
(
!
done
);
}
while
(
!
done
);
return
interesting
;
return
interesting
;
...
@@ -1082,7 +1082,7 @@ parse_kernel_route_rta(struct rtmsg *rtm, int len, struct kernel_route *route)
...
@@ -1082,7 +1082,7 @@ parse_kernel_route_rta(struct rtmsg *rtm, int len, struct kernel_route *route)
} while(0)
} while(0)
while
(
RTA_OK
(
rta
,
len
))
{
while
(
RTA_OK
(
rta
,
len
))
{
switch
(
rta
->
rta_type
)
{
switch
(
rta
->
rta_type
)
{
case
RTA_DST
:
case
RTA_DST
:
COPY_ADDR
(
route
->
prefix
,
RTA_DATA
(
rta
));
COPY_ADDR
(
route
->
prefix
,
RTA_DATA
(
rta
));
break
;
break
;
...
@@ -1204,7 +1204,7 @@ filter_kernel_routes(struct nlmsghdr *nh, void *data)
...
@@ -1204,7 +1204,7 @@ filter_kernel_routes(struct nlmsghdr *nh, void *data)
}
}
}
}
if
(
data
)
*
found
=
(
*
found
)
+
1
;
if
(
data
)
*
found
=
(
*
found
)
+
1
;
return
1
;
return
1
;
...
@@ -1261,7 +1261,7 @@ parse_ifname_rta(struct ifinfomsg *info, int len)
...
@@ -1261,7 +1261,7 @@ parse_ifname_rta(struct ifinfomsg *info, int len)
len
-=
NLMSG_ALIGN
(
sizeof
(
*
info
));
len
-=
NLMSG_ALIGN
(
sizeof
(
*
info
));
while
(
RTA_OK
(
rta
,
len
))
{
while
(
RTA_OK
(
rta
,
len
))
{
switch
(
rta
->
rta_type
)
{
switch
(
rta
->
rta_type
)
{
case
IFLA_IFNAME
:
case
IFLA_IFNAME
:
ifname
=
RTA_DATA
(
rta
);
ifname
=
RTA_DATA
(
rta
);
break
;
break
;
...
@@ -1280,17 +1280,17 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res)
...
@@ -1280,17 +1280,17 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res)
len
-=
NLMSG_ALIGN
(
sizeof
(
*
addr
));
len
-=
NLMSG_ALIGN
(
sizeof
(
*
addr
));
rta
=
IFA_RTA
(
addr
);
rta
=
IFA_RTA
(
addr
);
while
(
RTA_OK
(
rta
,
len
))
{
while
(
RTA_OK
(
rta
,
len
))
{
switch
(
rta
->
rta_type
)
{
switch
(
rta
->
rta_type
)
{
case
IFA_LOCAL
:
case
IFA_LOCAL
:
case
IFA_ADDRESS
:
case
IFA_ADDRESS
:
switch
(
addr
->
ifa_family
)
{
switch
(
addr
->
ifa_family
)
{
case
AF_INET
:
case
AF_INET
:
if
(
res
)
if
(
res
)
v4tov6
(
res
->
s6_addr
,
RTA_DATA
(
rta
));
v4tov6
(
res
->
s6_addr
,
RTA_DATA
(
rta
));
break
;
break
;
case
AF_INET6
:
case
AF_INET6
:
if
(
res
)
if
(
res
)
memcpy
(
res
->
s6_addr
,
RTA_DATA
(
rta
),
16
);
memcpy
(
res
->
s6_addr
,
RTA_DATA
(
rta
),
16
);
break
;
break
;
default:
default:
...
@@ -1334,7 +1334,7 @@ filter_link(struct nlmsghdr *nh, void *data)
...
@@ -1334,7 +1334,7 @@ filter_link(struct nlmsghdr *nh, void *data)
kdebugf
(
"filter_interfaces: link change on if %s(%d): 0x%x
\n
"
,
kdebugf
(
"filter_interfaces: link change on if %s(%d): 0x%x
\n
"
,
ifname
,
ifindex
,
(
unsigned
)
ifflags
);
ifname
,
ifindex
,
(
unsigned
)
ifflags
);
FOR_ALL_INTERFACES
(
ifp
)
{
FOR_ALL_INTERFACES
(
ifp
)
{
if
(
strcmp
(
ifp
->
name
,
ifname
)
==
0
)
if
(
strcmp
(
ifp
->
name
,
ifname
)
==
0
)
return
1
;
return
1
;
}
}
return
0
;
return
0
;
...
@@ -1354,7 +1354,7 @@ filter_addresses(struct nlmsghdr *nh, void *data)
...
@@ -1354,7 +1354,7 @@ filter_addresses(struct nlmsghdr *nh, void *data)
int
ifindex
=
0
;
int
ifindex
=
0
;
int
ll
=
0
;
int
ll
=
0
;
if
(
data
)
{
if
(
data
)
{
void
**
args
=
(
void
**
)
data
;
void
**
args
=
(
void
**
)
data
;
maxroutes
=
*
(
int
*
)
args
[
0
];
maxroutes
=
*
(
int
*
)
args
[
0
];
routes
=
(
struct
kernel_route
*
)
args
[
1
];
routes
=
(
struct
kernel_route
*
)
args
[
1
];
...
@@ -1365,10 +1365,10 @@ filter_addresses(struct nlmsghdr *nh, void *data)
...
@@ -1365,10 +1365,10 @@ filter_addresses(struct nlmsghdr *nh, void *data)
len
=
nh
->
nlmsg_len
;
len
=
nh
->
nlmsg_len
;
if
(
data
&&
*
found
>=
maxroutes
)
if
(
data
&&
*
found
>=
maxroutes
)
return
0
;
return
0
;
if
(
nh
->
nlmsg_type
!=
RTM_NEWADDR
&&
if
(
nh
->
nlmsg_type
!=
RTM_NEWADDR
&&
(
data
||
nh
->
nlmsg_type
!=
RTM_DELADDR
))
(
data
||
nh
->
nlmsg_type
!=
RTM_DELADDR
))
return
0
;
return
0
;
...
@@ -1376,20 +1376,20 @@ filter_addresses(struct nlmsghdr *nh, void *data)
...
@@ -1376,20 +1376,20 @@ filter_addresses(struct nlmsghdr *nh, void *data)
len
-=
NLMSG_LENGTH
(
0
);
len
-=
NLMSG_LENGTH
(
0
);
rc
=
parse_addr_rta
(
ifa
,
len
,
&
addr
);
rc
=
parse_addr_rta
(
ifa
,
len
,
&
addr
);
if
(
rc
<
0
)
if
(
rc
<
0
)
return
0
;
return
0
;
if
(
ll
==
!
IN6_IS_ADDR_LINKLOCAL
(
&
addr
))
if
(
ll
==
!
IN6_IS_ADDR_LINKLOCAL
(
&
addr
))
return
0
;
return
0
;
if
(
ifindex
&&
ifa
->
ifa_index
!=
ifindex
)
if
(
ifindex
&&
ifa
->
ifa_index
!=
ifindex
)
return
0
;
return
0
;
kdebugf
(
"found address on interface %s(%d): %s
\n
"
,
kdebugf
(
"found address on interface %s(%d): %s
\n
"
,
if_indextoname
(
ifa
->
ifa_index
,
ifname
),
ifa
->
ifa_index
,
if_indextoname
(
ifa
->
ifa_index
,
ifname
),
ifa
->
ifa_index
,
format_address
(
addr
.
s6_addr
));
format_address
(
addr
.
s6_addr
));
if
(
data
)
{
if
(
data
)
{
struct
kernel_route
*
route
=
&
routes
[
*
found
];
struct
kernel_route
*
route
=
&
routes
[
*
found
];
memcpy
(
route
->
prefix
,
addr
.
s6_addr
,
16
);
memcpy
(
route
->
prefix
,
addr
.
s6_addr
,
16
);
route
->
plen
=
128
;
route
->
plen
=
128
;
...
@@ -1409,23 +1409,23 @@ filter_netlink(struct nlmsghdr *nh, void *data)
...
@@ -1409,23 +1409,23 @@ filter_netlink(struct nlmsghdr *nh, void *data)
int
rc
;
int
rc
;
int
*
changed
=
data
;
int
*
changed
=
data
;
switch
(
nh
->
nlmsg_type
)
{
switch
(
nh
->
nlmsg_type
)
{
case
RTM_NEWROUTE
:
case
RTM_NEWROUTE
:
case
RTM_DELROUTE
:
case
RTM_DELROUTE
:
rc
=
filter_kernel_routes
(
nh
,
NULL
);
rc
=
filter_kernel_routes
(
nh
,
NULL
);
if
(
changed
&&
rc
>
0
)
if
(
changed
&&
rc
>
0
)
*
changed
|=
CHANGE_ROUTE
;
*
changed
|=
CHANGE_ROUTE
;
return
rc
;
return
rc
;
case
RTM_NEWLINK
:
case
RTM_NEWLINK
:
case
RTM_DELLINK
:
case
RTM_DELLINK
:
rc
=
filter_link
(
nh
,
NULL
);
rc
=
filter_link
(
nh
,
NULL
);
if
(
changed
&&
rc
>
0
)
if
(
changed
&&
rc
>
0
)
*
changed
|=
CHANGE_LINK
;
*
changed
|=
CHANGE_LINK
;
return
rc
;
return
rc
;
case
RTM_NEWADDR
:
case
RTM_NEWADDR
:
case
RTM_DELADDR
:
case
RTM_DELADDR
:
rc
=
filter_addresses
(
nh
,
NULL
);
rc
=
filter_addresses
(
nh
,
NULL
);
if
(
changed
&&
rc
>
0
)
if
(
changed
&&
rc
>
0
)
*
changed
|=
CHANGE_ADDR
;
*
changed
|=
CHANGE_ADDR
;
return
rc
;
return
rc
;
default:
default:
...
@@ -1446,15 +1446,15 @@ kernel_addresses(char *ifname, int ifindex, int ll,
...
@@ -1446,15 +1446,15 @@ kernel_addresses(char *ifname, int ifindex, int ll,
struct
rtgenmsg
g
;
struct
rtgenmsg
g
;
int
rc
;
int
rc
;
if
(
!
nl_setup
)
{
if
(
!
nl_setup
)
{
fprintf
(
stderr
,
"kernel_addresses: netlink not initialized.
\n
"
);
fprintf
(
stderr
,
"kernel_addresses: netlink not initialized.
\n
"
);
errno
=
ENOSYS
;
errno
=
ENOSYS
;
return
-
1
;
return
-
1
;
}
}
if
(
nl_command
.
sock
<
0
)
{
if
(
nl_command
.
sock
<
0
)
{
rc
=
netlink_socket
(
&
nl_command
,
0
);
rc
=
netlink_socket
(
&
nl_command
,
0
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
int
save
=
errno
;
int
save
=
errno
;
perror
(
"kernel_addresses: netlink_socket()"
);
perror
(
"kernel_addresses: netlink_socket()"
);
errno
=
save
;
errno
=
save
;
...
@@ -1465,12 +1465,12 @@ kernel_addresses(char *ifname, int ifindex, int ll,
...
@@ -1465,12 +1465,12 @@ kernel_addresses(char *ifname, int ifindex, int ll,
memset
(
&
g
,
0
,
sizeof
(
g
));
memset
(
&
g
,
0
,
sizeof
(
g
));
g
.
rtgen_family
=
AF_UNSPEC
;
g
.
rtgen_family
=
AF_UNSPEC
;
rc
=
netlink_send_dump
(
RTM_GETADDR
,
&
g
,
sizeof
(
g
));
rc
=
netlink_send_dump
(
RTM_GETADDR
,
&
g
,
sizeof
(
g
));
if
(
rc
<
0
)
if
(
rc
<
0
)
return
-
1
;
return
-
1
;
rc
=
netlink_read
(
&
nl_command
,
NULL
,
1
,
filter_addresses
,
(
void
*
)
data
);
rc
=
netlink_read
(
&
nl_command
,
NULL
,
1
,
filter_addresses
,
(
void
*
)
data
);
if
(
rc
<
0
)
if
(
rc
<
0
)
return
-
1
;
return
-
1
;
return
found
;
return
found
;
...
...
kernel_socket.c
View file @
b9605676
...
@@ -64,14 +64,14 @@ if_eui64(char *ifname, int ifindex, unsigned char *eui)
...
@@ -64,14 +64,14 @@ if_eui64(char *ifname, int ifindex, unsigned char *eui)
{
{
struct
sockaddr_dl
sdl
;
struct
sockaddr_dl
sdl
;
char
*
tmp
=
NULL
;
char
*
tmp
=
NULL
;
if
(
get_sdl
(
&
sdl
,
ifname
)
<
0
)
{
if
(
get_sdl
(
&
sdl
,
ifname
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
tmp
=
sdl
.
sdl_data
+
sdl
.
sdl_nlen
;
tmp
=
sdl
.
sdl_data
+
sdl
.
sdl_nlen
;
if
(
sdl
.
sdl_alen
==
8
)
{
if
(
sdl
.
sdl_alen
==
8
)
{
memcpy
(
eui
,
tmp
,
8
);
memcpy
(
eui
,
tmp
,
8
);
eui
[
0
]
^=
2
;
eui
[
0
]
^=
2
;
}
else
if
(
sdl
.
sdl_alen
==
6
)
{
}
else
if
(
sdl
.
sdl_alen
==
6
)
{
memcpy
(
eui
,
tmp
,
3
);
memcpy
(
eui
,
tmp
,
3
);
eui
[
3
]
=
0xFF
;
eui
[
3
]
=
0xFF
;
eui
[
4
]
=
0xFE
;
eui
[
4
]
=
0xFE
;
...
@@ -116,12 +116,12 @@ get_sdl(struct sockaddr_dl *sdl, char *ifname)
...
@@ -116,12 +116,12 @@ get_sdl(struct sockaddr_dl *sdl, char *ifname)
goto
fail
;
goto
fail
;
offset
=
0
;
offset
=
0
;
while
(
offset
<
(
int
)
buf_len
)
{
while
(
offset
<
(
int
)
buf_len
)
{
ifm
=
(
struct
if_msghdr
*
)
&
buffer
[
offset
];
ifm
=
(
struct
if_msghdr
*
)
&
buffer
[
offset
];
switch
(
ifm
->
ifm_type
)
{
switch
(
ifm
->
ifm_type
)
{
case
RTM_IFINFO
:
case
RTM_IFINFO
:
tmp_sdl
=
(
struct
sockaddr_dl
*
)
(
ifm
+
1
);
tmp_sdl
=
(
struct
sockaddr_dl
*
)
(
ifm
+
1
);
if
(
strncmp
(
ifname
,
tmp_sdl
->
sdl_data
,
tmp_sdl
->
sdl_nlen
)
==
0
if
(
strncmp
(
ifname
,
tmp_sdl
->
sdl_data
,
tmp_sdl
->
sdl_nlen
)
==
0
&&
strlen
(
ifname
)
==
tmp_sdl
->
sdl_nlen
)
{
&&
strlen
(
ifname
)
==
tmp_sdl
->
sdl_nlen
)
{
memcpy
(
sdl
,
tmp_sdl
,
sizeof
(
struct
sockaddr_dl
));
memcpy
(
sdl
,
tmp_sdl
,
sizeof
(
struct
sockaddr_dl
));
return
0
;
return
0
;
...
@@ -143,7 +143,7 @@ fail:
...
@@ -143,7 +143,7 @@ fail:
do { \
do { \
(a).s6_addr[2] = ((i) >> 8) & 0xff; \
(a).s6_addr[2] = ((i) >> 8) & 0xff; \
(a).s6_addr[3] = (i) & 0xff; \
(a).s6_addr[3] = (i) & 0xff; \
} while
(0)
} while(0)
#if defined(__APPLE__)
#if defined(__APPLE__)
#define ROUNDUP(a) \
#define ROUNDUP(a) \
...
@@ -171,7 +171,7 @@ mask2len(const unsigned char *p, const int size)
...
@@ -171,7 +171,7 @@ mask2len(const unsigned char *p, const int size)
}
}
if
(
j
<
size
)
{
if
(
j
<
size
)
{
switch
(
*
p
)
{
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
(
0xfe
,
7
);
break
;
MASKLEN
(
0xfc
,
6
);
break
;
MASKLEN
(
0xfc
,
6
);
break
;
MASKLEN
(
0xf8
,
5
);
break
;
MASKLEN
(
0xf8
,
5
);
break
;
...
@@ -197,8 +197,8 @@ plen2mask(int n, struct in6_addr *dest)
...
@@ -197,8 +197,8 @@ plen2mask(int n, struct in6_addr *dest)
memset
(
dest
,
0
,
sizeof
(
struct
in6_addr
));
memset
(
dest
,
0
,
sizeof
(
struct
in6_addr
));
p
=
(
u_char
*
)
dest
;
p
=
(
u_char
*
)
dest
;
for
(
i
=
0
;
i
<
16
;
i
++
,
p
++
,
n
-=
8
)
{
for
(
i
=
0
;
i
<
16
;
i
++
,
p
++
,
n
-=
8
)
{
if
(
n
>=
8
)
{
if
(
n
>=
8
)
{
*
p
=
0xff
;
*
p
=
0xff
;
continue
;
continue
;
}
}
...
@@ -224,13 +224,13 @@ kernel_setup(int setup)
...
@@ -224,13 +224,13 @@ kernel_setup(int setup)
mib
[
2
]
=
IPPROTO_IPV6
;
mib
[
2
]
=
IPPROTO_IPV6
;
mib
[
3
]
=
IPV6CTL_FORWARDING
;
mib
[
3
]
=
IPV6CTL_FORWARDING
;
datasize
=
sizeof
(
old_forwarding
);
datasize
=
sizeof
(
old_forwarding
);
if
(
setup
)
if
(
setup
)
rc
=
sysctl
(
mib
,
4
,
&
old_forwarding
,
&
datasize
,
rc
=
sysctl
(
mib
,
4
,
&
old_forwarding
,
&
datasize
,
&
forwarding
,
datasize
);
&
forwarding
,
datasize
);
else
if
(
old_forwarding
>=
0
)
else
if
(
old_forwarding
>=
0
)
rc
=
sysctl
(
mib
,
4
,
NULL
,
NULL
,
rc
=
sysctl
(
mib
,
4
,
NULL
,
NULL
,
&
old_forwarding
,
datasize
);
&
old_forwarding
,
datasize
);
if
(
rc
==
-
1
)
{
if
(
rc
==
-
1
)
{
perror
(
"Couldn't tweak forwarding knob."
);
perror
(
"Couldn't tweak forwarding knob."
);
return
-
1
;
return
-
1
;
}
}
...
@@ -243,13 +243,13 @@ kernel_setup(int setup)
...
@@ -243,13 +243,13 @@ kernel_setup(int setup)
mib
[
3
]
=
ICMPV6CTL_REDIRACCEPT
;
mib
[
3
]
=
ICMPV6CTL_REDIRACCEPT
;
#endif
#endif
datasize
=
sizeof
(
old_accept_redirects
);
datasize
=
sizeof
(
old_accept_redirects
);
if
(
setup
)
if
(
setup
)
rc
=
sysctl
(
mib
,
4
,
&
old_accept_redirects
,
&
datasize
,
rc
=
sysctl
(
mib
,
4
,
&
old_accept_redirects
,
&
datasize
,
&
accept_redirects
,
datasize
);
&
accept_redirects
,
datasize
);
else
if
(
old_accept_redirects
>=
0
)
else
if
(
old_accept_redirects
>=
0
)
rc
=
sysctl
(
mib
,
4
,
NULL
,
NULL
,
rc
=
sysctl
(
mib
,
4
,
NULL
,
NULL
,
&
old_accept_redirects
,
datasize
);
&
old_accept_redirects
,
datasize
);
if
(
rc
==
-
1
)
{
if
(
rc
==
-
1
)
{
perror
(
"Couldn't tweak accept_redirects knob."
);
perror
(
"Couldn't tweak accept_redirects knob."
);
return
-
1
;
return
-
1
;
}
}
...
@@ -370,9 +370,9 @@ kernel_interface_wireless(const char *ifname, int ifindex)
...
@@ -370,9 +370,9 @@ kernel_interface_wireless(const char *ifname, int ifindex)
strncpy
(
ifmr
.
ifm_name
,
ifname
,
sizeof
(
ifmr
.
ifm_name
));
strncpy
(
ifmr
.
ifm_name
,
ifname
,
sizeof
(
ifmr
.
ifm_name
));
rc
=
ioctl
(
s
,
SIOCGIFMEDIA
,
(
caddr_t
)
&
ifmr
);
rc
=
ioctl
(
s
,
SIOCGIFMEDIA
,
(
caddr_t
)
&
ifmr
);
close
(
s
);
close
(
s
);
if
(
rc
<
0
)
if
(
rc
<
0
)
return
rc
;
return
rc
;
if
((
ifmr
.
ifm_active
&
IFM_NMASK
)
==
IFM_IEEE80211
)
if
((
ifmr
.
ifm_active
&
IFM_NMASK
)
==
IFM_IEEE80211
)
return
1
;
return
1
;
else
else
return
0
;
return
0
;
...
@@ -479,7 +479,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
...
@@ -479,7 +479,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
if(get_sdl(sdl, ifname) < 0) \
if(get_sdl(sdl, ifname) < 0) \
return -1; \
return -1; \
data = data + ROUNDUP(sdl->sdl_len); \
data = data + ROUNDUP(sdl->sdl_len); \
} while
(0)
} while(0)
#define PUSHADDR(src) \
#define PUSHADDR(src) \
do { struct sockaddr_in *sin = (struct sockaddr_in*) data; \
do { struct sockaddr_in *sin = (struct sockaddr_in*) data; \
...
@@ -487,7 +487,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
...
@@ -487,7 +487,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
sin->sin_family = AF_INET; \
sin->sin_family = AF_INET; \
memcpy(&sin->sin_addr, (src) + 12, 4); \
memcpy(&sin->sin_addr, (src) + 12, 4); \
data = data + ROUNDUP(sin->sin_len); \
data = data + ROUNDUP(sin->sin_len); \
} while
(0)
} while(0)
#define PUSHADDR6(src) \
#define PUSHADDR6(src) \
do { struct sockaddr_in6 *sin6 = (struct sockaddr_in6*) data; \
do { struct sockaddr_in6 *sin6 = (struct sockaddr_in6*) data; \
...
@@ -497,14 +497,14 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
...
@@ -497,14 +497,14 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
if(IN6_IS_ADDR_LINKLOCAL (&sin6->sin6_addr)) \
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); \
data = data + ROUNDUP(sin6->sin6_len); \
} while
(0)
} while(0)
/* KAME ipv6 stack does not support IPv4 mapped IPv6, so we have to
/* KAME ipv6 stack does not support IPv4 mapped IPv6, so we have to
* duplicate the codepath */
* duplicate the codepath */
if
(
ipv4
)
{
if
(
ipv4
)
{
PUSHADDR
(
dest
);
PUSHADDR
(
dest
);
if
(
metric
==
KERNEL_INFINITY
)
{
if
(
metric
==
KERNEL_INFINITY
)
{
PUSHADDR
(
**
local4
);
PUSHADDR
(
**
local4
);
}
else
if
(
plen
==
128
&&
memcmp
(
dest
+
12
,
gate
+
12
,
4
)
==
0
)
{
}
else
if
(
plen
==
128
&&
memcmp
(
dest
+
12
,
gate
+
12
,
4
)
==
0
)
{
#if defined(RTF_CLONING)
#if defined(RTF_CLONING)
...
@@ -524,7 +524,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
...
@@ -524,7 +524,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
}
else
{
}
else
{
PUSHADDR6
(
dest
);
PUSHADDR6
(
dest
);
if
(
metric
==
KERNEL_INFINITY
)
{
if
(
metric
==
KERNEL_INFINITY
)
{
PUSHADDR6
(
**
local6
);
PUSHADDR6
(
**
local6
);
}
else
{
}
else
{
msg
.
m_rtm
.
rtm_flags
|=
RTF_GATEWAY
;
msg
.
m_rtm
.
rtm_flags
|=
RTF_GATEWAY
;
...
@@ -544,7 +544,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
...
@@ -544,7 +544,7 @@ kernel_route(int operation, const unsigned char *dest, unsigned short plen,
msg
.
m_rtm
.
rtm_msglen
=
data
-
(
char
*
)
&
msg
;
msg
.
m_rtm
.
rtm_msglen
=
data
-
(
char
*
)
&
msg
;
rc
=
write
(
kernel_socket
,
(
char
*
)
&
msg
,
msg
.
m_rtm
.
rtm_msglen
);
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
;
return
1
;
return
1
;
...
@@ -677,7 +677,7 @@ kernel_routes(struct kernel_route *routes, int maxroutes)
...
@@ -677,7 +677,7 @@ kernel_routes(struct kernel_route *routes, int maxroutes)
mib
[
5
]
=
0
;
/* No flags */
mib
[
5
]
=
0
;
/* No flags */
rc
=
sysctl
(
mib
,
6
,
NULL
,
&
len
,
NULL
,
0
);
rc
=
sysctl
(
mib
,
6
,
NULL
,
&
len
,
NULL
,
0
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
perror
(
"kernel_routes(len)"
);
perror
(
"kernel_routes(len)"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -689,7 +689,7 @@ kernel_routes(struct kernel_route *routes, int maxroutes)
...
@@ -689,7 +689,7 @@ kernel_routes(struct kernel_route *routes, int maxroutes)
}
}
rc
=
sysctl
(
mib
,
6
,
buf
,
&
len
,
NULL
,
0
);
rc
=
sysctl
(
mib
,
6
,
buf
,
&
len
,
NULL
,
0
);
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
perror
(
"kernel_routes(dump)"
);
perror
(
"kernel_routes(dump)"
);
goto
fail
;
goto
fail
;
}
}
...
...
message.c
View file @
b9605676
...
@@ -89,7 +89,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
...
@@ -89,7 +89,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
return
-
1
;
return
-
1
;
memcpy
(
prefix
,
v4prefix
,
12
);
memcpy
(
prefix
,
v4prefix
,
12
);
if
(
omitted
)
{
if
(
omitted
)
{
if
(
dp
==
NULL
||
!
v4mapped
(
dp
))
return
-
1
;
if
(
dp
==
NULL
||
!
v4mapped
(
dp
))
return
-
1
;
memcpy
(
prefix
,
dp
,
12
+
omitted
);
memcpy
(
prefix
,
dp
,
12
+
omitted
);
}
}
if
(
pb
>
omitted
)
memcpy
(
prefix
+
12
+
omitted
,
p
,
pb
-
omitted
);
if
(
pb
>
omitted
)
memcpy
(
prefix
+
12
+
omitted
,
p
,
pb
-
omitted
);
...
@@ -98,7 +98,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
...
@@ -98,7 +98,7 @@ network_prefix(int ae, int plen, unsigned int omitted,
case
2
:
case
2
:
if
(
omitted
>
16
||
(
pb
>
omitted
&&
len
<
pb
-
omitted
))
return
-
1
;
if
(
omitted
>
16
||
(
pb
>
omitted
&&
len
<
pb
-
omitted
))
return
-
1
;
if
(
omitted
)
{
if
(
omitted
)
{
if
(
dp
==
NULL
||
v4mapped
(
dp
))
return
-
1
;
if
(
dp
==
NULL
||
v4mapped
(
dp
))
return
-
1
;
memcpy
(
prefix
,
dp
,
omitted
);
memcpy
(
prefix
,
dp
,
omitted
);
}
}
if
(
pb
>
omitted
)
memcpy
(
prefix
+
omitted
,
p
,
pb
-
omitted
);
if
(
pb
>
omitted
)
memcpy
(
prefix
+
omitted
,
p
,
pb
-
omitted
);
...
@@ -620,7 +620,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
...
@@ -620,7 +620,7 @@ parse_packet(const unsigned char *from, struct interface *ifp,
format_address
(
from
),
ifp
->
name
,
rtt
);
format_address
(
from
),
ifp
->
name
,
rtt
);
old_rttcost
=
neighbour_rttcost
(
neigh
);
old_rttcost
=
neighbour_rttcost
(
neigh
);
if
(
valid_rtt
(
neigh
))
{
if
(
valid_rtt
(
neigh
))
{
/* Running exponential average. */
/* Running exponential average. */
smoothed_rtt
=
(
ifp
->
rtt_decay
*
rtt
+
smoothed_rtt
=
(
ifp
->
rtt_decay
*
rtt
+
(
256
-
ifp
->
rtt_decay
)
*
neigh
->
rtt
);
(
256
-
ifp
->
rtt_decay
)
*
neigh
->
rtt
);
...
@@ -1475,7 +1475,7 @@ send_ihu(struct neighbour *neigh, struct interface *ifp)
...
@@ -1475,7 +1475,7 @@ send_ihu(struct neighbour *neigh, struct interface *ifp)
accumulate_bytes
(
ifp
,
neigh
->
address
+
8
,
8
);
accumulate_bytes
(
ifp
,
neigh
->
address
+
8
,
8
);
else
else
accumulate_bytes
(
ifp
,
neigh
->
address
,
16
);
accumulate_bytes
(
ifp
,
neigh
->
address
,
16
);
if
(
send_rtt_data
)
{
if
(
send_rtt_data
)
{
accumulate_byte
(
ifp
,
SUBTLV_TIMESTAMP
);
accumulate_byte
(
ifp
,
SUBTLV_TIMESTAMP
);
accumulate_byte
(
ifp
,
8
);
accumulate_byte
(
ifp
,
8
);
accumulate_int
(
ifp
,
neigh
->
hello_send_us
);
accumulate_int
(
ifp
,
neigh
->
hello_send_us
);
...
@@ -1494,7 +1494,7 @@ send_ihu(struct neighbour *neigh, struct interface *ifp)
...
@@ -1494,7 +1494,7 @@ send_ihu(struct neighbour *neigh, struct interface *ifp)
accumulate_unicast_bytes
(
neigh
,
neigh
->
address
+
8
,
8
);
accumulate_unicast_bytes
(
neigh
,
neigh
->
address
+
8
,
8
);
else
else
accumulate_unicast_bytes
(
neigh
,
neigh
->
address
,
16
);
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
,
SUBTLV_TIMESTAMP
);
accumulate_unicast_byte
(
neigh
,
8
);
accumulate_unicast_byte
(
neigh
,
8
);
accumulate_unicast_int
(
neigh
,
neigh
->
hello_send_us
);
accumulate_unicast_int
(
neigh
,
neigh
->
hello_send_us
);
...
...
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