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
9fce67dd
Commit
9fce67dd
authored
Apr 03, 2009
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove goto chain
The selector logic is clearer with if / else if
parent
e48f73d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
115 deletions
+42
-115
tc/f_u32.c
tc/f_u32.c
+42
-115
No files found.
tc/f_u32.c
View file @
9fce67dd
...
...
@@ -47,7 +47,7 @@ static void explain(void)
#define usage() return(-1)
int
get_u32_handle
(
__u32
*
handle
,
char
*
str
)
int
get_u32_handle
(
__u32
*
handle
,
c
onst
c
har
*
str
)
{
__u32
htid
=
0
,
hash
=
0
,
nodeid
=
0
;
char
*
tmp
=
strchr
(
str
,
':'
);
...
...
@@ -417,77 +417,49 @@ static int parse_ip(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
if
(
strcmp
(
*
argv
,
"src"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_ip_addr
(
&
argc
,
&
argv
,
sel
,
12
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"dst"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"dst"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_ip_addr
(
&
argc
,
&
argv
,
sel
,
16
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"tos"
)
==
0
||
}
else
if
(
strcmp
(
*
argv
,
"tos"
)
==
0
||
matches
(
*
argv
,
"dsfield"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
1
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"ihl"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"ihl"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
0
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"protocol"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"protocol"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
9
,
0
);
goto
done
;
}
if
(
matches
(
*
argv
,
"precedence"
)
==
0
)
{
}
else
if
(
matches
(
*
argv
,
"precedence"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
1
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"nofrag"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"nofrag"
)
==
0
)
{
argc
--
;
argv
++
;
res
=
pack_key16
(
sel
,
0
,
0x3FFF
,
6
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"firstfrag"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"firstfrag"
)
==
0
)
{
argc
--
;
argv
++
;
res
=
pack_key16
(
sel
,
0
,
0x1FFF
,
6
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"df"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"df"
)
==
0
)
{
argc
--
;
argv
++
;
res
=
pack_key16
(
sel
,
0x4000
,
0x4000
,
6
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"mf"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"mf"
)
==
0
)
{
argc
--
;
argv
++
;
res
=
pack_key16
(
sel
,
0x2000
,
0x2000
,
6
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"dport"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"dport"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u16
(
&
argc
,
&
argv
,
sel
,
22
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"sport"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"sport"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u16
(
&
argc
,
&
argv
,
sel
,
20
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"icmp_type"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"icmp_type"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
20
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"icmp_code"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"icmp_code"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
20
,
1
);
goto
done
;
}
return
-
1
;
}
else
return
-
1
;
done:
*
argc_p
=
argc
;
*
argv_p
=
argv
;
return
res
;
...
...
@@ -505,51 +477,33 @@ static int parse_ip6(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
if
(
strcmp
(
*
argv
,
"src"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_ip6_addr
(
&
argc
,
&
argv
,
sel
,
8
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"dst"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"dst"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_ip6_addr
(
&
argc
,
&
argv
,
sel
,
24
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"priority"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"priority"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
4
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"protocol"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"protocol"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
6
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"flowlabel"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"flowlabel"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u32
(
&
argc
,
&
argv
,
sel
,
0
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"dport"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"dport"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u16
(
&
argc
,
&
argv
,
sel
,
42
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"sport"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"sport"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u16
(
&
argc
,
&
argv
,
sel
,
40
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"icmp_type"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"icmp_type"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
40
,
0
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"icmp_code"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"icmp_code"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
41
,
1
);
goto
done
;
}
return
-
1
;
}
else
return
-
1
;
done:
*
argc_p
=
argc
;
*
argv_p
=
argv
;
return
res
;
...
...
@@ -568,16 +522,12 @@ static int parse_udp(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
if
(
strcmp
(
*
argv
,
"src"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u16
(
&
argc
,
&
argv
,
sel
,
0
,
-
1
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"dst"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"dst"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u16
(
&
argc
,
&
argv
,
sel
,
2
,
-
1
);
goto
done
;
}
return
-
1
;
}
else
return
-
1
;
done:
*
argc_p
=
argc
;
*
argv_p
=
argv
;
return
res
;
...
...
@@ -596,16 +546,12 @@ static int parse_icmp(int *argc_p, char ***argv_p, struct tc_u32_sel *sel)
if
(
strcmp
(
*
argv
,
"type"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
0
,
-
1
);
goto
done
;
}
if
(
strcmp
(
*
argv
,
"code"
)
==
0
)
{
}
else
if
(
strcmp
(
*
argv
,
"code"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
1
,
-
1
);
goto
done
;
}
return
-
1
;
}
else
return
-
1
;
done:
*
argc_p
=
argc
;
*
argv_p
=
argv
;
return
res
;
...
...
@@ -659,52 +605,33 @@ static int parse_selector(int *argc_p, char ***argv_p,
if
(
matches
(
*
argv
,
"u32"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u32
(
&
argc
,
&
argv
,
sel
,
0
,
0
);
goto
done
;
}
if
(
matches
(
*
argv
,
"u16"
)
==
0
)
{
}
else
if
(
matches
(
*
argv
,
"u16"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u16
(
&
argc
,
&
argv
,
sel
,
0
,
0
);
goto
done
;
}
if
(
matches
(
*
argv
,
"u8"
)
==
0
)
{
}
else
if
(
matches
(
*
argv
,
"u8"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_u8
(
&
argc
,
&
argv
,
sel
,
0
,
0
);
goto
done
;
}
if
(
matches
(
*
argv
,
"ip"
)
==
0
)
{
}
else
if
(
matches
(
*
argv
,
"ip"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_ip
(
&
argc
,
&
argv
,
sel
);
goto
done
;
}
if
(
matches
(
*
argv
,
"ip6"
)
==
0
)
{
}
else
if
(
matches
(
*
argv
,
"ip6"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_ip6
(
&
argc
,
&
argv
,
sel
);
goto
done
;
}
if
(
matches
(
*
argv
,
"udp"
)
==
0
)
{
}
else
if
(
matches
(
*
argv
,
"udp"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_udp
(
&
argc
,
&
argv
,
sel
);
goto
done
;
}
if
(
matches
(
*
argv
,
"tcp"
)
==
0
)
{
}
else
if
(
matches
(
*
argv
,
"tcp"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_tcp
(
&
argc
,
&
argv
,
sel
);
goto
done
;
}
if
(
matches
(
*
argv
,
"icmp"
)
==
0
)
{
}
else
if
(
matches
(
*
argv
,
"icmp"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_icmp
(
&
argc
,
&
argv
,
sel
);
goto
done
;
}
if
(
matches
(
*
argv
,
"mark"
)
==
0
)
{
}
else
if
(
matches
(
*
argv
,
"mark"
)
==
0
)
{
NEXT_ARG
();
res
=
parse_mark
(
&
argc
,
&
argv
,
n
);
goto
done
;
}
return
-
1
;
}
else
return
-
1
;
done:
*
argc_p
=
argc
;
*
argv_p
=
argv
;
return
res
;
...
...
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