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
f40cbec0
Commit
f40cbec0
authored
Jan 02, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add kernel_interface_ipv4.
parent
02baf1c0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
kernel.h
kernel.h
+1
-0
kernel_netlink.c
kernel_netlink.c
+23
-0
kernel_socket.c
kernel_socket.c
+23
-0
No files found.
kernel.h
View file @
f40cbec0
...
...
@@ -37,6 +37,7 @@ struct kernel_route {
int
kernel_setup
(
int
setup
);
int
kernel_setup_socket
(
int
setup
);
int
kernel_setup_interface
(
int
setup
,
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_ipv4
(
const
char
*
ifname
,
int
ifindex
,
char
*
addr_r
);
int
kernel_interface_mtu
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_wireless
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_route
(
int
operation
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
...
...
kernel_netlink.c
View file @
f40cbec0
...
...
@@ -500,6 +500,29 @@ kernel_setup_interface(int setup, const char *ifname, int ifindex)
return
1
;
}
int
kernel_interface_ipv4
(
const
char
*
ifname
,
int
ifindex
,
char
*
addr_r
)
{
struct
ifreq
req
;
int
s
,
rc
;
s
=
socket
(
PF_INET
,
SOCK_DGRAM
,
0
);
if
(
s
<
0
)
return
-
1
;
memset
(
&
req
,
0
,
sizeof
(
req
));
strncpy
(
req
.
ifr_name
,
ifname
,
sizeof
(
req
.
ifr_name
));
req
.
ifr_addr
.
sa_family
=
AF_INET
;
rc
=
ioctl
(
s
,
SIOCGIFADDR
,
&
req
);
if
(
rc
<
0
)
{
close
(
s
);
return
-
1
;
}
memcpy
(
addr_r
,
&
((
struct
sockaddr_in
*
)
&
req
.
ifr_addr
)
->
sin_addr
,
4
);
return
1
;
}
int
kernel_interface_mtu
(
const
char
*
ifname
,
int
ifindex
)
{
...
...
kernel_socket.c
View file @
f40cbec0
...
...
@@ -220,6 +220,29 @@ kernel_setup_interface(int setup, const char *ifname, int ifindex)
return
1
;
}
int
kernel_interface_ipv4
(
const
char
*
ifname
,
int
ifindex
,
char
*
addr_r
)
{
struct
ifreq
req
;
int
s
,
rc
;
s
=
socket
(
PF_INET
,
SOCK_DGRAM
,
0
);
if
(
s
<
0
)
return
-
1
;
memset
(
&
req
,
0
,
sizeof
(
req
));
strncpy
(
req
.
ifr_name
,
ifname
,
sizeof
(
req
.
ifr_name
));
req
.
ifr_addr
.
sa_family
=
AF_INET
;
rc
=
ioctl
(
s
,
SIOCGIFADDR
,
&
req
);
if
(
rc
<
0
)
{
close
(
s
);
return
-
1
;
}
memcpy
(
addr_r
,
&
((
struct
sockaddr_in
*
)
&
req
.
ifr_addr
)
->
sin_addr
,
4
);
return
1
;
}
int
kernel_interface_mtu
(
const
char
*
ifname
,
int
ifindex
)
{
...
...
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