]>
git.proxmox.com Git - mirror_frr.git/blob - lib/route_types.awk
3 # Scan a file of route-type definitions (see eg route_types.txt) and
4 # generate a corresponding header file with:
6 # - enum of Zserv route-types
7 # - redistribute strings for the various Quagga daemons
9 # See route_types.txt for the format.
20 # 'bare' redistribute specifier, <1-255>, help string.
21 redist_bare_help =
"Numeric Zserv route type";
24 redist_def_fmt =
"#define QUAGGA_REDIST_STR_%s \\\n";
25 redist_str_fmt =
"\"(%s<1-255>)\"\n";
26 redist_help_def_fmt =
"#define QUAGGA_REDIST_HELP_STR_%s";
27 redist_help_str_fmt =
" \\\n \"%s\\n\"";
30 header =
"/* Auto-generated from route_types.txt by " ARGV[0] ". */\n";
31 header = header
"/* Do not edit! */\n";
32 header = header
"\n#ifndef _QUAGGA_ROUTE_TYPES_H\n";
33 header = header
"#define _QUAGGA_ROUTE_TYPES_H\n";
34 footer =
"#endif /* _QUAGGA_ROUTE_TYPES_H */\n";
35 printf ("%s\n", header
);
43 # get rid of the commas, leading/trailling whitespace and
46 for (i =
1; i
<=
NF; i
++) {
48 $i = gensub
(/^
[[:blank
:]]*(.
*)[,]*.
*/, "\\1", "g",$i
);
49 $i = gensub
(/^
["](.*)["]$
/, "\\1", "g", $i
);
55 # type cname daemon C 4 6 short help
60 print "error: attempt to redefine", $
1;
65 typesbynum
[tcount
] = $
1;
66 types
[$
1,"num"] = tcount
++;
67 types
[$
1,"cname"] = $
2;
68 types
[$
1,"daemon"] = $
3;
70 types
[$
1,"4"] = strtonum
($
5);
71 types
[$
1,"6"] = strtonum
($
6);
72 types
[$
1,"shelp"] = $
7;
74 #print "num :", types[$1,"num"]
75 #print "cname :", types[$1,"cname"]
76 #print "daemon:", types[$1,"daemon"];
77 #print "char :", types[$1,"C"];
80 # 2 field: type "long description"
84 if (!
(($
1 SUBSEP
"num") in types
)) {
85 print "error: type", $
1, "must be defined before help str";
90 types
[$
1,"lhelp"] = $
2;
100 #for (i = 0; i < tcount; i++) {
101 # type = typesbynum[i];
102 # if (type != "" && types[type,"num"] == i)
103 # printf (" %s,\n", type);
105 #printf (" ZEBRA_ROUTE_MAX,\n};\n\n");
107 # the redistribute defines
108 for (i =
0; i
< tcount
; i
++) {
109 type = typesbynum
[i
];
111 # must be a type, and must cross-check against recorded type
112 if (type ==
"" || types
[type
,"num"] != i
)
115 # ignore route types that can't be redistributed
116 if (!
(types
[type
,"4"] || types
[type
,"6"]))
119 # must have a daemon name
120 if (!
((type SUBSEP
"daemon") in types
))
122 if (!
(daemon = types
[type
,"daemon"]))
125 # might have done this daemon already?
126 if (daemon in seen_daemons
)
129 cname = types
[type
,"cname"];
134 # add it to the others
135 for (j =
0; j
< tcount
; j
++) {
140 type2 = typesbynum
[j
];
142 # type2 must be valid, and self-check.
143 if (type2 ==
"" || types
[type2
,"num"] != j
)
146 # ignore different route types for the same daemon
147 # (eg system/kernel/connected)
148 if (types
[type2
,"daemon"] == daemon
)
151 if ((types
[type2
,"4"] && types
[type
,"4"]) \
152 || (types
[type2
,"6"] && types
[type
,"6"])) {
154 rstr = rstr types
[type2
,"cname"] "|";
156 if ((type2 SUBSEP
"lhelp") in types
)
157 hstr2 = types
[type2
,"lhelp"];
158 else if ((type2 SUBSEP
"shelp") in types
)
159 hstr2 = types
[type2
,"shelp"];
161 hstr2 = types
[type2
,"cname"];
163 hstr = hstr
sprintf(redist_help_str_fmt
, hstr2
);
167 # dont double-process daemons.
168 seen_daemons
[daemon
] =
1;
170 printf("/* %s */\n", daemon
);
171 printf(redist_def_fmt
, toupper(daemon
));
172 printf(redist_str_fmt
, rstr
);
173 printf(redist_help_def_fmt
, toupper(daemon
));
175 printf(redist_help_str_fmt
, redist_bare_help
);
180 #printf("#define QUAGGA_REDIST_STR_ALL %s\n",all);
182 # for (i = 0; i < lcount; i++) {
183 # if (mlists[i] != "")
184 # printf (mlistformat "\n", mlists[i]);