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
978bfd37
Commit
978bfd37
authored
Oct 09, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a function to determine an interface's link-layer address.
parent
c7535333
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
kernel.c
kernel.c
+39
-0
kernel.h
kernel.h
+1
-0
No files found.
kernel.c
View file @
978bfd37
...
@@ -58,6 +58,45 @@ kernel_ll_addresses(char *ifname, int ifindex,
...
@@ -58,6 +58,45 @@ 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
;
/* Check not group and global */
if
((
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.h
View file @
978bfd37
...
@@ -61,4 +61,5 @@ int kernel_addresses(char *ifname, int ifindex,
...
@@ -61,4 +61,5 @@ int kernel_addresses(char *ifname, int ifindex,
struct
kernel_route
*
routes
,
int
maxroutes
);
struct
kernel_route
*
routes
,
int
maxroutes
);
int
kernel_ll_addresses
(
char
*
ifname
,
int
ifindex
,
int
kernel_ll_addresses
(
char
*
ifname
,
int
ifindex
,
unsigned
char
(
*
addresses
)[
16
],
int
maxaddr
);
unsigned
char
(
*
addresses
)[
16
],
int
maxaddr
);
int
if_eui64
(
char
*
ifname
,
int
ifindex
,
unsigned
char
*
eui
);
int
gettime
(
struct
timeval
*
tv
);
int
gettime
(
struct
timeval
*
tv
);
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