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
ad8cf851
Commit
ad8cf851
authored
Dec 31, 2009
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement kernel_addresses for BSD.
parent
4e70b650
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
3 deletions
+47
-3
kernel_socket.c
kernel_socket.c
+47
-3
No files found.
kernel_socket.c
View file @
ad8cf851
/*
/*
Copyright (c) 2007 by Grégoire Henry
Copyright (c) 2007 by Grégoire Henry
Copyright (c) 2008 by Juliusz Chroboczek
Copyright (c) 2008
, 2009
by Juliusz Chroboczek
Permission is hereby granted, free of charge, to any person obtaining a copy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
of this software and associated documentation files (the "Software"), to deal
...
@@ -37,6 +37,7 @@ THE SOFTWARE.
...
@@ -37,6 +37,7 @@ THE SOFTWARE.
#include <sys/types.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_dl.h>
#include <net/route.h>
#include <net/route.h>
...
@@ -46,6 +47,9 @@ THE SOFTWARE.
...
@@ -46,6 +47,9 @@ THE SOFTWARE.
#include "kernel.h"
#include "kernel.h"
#include "util.h"
#include "util.h"
static
const
unsigned
char
v4prefix
[
16
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0xFF
,
0xFF
,
0
,
0
,
0
,
0
};
int
export_table
=
-
1
,
import_table
=
-
1
;
int
export_table
=
-
1
,
import_table
=
-
1
;
int
int
...
@@ -612,8 +616,48 @@ int
...
@@ -612,8 +616,48 @@ int
kernel_addresses
(
char
*
ifname
,
int
ifindex
,
int
ll
,
kernel_addresses
(
char
*
ifname
,
int
ifindex
,
int
ll
,
struct
kernel_route
*
routes
,
int
maxroutes
)
struct
kernel_route
*
routes
,
int
maxroutes
)
{
{
errno
=
ENOSYS
;
struct
ifaddrs
*
ifa
,
*
ifap
;
int
rc
,
i
;
rc
=
getifaddrs
(
&
ifa
);
if
(
rc
<
0
)
return
-
1
;
return
-
1
;
ifap
=
ifa
;
i
=
0
;
while
(
ifap
&&
i
<
maxroutes
)
{
if
(
ifap
->
ifa_name
==
NULL
||
strcmp
(
ifap
->
ifa_name
,
ifname
)
!=
0
)
goto
next
;
if
(
ifap
->
ifa_addr
->
sa_family
==
AF_INET6
)
{
struct
sockaddr_in6
*
sin6
=
(
struct
sockaddr_in6
*
)
ifap
->
ifa_addr
;
if
(
!!
ll
!=
!!
IN6_IS_ADDR_LINKLOCAL
(
&
sin6
->
sin6_addr
))
goto
next
;
memcpy
(
routes
[
i
].
prefix
,
&
sin6
->
sin6_addr
,
16
);
routes
[
i
].
plen
=
128
;
routes
[
i
].
metric
=
0
;
routes
[
i
].
ifindex
=
ifindex
;
routes
[
i
].
proto
=
RTPROT_BABEL_LOCAL
;
memset
(
routes
[
i
].
gw
,
0
,
16
);
}
else
if
(
ifap
->
ifa_addr
->
sa_family
==
AF_INET
)
{
struct
sockaddr_in
*
sin
=
(
struct
sockaddr_in
*
)
ifap
->
ifa_addr
;
if
(
ll
)
goto
next
;
memcpy
(
routes
[
i
].
prefix
,
v4prefix
,
12
);
memcpy
(
routes
[
i
].
prefix
+
12
,
&
sin
->
sin_addr
,
4
);
routes
[
i
].
plen
=
128
;
routes
[
i
].
metric
=
0
;
routes
[
i
].
ifindex
=
ifindex
;
routes
[
i
].
proto
=
RTPROT_BABEL_LOCAL
;
memset
(
routes
[
i
].
gw
,
0
,
16
);
}
next:
ifap
=
ifap
->
ifa_next
;
i
++
;
}
freeifaddrs
(
ifa
);
return
i
;
}
}
int
int
...
...
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