3 * Copyright (C) 1997, 1998, 1999 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 #define QUAGGA_DEFINE_DESC_TABLE
33 /* for printstack on solaris */
34 #ifdef HAVE_UCONTEXT_H
38 static int logfile_fd
= -1; /* Used in signal handler. */
40 struct zlog
*zlog_default
= NULL
;
42 const char *zlog_proto_names
[] =
58 const char *zlog_priority
[] =
73 /* For time string format. */
76 quagga_timestamp(int timestamp_precision
, char *buf
, size_t buflen
)
85 /* would it be sufficient to use global 'recent_time' here? I fear not... */
86 gettimeofday(&clock
, NULL
);
88 /* first, we update the cache if the time has changed */
89 if (cache
.last
!= clock
.tv_sec
)
92 cache
.last
= clock
.tv_sec
;
93 tm
= localtime(&cache
.last
);
94 cache
.len
= strftime(cache
.buf
, sizeof(cache
.buf
),
95 "%Y/%m/%d %H:%M:%S", tm
);
97 /* note: it's not worth caching the subsecond part, because
98 chances are that back-to-back calls are not sufficiently close together
99 for the clock not to have ticked forward */
101 if (buflen
> cache
.len
)
103 memcpy(buf
, cache
.buf
, cache
.len
);
104 if ((timestamp_precision
> 0) &&
105 (buflen
> cache
.len
+1+timestamp_precision
))
107 /* should we worry about locale issues? */
108 static const int divisor
[] = {0, 100000, 10000, 1000, 100, 10, 1};
110 char *p
= buf
+cache
.len
+1+(prec
= timestamp_precision
);
113 /* this is unlikely to happen, but protect anyway */
118 clock
.tv_usec
/= divisor
[prec
];
121 *p
-- = '0'+(clock
.tv_usec
% 10);
126 return cache
.len
+1+timestamp_precision
;
128 buf
[cache
.len
] = '\0';
136 /* Utility routine for current time printing. */
138 time_print(FILE *fp
, struct timestamp_control
*ctl
)
140 if (!ctl
->already_rendered
)
142 ctl
->len
= quagga_timestamp(ctl
->precision
, ctl
->buf
, sizeof(ctl
->buf
));
143 ctl
->already_rendered
= 1;
145 fprintf(fp
, "%s ", ctl
->buf
);
149 /* va_list version of zlog. */
151 vzlog (struct zlog
*zl
, int priority
, const char *format
, va_list args
)
153 struct timestamp_control tsctl
;
154 tsctl
.already_rendered
= 0;
156 /* If zlog is not specified, use default one. */
160 /* When zlog_default is also NULL, use stderr for logging. */
164 time_print(stderr
, &tsctl
);
165 fprintf (stderr
, "%s: ", "unknown");
166 vfprintf (stderr
, format
, args
);
167 fprintf (stderr
, "\n");
170 /* In this case we return at here. */
173 tsctl
.precision
= zl
->timestamp_precision
;
176 if (priority
<= zl
->maxlvl
[ZLOG_DEST_SYSLOG
])
180 vsyslog (priority
|zlog_default
->facility
, format
, ac
);
185 if ((priority
<= zl
->maxlvl
[ZLOG_DEST_FILE
]) && zl
->fp
)
188 time_print (zl
->fp
, &tsctl
);
189 if (zl
->record_priority
)
190 fprintf (zl
->fp
, "%s: ", zlog_priority
[priority
]);
191 fprintf (zl
->fp
, "%s: ", zlog_proto_names
[zl
->protocol
]);
193 vfprintf (zl
->fp
, format
, ac
);
195 fprintf (zl
->fp
, "\n");
200 if (priority
<= zl
->maxlvl
[ZLOG_DEST_STDOUT
])
203 time_print (stdout
, &tsctl
);
204 if (zl
->record_priority
)
205 fprintf (stdout
, "%s: ", zlog_priority
[priority
]);
206 fprintf (stdout
, "%s: ", zlog_proto_names
[zl
->protocol
]);
208 vfprintf (stdout
, format
, ac
);
210 fprintf (stdout
, "\n");
214 /* Terminal monitor. */
215 if (priority
<= zl
->maxlvl
[ZLOG_DEST_MONITOR
])
216 vty_log ((zl
->record_priority
? zlog_priority
[priority
] : NULL
),
217 zlog_proto_names
[zl
->protocol
], format
, &tsctl
, args
);
221 str_append(char *dst
, int len
, const char *src
)
223 while ((len
-- > 0) && *src
)
229 num_append(char *s
, int len
, u_long x
)
235 return str_append(s
,len
,"0");
236 *(t
= &buf
[sizeof(buf
)-1]) = '\0';
237 while (x
&& (t
> buf
))
242 return str_append(s
,len
,t
);
245 #if defined(SA_SIGINFO) || defined(HAVE_STACK_TRACE)
247 hex_append(char *s
, int len
, u_long x
)
253 return str_append(s
,len
,"0");
254 *(t
= &buf
[sizeof(buf
)-1]) = '\0';
255 while (x
&& (t
> buf
))
258 *--t
= ((cc
< 10) ? ('0'+cc
) : ('a'+cc
-10));
261 return str_append(s
,len
,t
);
265 /* Needs to be enhanced to support Solaris. */
274 struct sockaddr_un addr
;
276 if ((fd
= socket(AF_UNIX
,SOCK_DGRAM
,0)) < 0)
278 addr
.sun_family
= AF_UNIX
;
280 #define SYSLOG_SOCKET_PATH _PATH_LOG
282 #define SYSLOG_SOCKET_PATH "/dev/log"
284 s
= str_append(addr
.sun_path
,sizeof(addr
.sun_path
),SYSLOG_SOCKET_PATH
);
285 #undef SYSLOG_SOCKET_PATH
287 if (connect(fd
,(struct sockaddr
*)&addr
,sizeof(addr
)) < 0)
297 syslog_sigsafe(int priority
, const char *msg
, size_t msglen
)
299 static int syslog_fd
= -1;
300 char buf
[sizeof("<1234567890>ripngd[1234567890]: ")+msglen
+50];
303 if ((syslog_fd
< 0) && ((syslog_fd
= syslog_connect()) < 0))
306 #define LOC s,buf+sizeof(buf)-s
308 s
= str_append(LOC
,"<");
309 s
= num_append(LOC
,priority
);
310 s
= str_append(LOC
,">");
311 /* forget about the timestamp, too difficult in a signal handler */
312 s
= str_append(LOC
,zlog_default
->ident
);
313 if (zlog_default
->syslog_options
& LOG_PID
)
315 s
= str_append(LOC
,"[");
316 s
= num_append(LOC
,getpid());
317 s
= str_append(LOC
,"]");
319 s
= str_append(LOC
,": ");
320 s
= str_append(LOC
,msg
);
321 write(syslog_fd
,buf
,s
-buf
);
328 #define CRASHLOG_PREFIX "/var/tmp/quagga."
329 #define CRASHLOG_SUFFIX "crashlog"
330 if (zlog_default
&& zlog_default
->ident
)
332 /* Avoid strlen since it is not async-signal-safe. */
336 for (p
= zlog_default
->ident
, ilen
= 0; *p
; p
++)
339 char buf
[sizeof(CRASHLOG_PREFIX
)+ilen
+sizeof(CRASHLOG_SUFFIX
)+3];
341 #define LOC s,buf+sizeof(buf)-s
342 s
= str_append(LOC
, CRASHLOG_PREFIX
);
343 s
= str_append(LOC
, zlog_default
->ident
);
344 s
= str_append(LOC
, ".");
345 s
= str_append(LOC
, CRASHLOG_SUFFIX
);
348 return open(buf
, O_WRONLY
|O_CREAT
|O_EXCL
, LOGFILE_MASK
);
351 return open(CRASHLOG_PREFIX CRASHLOG_SUFFIX
, O_WRONLY
|O_CREAT
|O_EXCL
,
353 #undef CRASHLOG_SUFFIX
354 #undef CRASHLOG_PREFIX
357 /* Note: the goal here is to use only async-signal-safe functions. */
359 zlog_signal(int signo
, const char *action
361 , siginfo_t
*siginfo
, void *program_counter
366 char buf
[sizeof("DEFAULT: Received signal S at T (si_addr 0xP, PC 0xP); aborting...")+100];
368 char *msgstart
= buf
;
369 #define LOC s,buf+sizeof(buf)-s
374 s
= str_append(LOC
,zlog_proto_names
[zlog_default
->protocol
]);
379 s
= str_append(LOC
,"Received signal ");
380 s
= num_append(LOC
,signo
);
381 s
= str_append(LOC
," at ");
382 s
= num_append(LOC
,now
);
384 s
= str_append(LOC
," (si_addr 0x");
385 s
= hex_append(LOC
,(u_long
)(siginfo
->si_addr
));
388 s
= str_append(LOC
,", PC 0x");
389 s
= hex_append(LOC
,(u_long
)program_counter
);
391 s
= str_append(LOC
,"); ");
392 #else /* SA_SIGINFO */
393 s
= str_append(LOC
,"; ");
394 #endif /* SA_SIGINFO */
395 s
= str_append(LOC
,action
);
396 if (s
< buf
+sizeof(buf
))
399 /* N.B. implicit priority is most severe */
402 #define DUMP(FD) write(FD, buf, s-buf);
403 /* If no file logging configured, try to write to fallback log file. */
404 if ((logfile_fd
>= 0) || ((logfile_fd
= open_crashlog()) >= 0))
410 if (PRI
<= zlog_default
->maxlvl
[ZLOG_DEST_STDOUT
])
412 /* Remove trailing '\n' for monitor and syslog */
414 if (PRI
<= zlog_default
->maxlvl
[ZLOG_DEST_MONITOR
])
415 vty_log_fixed(buf
,s
-buf
);
416 if (PRI
<= zlog_default
->maxlvl
[ZLOG_DEST_SYSLOG
])
417 syslog_sigsafe(PRI
|zlog_default
->facility
,msgstart
,s
-msgstart
);
421 zlog_backtrace_sigsafe(PRI
,
432 /* Log a backtrace using only async-signal-safe functions.
433 Needs to be enhanced to support syslog logging. */
435 zlog_backtrace_sigsafe(int priority
, void *program_counter
)
437 #ifdef HAVE_STACK_TRACE
438 static const char pclabel
[] = "Program counter: ";
442 char *s
, **bt
= NULL
;
443 #define LOC s,buf+sizeof(buf)-s
445 #ifdef HAVE_GLIBC_BACKTRACE
446 if (((size
= backtrace(array
,sizeof(array
)/sizeof(array
[0]))) <= 0) ||
447 ((size_t)size
> sizeof(array
)/sizeof(array
[0])))
451 if (program_counter) \
453 write(FD, pclabel, sizeof(pclabel)-1); \
454 backtrace_symbols_fd(&program_counter, 1, FD); \
456 write(FD, buf, s-buf); \
457 backtrace_symbols_fd(array, size, FD); \
459 #elif defined(HAVE_PRINTSTACK)
461 if (program_counter) \
462 write((FD), pclabel, sizeof(pclabel)-1); \
463 write((FD), buf, s-buf); \
466 #endif /* HAVE_GLIBC_BACKTRACE, HAVE_PRINTSTACK */
469 s
= str_append(LOC
,"Backtrace for ");
470 s
= num_append(LOC
,size
);
471 s
= str_append(LOC
," stack frames:\n");
473 if ((logfile_fd
>= 0) || ((logfile_fd
= open_crashlog()) >= 0))
479 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_STDOUT
])
481 /* Remove trailing '\n' for monitor and syslog */
483 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_MONITOR
])
484 vty_log_fixed(buf
,s
-buf
);
485 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_SYSLOG
])
486 syslog_sigsafe(priority
|zlog_default
->facility
,buf
,s
-buf
);
489 #ifdef HAVE_GLIBC_BACKTRACE
490 bt
= backtrace_symbols(array
, size
);
492 /* Just print the function addresses. */
493 for (i
= 0; i
< size
; i
++)
497 s
= str_append(LOC
, bt
[i
]);
499 s
= str_append(LOC
,"[bt ");
500 s
= num_append(LOC
,i
);
501 s
= str_append(LOC
,"] 0x");
502 s
= hex_append(LOC
,(u_long
)(array
[i
]));
505 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_MONITOR
])
506 vty_log_fixed(buf
,s
-buf
);
507 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_SYSLOG
])
508 syslog_sigsafe(priority
|zlog_default
->facility
,buf
,s
-buf
);
516 #endif /* HAVE_STRACK_TRACE */
520 zlog_backtrace(int priority
)
522 #ifndef HAVE_GLIBC_BACKTRACE
523 zlog(NULL
, priority
, "No backtrace available on this platform.");
529 if (((size
= backtrace(array
,sizeof(array
)/sizeof(array
[0]))) <= 0) ||
530 ((size_t)size
> sizeof(array
)/sizeof(array
[0])))
532 zlog_err("Cannot get backtrace, returned invalid # of frames %d "
533 "(valid range is between 1 and %lu)",
534 size
, (unsigned long)(sizeof(array
)/sizeof(array
[0])));
537 zlog(NULL
, priority
, "Backtrace for %d stack frames:", size
);
538 if (!(strings
= backtrace_symbols(array
, size
)))
540 zlog_err("Cannot get backtrace symbols (out of memory?)");
541 for (i
= 0; i
< size
; i
++)
542 zlog(NULL
, priority
, "[bt %d] %p",i
,array
[i
]);
546 for (i
= 0; i
< size
; i
++)
547 zlog(NULL
, priority
, "[bt %d] %s",i
,strings
[i
]);
550 #endif /* HAVE_GLIBC_BACKTRACE */
554 zlog (struct zlog
*zl
, int priority
, const char *format
, ...)
558 va_start(args
, format
);
559 vzlog (zl
, priority
, format
, args
);
563 #define ZLOG_FUNC(FUNCNAME,PRIORITY) \
565 FUNCNAME(const char *format, ...) \
568 va_start(args, format); \
569 vzlog (NULL, PRIORITY, format, args); \
573 ZLOG_FUNC(zlog_err
, LOG_ERR
)
575 ZLOG_FUNC(zlog_warn
, LOG_WARNING
)
577 ZLOG_FUNC(zlog_info
, LOG_INFO
)
579 ZLOG_FUNC(zlog_notice
, LOG_NOTICE
)
581 ZLOG_FUNC(zlog_debug
, LOG_DEBUG
)
585 #define PLOG_FUNC(FUNCNAME,PRIORITY) \
587 FUNCNAME(struct zlog *zl, const char *format, ...) \
590 va_start(args, format); \
591 vzlog (zl, PRIORITY, format, args); \
595 PLOG_FUNC(plog_err
, LOG_ERR
)
597 PLOG_FUNC(plog_warn
, LOG_WARNING
)
599 PLOG_FUNC(plog_info
, LOG_INFO
)
601 PLOG_FUNC(plog_notice
, LOG_NOTICE
)
603 PLOG_FUNC(plog_debug
, LOG_DEBUG
)
608 _zlog_assert_failed (const char *assertion
, const char *file
,
609 unsigned int line
, const char *function
)
611 /* Force fallback file logging? */
612 if (zlog_default
&& !zlog_default
->fp
&&
613 ((logfile_fd
= open_crashlog()) >= 0) &&
614 ((zlog_default
->fp
= fdopen(logfile_fd
, "w")) != NULL
))
615 zlog_default
->maxlvl
[ZLOG_DEST_FILE
] = LOG_ERR
;
616 zlog(NULL
, LOG_CRIT
, "Assertion `%s' failed in file %s, line %u, function %s",
617 assertion
,file
,line
,(function
? function
: "?"));
618 zlog_backtrace(LOG_CRIT
);
623 /* Open log stream */
625 openzlog (const char *progname
, zlog_proto_t protocol
,
626 int syslog_flags
, int syslog_facility
)
631 zl
= XCALLOC(MTYPE_ZLOG
, sizeof (struct zlog
));
633 zl
->ident
= progname
;
634 zl
->protocol
= protocol
;
635 zl
->facility
= syslog_facility
;
636 zl
->syslog_options
= syslog_flags
;
638 /* Set default logging levels. */
639 for (i
= 0; i
< sizeof(zl
->maxlvl
)/sizeof(zl
->maxlvl
[0]); i
++)
640 zl
->maxlvl
[i
] = ZLOG_DISABLED
;
641 zl
->maxlvl
[ZLOG_DEST_MONITOR
] = LOG_DEBUG
;
642 zl
->default_lvl
= LOG_DEBUG
;
644 openlog (progname
, syslog_flags
, zl
->facility
);
650 closezlog (struct zlog
*zl
)
657 if (zl
->filename
!= NULL
)
660 XFREE (MTYPE_ZLOG
, zl
);
663 /* Called from command.c. */
665 zlog_set_level (struct zlog
*zl
, zlog_dest_t dest
, int log_level
)
670 zl
->maxlvl
[dest
] = log_level
;
674 zlog_set_file (struct zlog
*zl
, const char *filename
, int log_level
)
679 /* There is opend file. */
680 zlog_reset_file (zl
);
682 /* Set default zl. */
687 oldumask
= umask (0777 & ~LOGFILE_MASK
);
688 fp
= fopen (filename
, "a");
694 zl
->filename
= strdup (filename
);
695 zl
->maxlvl
[ZLOG_DEST_FILE
] = log_level
;
697 logfile_fd
= fileno(fp
);
702 /* Reset opend file. */
704 zlog_reset_file (struct zlog
*zl
)
713 zl
->maxlvl
[ZLOG_DEST_FILE
] = ZLOG_DISABLED
;
722 /* Reopen log file. */
724 zlog_rotate (struct zlog
*zl
)
735 level
= zl
->maxlvl
[ZLOG_DEST_FILE
];
736 zl
->maxlvl
[ZLOG_DEST_FILE
] = ZLOG_DISABLED
;
743 oldumask
= umask (0777 & ~LOGFILE_MASK
);
744 zl
->fp
= fopen (zl
->filename
, "a");
749 zlog_err("Log rotate failed: cannot open file %s for append: %s",
750 zl
->filename
, safe_strerror(save_errno
));
753 logfile_fd
= fileno(zl
->fp
);
754 zl
->maxlvl
[ZLOG_DEST_FILE
] = level
;
760 /* Message lookup function. */
762 lookup (const struct message
*mes
, int key
)
764 const struct message
*pnt
;
766 for (pnt
= mes
; pnt
->key
!= 0; pnt
++)
773 /* Older/faster version of message lookup function, but requires caller to pass
774 * in the array size (instead of relying on a 0 key to terminate the search).
776 * The return value is the message string if found, or the 'none' pointer
777 * provided otherwise.
780 mes_lookup (const struct message
*meslist
, int max
, int index
,
781 const char *none
, const char *mesname
)
783 int pos
= index
- meslist
[0].key
;
785 /* first check for best case: index is in range and matches the key
786 * value in that slot.
787 * NB: key numbering might be offset from 0. E.g. protocol constants
790 if ((pos
>= 0) && (pos
< max
)
791 && (meslist
[pos
].key
== index
))
792 return meslist
[pos
].str
;
794 /* fall back to linear search */
798 for (i
= 0; i
< max
; i
++, meslist
++)
800 if (meslist
->key
== index
)
802 const char *str
= (meslist
->str
? meslist
->str
: none
);
804 zlog_debug ("message index %d [%s] found in %s at position %d (max is %d)",
805 index
, str
, mesname
, i
, max
);
810 zlog_err("message index %d not found in %s (max is %d)", index
, mesname
, max
);
815 /* Wrapper around strerror to handle case where it returns NULL. */
817 safe_strerror(int errnum
)
819 const char *s
= strerror(errnum
);
820 return (s
!= NULL
) ? s
: "Unknown error";
823 #define DESC_ENTRY(T) [(T)] = { (T), (#T), '\0' }
824 static const struct zebra_desc_table command_types
[] = {
825 DESC_ENTRY (ZEBRA_INTERFACE_ADD
),
826 DESC_ENTRY (ZEBRA_INTERFACE_DELETE
),
827 DESC_ENTRY (ZEBRA_INTERFACE_ADDRESS_ADD
),
828 DESC_ENTRY (ZEBRA_INTERFACE_ADDRESS_DELETE
),
829 DESC_ENTRY (ZEBRA_INTERFACE_UP
),
830 DESC_ENTRY (ZEBRA_INTERFACE_DOWN
),
831 DESC_ENTRY (ZEBRA_IPV4_ROUTE_ADD
),
832 DESC_ENTRY (ZEBRA_IPV4_ROUTE_DELETE
),
833 DESC_ENTRY (ZEBRA_IPV6_ROUTE_ADD
),
834 DESC_ENTRY (ZEBRA_IPV6_ROUTE_DELETE
),
835 DESC_ENTRY (ZEBRA_REDISTRIBUTE_ADD
),
836 DESC_ENTRY (ZEBRA_REDISTRIBUTE_DELETE
),
837 DESC_ENTRY (ZEBRA_REDISTRIBUTE_DEFAULT_ADD
),
838 DESC_ENTRY (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE
),
839 DESC_ENTRY (ZEBRA_IPV4_NEXTHOP_LOOKUP
),
840 DESC_ENTRY (ZEBRA_IPV6_NEXTHOP_LOOKUP
),
841 DESC_ENTRY (ZEBRA_IPV4_IMPORT_LOOKUP
),
842 DESC_ENTRY (ZEBRA_IPV6_IMPORT_LOOKUP
),
843 DESC_ENTRY (ZEBRA_INTERFACE_RENAME
),
844 DESC_ENTRY (ZEBRA_ROUTER_ID_ADD
),
845 DESC_ENTRY (ZEBRA_ROUTER_ID_DELETE
),
846 DESC_ENTRY (ZEBRA_ROUTER_ID_UPDATE
),
847 DESC_ENTRY (ZEBRA_HELLO
),
851 static const struct zebra_desc_table unknown
= { 0, "unknown", '?' };
853 static const struct zebra_desc_table
*
854 zroute_lookup(u_int zroute
)
858 if (zroute
>= sizeof(route_types
)/sizeof(route_types
[0]))
860 zlog_err("unknown zebra route type: %u", zroute
);
863 if (zroute
== route_types
[zroute
].type
)
864 return &route_types
[zroute
];
865 for (i
= 0; i
< sizeof(route_types
)/sizeof(route_types
[0]); i
++)
867 if (zroute
== route_types
[i
].type
)
869 zlog_warn("internal error: route type table out of order "
870 "while searching for %u, please notify developers", zroute
);
871 return &route_types
[i
];
874 zlog_err("internal error: cannot find route type %u in table!", zroute
);
879 zebra_route_string(u_int zroute
)
881 return zroute_lookup(zroute
)->string
;
885 zebra_route_char(u_int zroute
)
887 return zroute_lookup(zroute
)->chr
;
891 zserv_command_string (unsigned int command
)
893 if (command
>= sizeof(command_types
)/sizeof(command_types
[0]))
895 zlog_err ("unknown zserv command type: %u", command
);
896 return unknown
.string
;
898 return command_types
[command
].string
;
901 #define RTSIZE (sizeof(route_types)/sizeof(route_types[0]))
904 proto_name2num(const char *s
)
908 for (i
=0; i
<RTSIZE
; ++i
)
909 if (strcasecmp(s
, route_types
[i
].string
) == 0)
910 return route_types
[i
].type
;
917 proto_redistnum(int afi
, const char *s
)
924 if (strncmp (s
, "k", 1) == 0)
925 return ZEBRA_ROUTE_KERNEL
;
926 else if (strncmp (s
, "c", 1) == 0)
927 return ZEBRA_ROUTE_CONNECT
;
928 else if (strncmp (s
, "s", 1) == 0)
929 return ZEBRA_ROUTE_STATIC
;
930 else if (strncmp (s
, "r", 1) == 0)
931 return ZEBRA_ROUTE_RIP
;
932 else if (strncmp (s
, "o", 1) == 0)
933 return ZEBRA_ROUTE_OSPF
;
934 else if (strncmp (s
, "i", 1) == 0)
935 return ZEBRA_ROUTE_ISIS
;
936 else if (strncmp (s
, "b", 1) == 0)
937 return ZEBRA_ROUTE_BGP
;
941 if (strncmp (s
, "k", 1) == 0)
942 return ZEBRA_ROUTE_KERNEL
;
943 else if (strncmp (s
, "c", 1) == 0)
944 return ZEBRA_ROUTE_CONNECT
;
945 else if (strncmp (s
, "s", 1) == 0)
946 return ZEBRA_ROUTE_STATIC
;
947 else if (strncmp (s
, "r", 1) == 0)
948 return ZEBRA_ROUTE_RIPNG
;
949 else if (strncmp (s
, "o", 1) == 0)
950 return ZEBRA_ROUTE_OSPF6
;
951 else if (strncmp (s
, "i", 1) == 0)
952 return ZEBRA_ROUTE_ISIS
;
953 else if (strncmp (s
, "b", 1) == 0)
954 return ZEBRA_ROUTE_BGP
;