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
a87bbe20
Commit
a87bbe20
authored
Oct 18, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move if_eui64 to system-specific file.
parent
1121ea30
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
40 deletions
+48
-40
kernel.c
kernel.c
+0
-40
kernel_netlink.c
kernel_netlink.c
+40
-0
kernel_socket.c
kernel_socket.c
+8
-0
No files found.
kernel.c
View file @
a87bbe20
...
@@ -58,46 +58,6 @@ kernel_ll_addresses(char *ifname, int ifindex,
...
@@ -58,46 +58,6 @@ kernel_ll_addresses(char *ifname, int ifindex,
return
j
;
return
j
;
}
}
/* Determine an interface's hardware address, in modified EUI-64 format */
int
if_eui64
(
char
*
ifname
,
int
ifindex
,
unsigned
char
*
eui
)
{
int
s
,
rc
;
struct
ifreq
req
;
unsigned
char
*
mac
;
s
=
socket
(
PF_INET
,
SOCK_DGRAM
,
IPPROTO_IP
);
if
(
s
<
0
)
return
-
1
;
memset
(
&
req
,
0
,
sizeof
(
req
));
strncpy
(
req
.
ifr_name
,
ifname
,
sizeof
(
req
.
ifr_name
));
rc
=
ioctl
(
s
,
SIOCGIFHWADDR
,
&
req
);
if
(
rc
<
0
)
{
int
saved_errno
=
errno
;
close
(
s
);
errno
=
saved_errno
;
return
-
1
;
}
close
(
s
);
mac
=
(
unsigned
char
*
)
req
.
ifr_hwaddr
.
sa_data
;
/* OpenVPN interfaces have a null MAC address. Also check not group
and global */
if
(
memcmp
(
mac
,
zeroes
,
6
)
==
0
||
(
mac
[
0
]
&
1
)
!=
0
||
(
mac
[
0
]
&
2
)
!=
0
)
{
errno
=
ENOENT
;
return
-
1
;
}
eui
[
0
]
=
mac
[
0
]
^
2
;
eui
[
1
]
=
mac
[
1
];
eui
[
2
]
=
mac
[
2
];
eui
[
3
]
=
0xFF
;
eui
[
4
]
=
0xFE
;
eui
[
5
]
=
mac
[
3
];
eui
[
6
]
=
mac
[
4
];
eui
[
7
]
=
mac
[
5
];
return
1
;
}
/* Like gettimeofday, but should return monotonic time. If POSIX clocks
/* Like gettimeofday, but should return monotonic time. If POSIX clocks
are not available, falls back to gettimeofday. */
are not available, falls back to gettimeofday. */
int
int
...
...
kernel_netlink.c
View file @
a87bbe20
...
@@ -59,6 +59,46 @@ static int old_rp_filter = -1;
...
@@ -59,6 +59,46 @@ static int old_rp_filter = -1;
static
int
dgram_socket
=
-
1
;
static
int
dgram_socket
=
-
1
;
/* Determine an interface's hardware address, in modified EUI-64 format */
int
if_eui64
(
char
*
ifname
,
int
ifindex
,
unsigned
char
*
eui
)
{
int
s
,
rc
;
struct
ifreq
req
;
unsigned
char
*
mac
;
s
=
socket
(
PF_INET
,
SOCK_DGRAM
,
IPPROTO_IP
);
if
(
s
<
0
)
return
-
1
;
memset
(
&
req
,
0
,
sizeof
(
req
));
strncpy
(
req
.
ifr_name
,
ifname
,
sizeof
(
req
.
ifr_name
));
rc
=
ioctl
(
s
,
SIOCGIFHWADDR
,
&
req
);
if
(
rc
<
0
)
{
int
saved_errno
=
errno
;
close
(
s
);
errno
=
saved_errno
;
return
-
1
;
}
close
(
s
);
mac
=
(
unsigned
char
*
)
req
.
ifr_hwaddr
.
sa_data
;
/* OpenVPN interfaces have a null MAC address. Also check not group
and global */
if
(
memcmp
(
mac
,
zeroes
,
6
)
==
0
||
(
mac
[
0
]
&
1
)
!=
0
||
(
mac
[
0
]
&
2
)
!=
0
)
{
errno
=
ENOENT
;
return
-
1
;
}
eui
[
0
]
=
mac
[
0
]
^
2
;
eui
[
1
]
=
mac
[
1
];
eui
[
2
]
=
mac
[
2
];
eui
[
3
]
=
0xFF
;
eui
[
4
]
=
0xFE
;
eui
[
5
]
=
mac
[
3
];
eui
[
6
]
=
mac
[
4
];
eui
[
7
]
=
mac
[
5
];
return
1
;
}
static
int
static
int
read_proc
(
char
*
filename
)
read_proc
(
char
*
filename
)
{
{
...
...
kernel_socket.c
View file @
a87bbe20
...
@@ -48,6 +48,14 @@ THE SOFTWARE.
...
@@ -48,6 +48,14 @@ THE SOFTWARE.
int
export_table
=
-
1
,
import_table
=
-
1
;
int
export_table
=
-
1
,
import_table
=
-
1
;
int
if_eui64
(
char
*
ifname
,
int
ifindex
,
unsigned
char
*
eui
)
{
errno
=
ENOSYS
;
return
-
1
;
}
/* KAME said : "Following two macros are highly depending on KAME Release" */
/* KAME said : "Following two macros are highly depending on KAME Release" */
#define IN6_LINKLOCAL_IFINDEX(a) ((a).s6_addr[2] << 8 | (a).s6_addr[3])
#define IN6_LINKLOCAL_IFINDEX(a) ((a).s6_addr[2] << 8 | (a).s6_addr[3])
#define SET_IN6_LINKLOCAL_IFINDEX(a, i) \
#define SET_IN6_LINKLOCAL_IFINDEX(a, 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