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
150a87a6
Commit
150a87a6
authored
Jun 15, 2007
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use named constants for kernel route manipulation.
parent
17ef3ef2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
13 deletions
+16
-13
kernel.c
kernel.c
+4
-4
kernel.h
kernel.h
+4
-1
route.c
route.c
+4
-4
xroute.c
xroute.c
+4
-4
No files found.
kernel.c
View file @
150a87a6
...
@@ -545,7 +545,7 @@ kernel_interface_wireless(const char *ifname, int ifindex)
...
@@ -545,7 +545,7 @@ kernel_interface_wireless(const char *ifname, int ifindex)
}
}
int
int
kernel_route
(
int
add
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
kernel_route
(
int
operation
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
)
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
)
{
{
...
@@ -554,8 +554,8 @@ kernel_route(int add, const unsigned char *dest, unsigned short plen,
...
@@ -554,8 +554,8 @@ kernel_route(int add, const unsigned char *dest, unsigned short plen,
struct
rtattr
*
rta
;
struct
rtattr
*
rta
;
int
len
=
sizeof
(
buf
.
raw
);
int
len
=
sizeof
(
buf
.
raw
);
debugf
(
"kernel_route: %s
:
%s/%d metric %d via %d nexthop %s
\n
"
,
debugf
(
"kernel_route: %s %s/%d metric %d via %d nexthop %s
\n
"
,
add
?
"Add"
:
"Del
"
,
operation
==
ROUTE_ADD
?
"add"
:
"flush
"
,
format_address
(
dest
),
plen
,
metric
,
ifindex
,
format_address
(
dest
),
plen
,
metric
,
ifindex
,
format_address
(
gate
));
format_address
(
gate
));
...
@@ -566,7 +566,7 @@ kernel_route(int add, const unsigned char *dest, unsigned short plen,
...
@@ -566,7 +566,7 @@ kernel_route(int add, const unsigned char *dest, unsigned short plen,
}
}
memset
(
buf
.
raw
,
0
,
sizeof
(
buf
.
raw
));
memset
(
buf
.
raw
,
0
,
sizeof
(
buf
.
raw
));
if
(
add
)
{
if
(
operation
==
ROUTE_ADD
)
{
buf
.
nh
.
nlmsg_flags
=
NLM_F_REQUEST
|
NLM_F_CREATE
|
NLM_F_EXCL
;
buf
.
nh
.
nlmsg_flags
=
NLM_F_REQUEST
|
NLM_F_CREATE
|
NLM_F_EXCL
;
buf
.
nh
.
nlmsg_type
=
RTM_NEWROUTE
;
buf
.
nh
.
nlmsg_type
=
RTM_NEWROUTE
;
}
else
{
}
else
{
...
...
kernel.h
View file @
150a87a6
...
@@ -30,11 +30,14 @@ struct kernel_route {
...
@@ -30,11 +30,14 @@ struct kernel_route {
unsigned
char
gw
[
16
];
unsigned
char
gw
[
16
];
};
};
#define ROUTE_FLUSH 0
#define ROUTE_ADD 1
int
kernel_setup
(
int
setup
);
int
kernel_setup
(
int
setup
);
int
kernel_setup_interface
(
int
setup
,
const
char
*
ifname
,
int
ifindex
);
int
kernel_setup_interface
(
int
setup
,
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_mtu
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_mtu
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_wireless
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_wireless
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_route
(
int
add
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
int
kernel_route
(
int
operation
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
);
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
);
int
kernel_routes
(
int
maxplen
,
struct
kernel_route
*
routes
,
int
maxroutes
);
int
kernel_routes
(
int
maxplen
,
struct
kernel_route
*
routes
,
int
maxroutes
);
int
kernel_callback
(
void
);
int
kernel_callback
(
void
);
route.c
View file @
150a87a6
...
@@ -177,12 +177,12 @@ install_route(struct route *route)
...
@@ -177,12 +177,12 @@ install_route(struct route *route)
if
(
installed
)
if
(
installed
)
uninstall_route
(
installed
);
uninstall_route
(
installed
);
rc
=
kernel_route
(
1
,
route
->
dest
->
address
,
128
,
rc
=
kernel_route
(
ROUTE_ADD
,
route
->
dest
->
address
,
128
,
route
->
nexthop
->
address
,
route
->
nexthop
->
address
,
route
->
nexthop
->
network
->
ifindex
,
route
->
nexthop
->
network
->
ifindex
,
metric_to_kernel
(
route
->
metric
));
metric_to_kernel
(
route
->
metric
));
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
perror
(
"kernel_route(
1
)"
);
perror
(
"kernel_route(
ADD
)"
);
if
(
errno
!=
EEXIST
)
if
(
errno
!=
EEXIST
)
return
;
return
;
}
}
...
@@ -209,12 +209,12 @@ uninstall_route(struct route *route)
...
@@ -209,12 +209,12 @@ uninstall_route(struct route *route)
uninstall_xroute
(
&
xroutes
[
i
]);
uninstall_xroute
(
&
xroutes
[
i
]);
}
}
rc
=
kernel_route
(
0
,
route
->
dest
->
address
,
128
,
rc
=
kernel_route
(
ROUTE_FLUSH
,
route
->
dest
->
address
,
128
,
route
->
nexthop
->
address
,
route
->
nexthop
->
address
,
route
->
nexthop
->
network
->
ifindex
,
route
->
nexthop
->
network
->
ifindex
,
metric_to_kernel
(
route
->
metric
));
metric_to_kernel
(
route
->
metric
));
if
(
rc
<
0
)
if
(
rc
<
0
)
perror
(
"kernel_route(
0
)"
);
perror
(
"kernel_route(
FLUSH
)"
);
route
->
installed
=
0
;
route
->
installed
=
0
;
}
}
...
...
xroute.c
View file @
150a87a6
...
@@ -116,12 +116,12 @@ install_xroute(struct xroute *xroute)
...
@@ -116,12 +116,12 @@ install_xroute(struct xroute *xroute)
if
(
installed
)
if
(
installed
)
uninstall_xroute
(
installed
);
uninstall_xroute
(
installed
);
rc
=
kernel_route
(
1
,
xroute
->
prefix
,
xroute
->
plen
,
rc
=
kernel_route
(
ROUTE_ADD
,
xroute
->
prefix
,
xroute
->
plen
,
gwroute
->
nexthop
->
address
,
gwroute
->
nexthop
->
address
,
gwroute
->
nexthop
->
network
->
ifindex
,
gwroute
->
nexthop
->
network
->
ifindex
,
metric_to_kernel
(
xroute
->
metric
));
metric_to_kernel
(
xroute
->
metric
));
if
(
rc
<
0
)
{
if
(
rc
<
0
)
{
perror
(
"kernel_route(
1
)"
);
perror
(
"kernel_route(
ADD
)"
);
if
(
errno
!=
EEXIST
)
if
(
errno
!=
EEXIST
)
return
;
return
;
}
}
...
@@ -145,12 +145,12 @@ uninstall_xroute(struct xroute *xroute)
...
@@ -145,12 +145,12 @@ uninstall_xroute(struct xroute *xroute)
return
;
return
;
}
}
rc
=
kernel_route
(
0
,
xroute
->
prefix
,
xroute
->
plen
,
rc
=
kernel_route
(
ROUTE_FLUSH
,
xroute
->
prefix
,
xroute
->
plen
,
gwroute
->
nexthop
->
address
,
gwroute
->
nexthop
->
address
,
gwroute
->
nexthop
->
network
->
ifindex
,
gwroute
->
nexthop
->
network
->
ifindex
,
metric_to_kernel
(
xroute
->
metric
));
metric_to_kernel
(
xroute
->
metric
));
if
(
rc
<
0
)
if
(
rc
<
0
)
perror
(
"kernel_route(
0
)"
);
perror
(
"kernel_route(
FLUSH
)"
);
xroute
->
installed
=
0
;
xroute
->
installed
=
0
;
}
}
...
...
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