aboutsummaryrefslogtreecommitdiff
path: root/networking/libiproute/rt_names.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/libiproute/rt_names.c')
-rw-r--r--networking/libiproute/rt_names.c81
1 files changed, 0 insertions, 81 deletions
diff --git a/networking/libiproute/rt_names.c b/networking/libiproute/rt_names.c
index 5206c4b40..9d47491bc 100644
--- a/networking/libiproute/rt_names.c
+++ b/networking/libiproute/rt_names.c
@@ -207,23 +207,6 @@ static void rtnl_rtrealm_initialize(void)
207 rtnl_rtrealm_tab, 256); 207 rtnl_rtrealm_tab, 256);
208} 208}
209 209
210const char * rtnl_rtrealm_n2a(int id, char *buf, int len)
211{
212 if (id<0 || id>=256) {
213 snprintf(buf, len, "%d", id);
214 return buf;
215 }
216 if (!rtnl_rtrealm_tab[id]) {
217 if (!rtnl_rtrealm_init)
218 rtnl_rtrealm_initialize();
219 }
220 if (rtnl_rtrealm_tab[id])
221 return rtnl_rtrealm_tab[id];
222 snprintf(buf, len, "%d", id);
223 return buf;
224}
225
226
227int rtnl_rtrealm_a2n(uint32_t *id, char *arg) 210int rtnl_rtrealm_a2n(uint32_t *id, char *arg)
228{ 211{
229 static char *cache = NULL; 212 static char *cache = NULL;
@@ -258,70 +241,6 @@ int rtnl_rtrealm_a2n(uint32_t *id, char *arg)
258 241
259 242
260 243
261static char * rtnl_rttable_tab[256] = {
262 "unspec",
263};
264
265static int rtnl_rttable_init;
266
267static void rtnl_rttable_initialize(void)
268{
269 rtnl_rttable_init = 1;
270 rtnl_rttable_tab[255] = "local";
271 rtnl_rttable_tab[254] = "main";
272 rtnl_tab_initialize("/etc/iproute2/rt_tables",
273 rtnl_rttable_tab, 256);
274}
275
276const char * rtnl_rttable_n2a(int id, char *buf, int len)
277{
278 if (id<0 || id>=256) {
279 snprintf(buf, len, "%d", id);
280 return buf;
281 }
282 if (!rtnl_rttable_tab[id]) {
283 if (!rtnl_rttable_init)
284 rtnl_rttable_initialize();
285 }
286 if (rtnl_rttable_tab[id])
287 return rtnl_rttable_tab[id];
288 snprintf(buf, len, "%d", id);
289 return buf;
290}
291
292int rtnl_rttable_a2n(uint32_t *id, char *arg)
293{
294 static char *cache = NULL;
295 static unsigned long res;
296 char *end;
297 int i;
298
299 if (cache && strcmp(cache, arg) == 0) {
300 *id = res;
301 return 0;
302 }
303
304 if (!rtnl_rttable_init)
305 rtnl_rttable_initialize();
306
307 for (i=0; i<256; i++) {
308 if (rtnl_rttable_tab[i] &&
309 strcmp(rtnl_rttable_tab[i], arg) == 0) {
310 cache = rtnl_rttable_tab[i];
311 res = i;
312 *id = res;
313 return 0;
314 }
315 }
316
317 i = strtoul(arg, &end, 0);
318 if (!end || end == arg || *end || i > 255)
319 return -1;
320 *id = i;
321 return 0;
322}
323
324
325static char * rtnl_rtdsfield_tab[256] = { 244static char * rtnl_rtdsfield_tab[256] = {
326 "0", 245 "0",
327}; 246};