Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
iproute2
Commits
2520598a
Commit
2520598a
authored
Nov 13, 2015
by
Phil Sutter
Committed by
Stephen Hemminger
Nov 23, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
iptunnel: share common code when setting tunnel mode
Signed-off-by:
Phil Sutter
<
phil@nwl.cc
>
parent
7894ce77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
25 deletions
+14
-25
ip/iptunnel.c
ip/iptunnel.c
+14
-25
No files found.
ip/iptunnel.c
View file @
2520598a
...
...
@@ -47,6 +47,15 @@ static void usage(void)
exit
(
-
1
);
}
static
void
set_tunnel_proto
(
struct
ip_tunnel_parm
*
p
,
int
proto
)
{
if
(
p
->
iph
.
protocol
&&
p
->
iph
.
protocol
!=
proto
)
{
fprintf
(
stderr
,
"You managed to ask for more than one tunnel mode.
\n
"
);
exit
(
-
1
);
}
p
->
iph
.
protocol
=
proto
;
}
static
int
parse_args
(
int
argc
,
char
**
argv
,
int
cmd
,
struct
ip_tunnel_parm
*
p
)
{
int
count
=
0
;
...
...
@@ -68,38 +77,18 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
NEXT_ARG
();
if
(
strcmp
(
*
argv
,
"ipip"
)
==
0
||
strcmp
(
*
argv
,
"ip/ip"
)
==
0
)
{
if
(
p
->
iph
.
protocol
&&
p
->
iph
.
protocol
!=
IPPROTO_IPIP
)
{
fprintf
(
stderr
,
"You managed to ask for more than one tunnel mode.
\n
"
);
exit
(
-
1
);
}
p
->
iph
.
protocol
=
IPPROTO_IPIP
;
set_tunnel_proto
(
p
,
IPPROTO_IPIP
);
}
else
if
(
strcmp
(
*
argv
,
"gre"
)
==
0
||
strcmp
(
*
argv
,
"gre/ip"
)
==
0
)
{
if
(
p
->
iph
.
protocol
&&
p
->
iph
.
protocol
!=
IPPROTO_GRE
)
{
fprintf
(
stderr
,
"You managed to ask for more than one tunnel mode.
\n
"
);
exit
(
-
1
);
}
p
->
iph
.
protocol
=
IPPROTO_GRE
;
set_tunnel_proto
(
p
,
IPPROTO_GRE
);
}
else
if
(
strcmp
(
*
argv
,
"sit"
)
==
0
||
strcmp
(
*
argv
,
"ipv6/ip"
)
==
0
)
{
if
(
p
->
iph
.
protocol
&&
p
->
iph
.
protocol
!=
IPPROTO_IPV6
)
{
fprintf
(
stderr
,
"You managed to ask for more than one tunnel mode.
\n
"
);
exit
(
-
1
);
}
p
->
iph
.
protocol
=
IPPROTO_IPV6
;
set_tunnel_proto
(
p
,
IPPROTO_IPV6
);
}
else
if
(
strcmp
(
*
argv
,
"isatap"
)
==
0
)
{
if
(
p
->
iph
.
protocol
&&
p
->
iph
.
protocol
!=
IPPROTO_IPV6
)
{
fprintf
(
stderr
,
"You managed to ask for more than one tunnel mode.
\n
"
);
exit
(
-
1
);
}
p
->
iph
.
protocol
=
IPPROTO_IPV6
;
set_tunnel_proto
(
p
,
IPPROTO_IPV6
);
isatap
++
;
}
else
if
(
strcmp
(
*
argv
,
"vti"
)
==
0
)
{
if
(
p
->
iph
.
protocol
&&
p
->
iph
.
protocol
!=
IPPROTO_IPIP
)
{
fprintf
(
stderr
,
"You managed to ask for more than one tunnel mode.
\n
"
);
exit
(
-
1
);
}
p
->
iph
.
protocol
=
IPPROTO_IPIP
;
set_tunnel_proto
(
p
,
IPPROTO_IPIP
);
p
->
i_flags
|=
VTI_ISVTI
;
}
else
{
fprintf
(
stderr
,
"Unknown tunnel mode
\"
%s
\"\n
"
,
*
argv
);
...
...
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