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
19626a7e
Commit
19626a7e
authored
Jul 07, 2012
by
Grégoire Henry
Committed by
Juliusz Chroboczek
Jul 08, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compilation on FreeBSD and Debian/kFreeBSD.
parent
ae638ec8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
kernel_socket.c
kernel_socket.c
+25
-10
net.c
net.c
+1
-1
No files found.
kernel_socket.c
View file @
19626a7e
...
@@ -143,8 +143,13 @@ fail:
...
@@ -143,8 +143,13 @@ fail:
(a).s6_addr[3] = (i) & 0xff; \
(a).s6_addr[3] = (i) & 0xff; \
} while (0)
} while (0)
#if defined(__APPLE__)
#define ROUNDUP(a) \
#define ROUNDUP(a) \
((a) > 0 ? (1 + (((a) - 1) | (sizeof(uint32_t) - 1))) : sizeof(uint32_t))
((a) > 0 ? (1 + (((a) - 1) | (sizeof(uint32_t) - 1))) : sizeof(uint32_t))
#else
#define ROUNDUP(a) \
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
#endif
static
int
old_forwarding
=
-
1
;
static
int
old_forwarding
=
-
1
;
static
int
old_accept_redirects
=
-
1
;
static
int
old_accept_redirects
=
-
1
;
...
@@ -230,7 +235,11 @@ kernel_setup(int setup)
...
@@ -230,7 +235,11 @@ kernel_setup(int setup)
rc
=
0
;
rc
=
0
;
mib
[
2
]
=
IPPROTO_ICMPV6
;
mib
[
2
]
=
IPPROTO_ICMPV6
;
#if defined(IPV6CTL_SENDREDIRECTS)
mib
[
3
]
=
IPV6CTL_SENDREDIRECTS
;
#else
mib
[
3
]
=
ICMPV6CTL_REDIRACCEPT
;
mib
[
3
]
=
ICMPV6CTL_REDIRACCEPT
;
#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
,
...
@@ -560,6 +569,7 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
...
@@ -560,6 +569,7 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
{
{
struct
sockaddr
*
sa
;
struct
sockaddr
*
sa
;
void
*
rta
=
(
void
*
)
rtm
+
sizeof
(
struct
rt_msghdr
);
void
*
rta
=
(
void
*
)
rtm
+
sizeof
(
struct
rt_msghdr
);
uint32_t
excluded_flags
=
0
;
if
(
ifindex_lo
<
0
)
{
if
(
ifindex_lo
<
0
)
{
ifindex_lo
=
if_nametoindex
(
"lo0"
);
ifindex_lo
=
if_nametoindex
(
"lo0"
);
...
@@ -571,12 +581,17 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
...
@@ -571,12 +581,17 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
route
->
metric
=
0
;
route
->
metric
=
0
;
route
->
ifindex
=
rtm
->
rtm_index
;
route
->
ifindex
=
rtm
->
rtm_index
;
/* filter out kernel route (cache) */
#if defined(RTF_IFSCOPE)
if
((
rtm
->
rtm_flags
&
RTF_IFSCOPE
)
!=
0
)
/* Filter out kernel route on OS X */
return
-
1
;
excluded_flags
|=
RTF_IFSCOPE
;
#endif
/* filter out our own route */
#if defined(RTF_MULTICAST)
if
((
rtm
->
rtm_flags
&
RTF_PROTO2
)
!=
0
)
/* Filter out multicast route on others BSD */
excluded_flags
|=
RTF_MULTICAST
;
#endif
/* Filter out our own route */
excluded_flags
|=
RTF_PROTO2
;
if
((
rtm
->
rtm_flags
&
excluded_flags
)
!=
0
)
return
-
1
;
return
-
1
;
/* Prefix */
/* Prefix */
...
@@ -592,7 +607,7 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
...
@@ -592,7 +607,7 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
return
-
1
;
return
-
1
;
}
else
if
(
sa
->
sa_family
==
AF_INET
)
{
}
else
if
(
sa
->
sa_family
==
AF_INET
)
{
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
sa
;
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
sa
;
#if
def __APPLE__
#if
defined(IN_LINKLOCAL)
if
(
IN_LINKLOCAL
(
ntohl
(
sin
->
sin_addr
.
s_addr
)))
if
(
IN_LINKLOCAL
(
ntohl
(
sin
->
sin_addr
.
s_addr
)))
return
-
1
;
return
-
1
;
#endif
#endif
...
@@ -627,8 +642,8 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
...
@@ -627,8 +642,8 @@ parse_kernel_route(const struct rt_msghdr *rtm, struct kernel_route *route)
sa
=
(
struct
sockaddr
*
)
rta
;
sa
=
(
struct
sockaddr
*
)
rta
;
rta
+=
ROUNDUP
(
sa
->
sa_len
);
rta
+=
ROUNDUP
(
sa
->
sa_len
);
if
(
!
v4mapped
(
route
->
prefix
))
{
if
(
!
v4mapped
(
route
->
prefix
))
{
struct
sockaddr_in6
*
sin6
=
(
struct
sockaddr_in6
*
)
sa
;
struct
sockaddr_in6
*
sin6
=
(
struct
sockaddr_in6
*
)
sa
;
route
->
plen
=
mask2len
(
sin6
->
sin6_addr
.
__u6_addr
.
__u6_addr8
,
16
);
route
->
plen
=
mask2len
(
(
unsigned
char
*
)
&
sin6
->
sin6_addr
,
16
);
}
else
{
}
else
{
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
sa
;
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
sa
;
route
->
plen
=
mask2len
((
unsigned
char
*
)
&
sin
->
sin_addr
,
4
);
route
->
plen
=
mask2len
((
unsigned
char
*
)
&
sin
->
sin_addr
,
4
);
...
@@ -778,7 +793,7 @@ kernel_addresses(char *ifname, int ifindex, int ll,
...
@@ -778,7 +793,7 @@ kernel_addresses(char *ifname, int ifindex, int ll,
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
ifap
->
ifa_addr
;
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
ifap
->
ifa_addr
;
if
(
ll
)
if
(
ll
)
goto
next
;
goto
next
;
#if
def __APPLE__
#if
defined(IN_LINKLOCAL)
if
(
IN_LINKLOCAL
(
htonl
(
sin
->
sin_addr
.
s_addr
)))
if
(
IN_LINKLOCAL
(
htonl
(
sin
->
sin_addr
.
s_addr
)))
goto
next
;
goto
next
;
#endif
#endif
...
...
net.c
View file @
19626a7e
...
@@ -28,8 +28,8 @@ THE SOFTWARE.
...
@@ -28,8 +28,8 @@ THE SOFTWARE.
#include <sys/types.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/uio.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <errno.h>
#include <errno.h>
...
...
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