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
)
154 struct timestamp_control tsctl
;
155 tsctl
.already_rendered
= 0;
157 /* If zlog is not specified, use default one. */
161 /* When zlog_default is also NULL, use stderr for logging. */
165 time_print(stderr
, &tsctl
);
166 fprintf (stderr
, "%s: ", "unknown");
167 vfprintf (stderr
, format
, args
);
168 fprintf (stderr
, "\n");
171 /* In this case we return at here. */
174 tsctl
.precision
= zl
->timestamp_precision
;
177 if (priority
<= zl
->maxlvl
[ZLOG_DEST_SYSLOG
])
181 vsyslog (priority
|zlog_default
->facility
, format
, ac
);
186 sprintf (proto_str
, "%s[%d]: ", zlog_proto_names
[zl
->protocol
], zl
->instance
);
188 sprintf (proto_str
, "%s: ", zlog_proto_names
[zl
->protocol
]);
191 if ((priority
<= zl
->maxlvl
[ZLOG_DEST_FILE
]) && zl
->fp
)
194 time_print (zl
->fp
, &tsctl
);
195 if (zl
->record_priority
)
196 fprintf (zl
->fp
, "%s: ", zlog_priority
[priority
]);
197 fprintf (zl
->fp
, "%s", proto_str
);
199 vfprintf (zl
->fp
, format
, ac
);
201 fprintf (zl
->fp
, "\n");
206 if (priority
<= zl
->maxlvl
[ZLOG_DEST_STDOUT
])
209 time_print (stdout
, &tsctl
);
210 if (zl
->record_priority
)
211 fprintf (stdout
, "%s: ", zlog_priority
[priority
]);
212 fprintf (stdout
, "%s", proto_str
);
214 vfprintf (stdout
, format
, ac
);
216 fprintf (stdout
, "\n");
220 /* Terminal monitor. */
221 if (priority
<= zl
->maxlvl
[ZLOG_DEST_MONITOR
])
222 vty_log ((zl
->record_priority
? zlog_priority
[priority
] : NULL
),
223 proto_str
, format
, &tsctl
, args
);
227 str_append(char *dst
, int len
, const char *src
)
229 while ((len
-- > 0) && *src
)
235 num_append(char *s
, int len
, u_long x
)
241 return str_append(s
,len
,"0");
242 *(t
= &buf
[sizeof(buf
)-1]) = '\0';
243 while (x
&& (t
> buf
))
248 return str_append(s
,len
,t
);
251 #if defined(SA_SIGINFO) || defined(HAVE_STACK_TRACE)
253 hex_append(char *s
, int len
, u_long x
)
259 return str_append(s
,len
,"0");
260 *(t
= &buf
[sizeof(buf
)-1]) = '\0';
261 while (x
&& (t
> buf
))
264 *--t
= ((cc
< 10) ? ('0'+cc
) : ('a'+cc
-10));
267 return str_append(s
,len
,t
);
271 /* Needs to be enhanced to support Solaris. */
280 struct sockaddr_un addr
;
282 if ((fd
= socket(AF_UNIX
,SOCK_DGRAM
,0)) < 0)
284 addr
.sun_family
= AF_UNIX
;
286 #define SYSLOG_SOCKET_PATH _PATH_LOG
288 #define SYSLOG_SOCKET_PATH "/dev/log"
290 s
= str_append(addr
.sun_path
,sizeof(addr
.sun_path
),SYSLOG_SOCKET_PATH
);
291 #undef SYSLOG_SOCKET_PATH
293 if (connect(fd
,(struct sockaddr
*)&addr
,sizeof(addr
)) < 0)
303 syslog_sigsafe(int priority
, const char *msg
, size_t msglen
)
305 static int syslog_fd
= -1;
306 char buf
[sizeof("<1234567890>ripngd[1234567890]: ")+msglen
+50];
309 if ((syslog_fd
< 0) && ((syslog_fd
= syslog_connect()) < 0))
312 #define LOC s,buf+sizeof(buf)-s
314 s
= str_append(LOC
,"<");
315 s
= num_append(LOC
,priority
);
316 s
= str_append(LOC
,">");
317 /* forget about the timestamp, too difficult in a signal handler */
318 s
= str_append(LOC
,zlog_default
->ident
);
319 if (zlog_default
->syslog_options
& LOG_PID
)
321 s
= str_append(LOC
,"[");
322 s
= num_append(LOC
,getpid());
323 s
= str_append(LOC
,"]");
325 s
= str_append(LOC
,": ");
326 s
= str_append(LOC
,msg
);
327 write(syslog_fd
,buf
,s
-buf
);
334 #define CRASHLOG_PREFIX "/var/tmp/quagga."
335 #define CRASHLOG_SUFFIX "crashlog"
336 if (zlog_default
&& zlog_default
->ident
)
338 /* Avoid strlen since it is not async-signal-safe. */
342 for (p
= zlog_default
->ident
, ilen
= 0; *p
; p
++)
345 char buf
[sizeof(CRASHLOG_PREFIX
)+ilen
+sizeof(CRASHLOG_SUFFIX
)+3];
347 #define LOC s,buf+sizeof(buf)-s
348 s
= str_append(LOC
, CRASHLOG_PREFIX
);
349 s
= str_append(LOC
, zlog_default
->ident
);
350 s
= str_append(LOC
, ".");
351 s
= str_append(LOC
, CRASHLOG_SUFFIX
);
354 return open(buf
, O_WRONLY
|O_CREAT
|O_EXCL
, LOGFILE_MASK
);
357 return open(CRASHLOG_PREFIX CRASHLOG_SUFFIX
, O_WRONLY
|O_CREAT
|O_EXCL
,
359 #undef CRASHLOG_SUFFIX
360 #undef CRASHLOG_PREFIX
363 /* Note: the goal here is to use only async-signal-safe functions. */
365 zlog_signal(int signo
, const char *action
367 , siginfo_t
*siginfo
, void *program_counter
372 char buf
[sizeof("DEFAULT: Received signal S at T (si_addr 0xP, PC 0xP); aborting...")+100];
374 char *msgstart
= buf
;
375 #define LOC s,buf+sizeof(buf)-s
380 s
= str_append(LOC
,zlog_proto_names
[zlog_default
->protocol
]);
385 s
= str_append(LOC
,"Received signal ");
386 s
= num_append(LOC
,signo
);
387 s
= str_append(LOC
," at ");
388 s
= num_append(LOC
,now
);
390 s
= str_append(LOC
," (si_addr 0x");
391 s
= hex_append(LOC
,(u_long
)(siginfo
->si_addr
));
394 s
= str_append(LOC
,", PC 0x");
395 s
= hex_append(LOC
,(u_long
)program_counter
);
397 s
= str_append(LOC
,"); ");
398 #else /* SA_SIGINFO */
399 s
= str_append(LOC
,"; ");
400 #endif /* SA_SIGINFO */
401 s
= str_append(LOC
,action
);
402 if (s
< buf
+sizeof(buf
))
405 /* N.B. implicit priority is most severe */
408 #define DUMP(FD) write(FD, buf, s-buf);
409 /* If no file logging configured, try to write to fallback log file. */
410 if ((logfile_fd
>= 0) || ((logfile_fd
= open_crashlog()) >= 0))
416 if (PRI
<= zlog_default
->maxlvl
[ZLOG_DEST_STDOUT
])
418 /* Remove trailing '\n' for monitor and syslog */
420 if (PRI
<= zlog_default
->maxlvl
[ZLOG_DEST_MONITOR
])
421 vty_log_fixed(buf
,s
-buf
);
422 if (PRI
<= zlog_default
->maxlvl
[ZLOG_DEST_SYSLOG
])
423 syslog_sigsafe(PRI
|zlog_default
->facility
,msgstart
,s
-msgstart
);
427 zlog_backtrace_sigsafe(PRI
,
438 /* Log a backtrace using only async-signal-safe functions.
439 Needs to be enhanced to support syslog logging. */
441 zlog_backtrace_sigsafe(int priority
, void *program_counter
)
443 #ifdef HAVE_STACK_TRACE
444 static const char pclabel
[] = "Program counter: ";
448 char *s
, **bt
= NULL
;
449 #define LOC s,buf+sizeof(buf)-s
451 #ifdef HAVE_GLIBC_BACKTRACE
452 size
= backtrace(array
, array_size(array
));
453 if (size
<= 0 || (size_t)size
> array_size(array
))
457 if (program_counter) \
459 write(FD, pclabel, sizeof(pclabel)-1); \
460 backtrace_symbols_fd(&program_counter, 1, FD); \
462 write(FD, buf, s-buf); \
463 backtrace_symbols_fd(array, size, FD); \
465 #elif defined(HAVE_PRINTSTACK)
467 if (program_counter) \
468 write((FD), pclabel, sizeof(pclabel)-1); \
469 write((FD), buf, s-buf); \
472 #endif /* HAVE_GLIBC_BACKTRACE, HAVE_PRINTSTACK */
475 s
= str_append(LOC
,"Backtrace for ");
476 s
= num_append(LOC
,size
);
477 s
= str_append(LOC
," stack frames:\n");
479 if ((logfile_fd
>= 0) || ((logfile_fd
= open_crashlog()) >= 0))
485 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_STDOUT
])
487 /* Remove trailing '\n' for monitor and syslog */
489 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_MONITOR
])
490 vty_log_fixed(buf
,s
-buf
);
491 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_SYSLOG
])
492 syslog_sigsafe(priority
|zlog_default
->facility
,buf
,s
-buf
);
495 #ifdef HAVE_GLIBC_BACKTRACE
496 bt
= backtrace_symbols(array
, size
);
498 /* Just print the function addresses. */
499 for (i
= 0; i
< size
; i
++)
503 s
= str_append(LOC
, bt
[i
]);
505 s
= str_append(LOC
,"[bt ");
506 s
= num_append(LOC
,i
);
507 s
= str_append(LOC
,"] 0x");
508 s
= hex_append(LOC
,(u_long
)(array
[i
]));
511 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_MONITOR
])
512 vty_log_fixed(buf
,s
-buf
);
513 if (priority
<= zlog_default
->maxlvl
[ZLOG_DEST_SYSLOG
])
514 syslog_sigsafe(priority
|zlog_default
->facility
,buf
,s
-buf
);
522 #endif /* HAVE_STRACK_TRACE */
526 zlog_backtrace(int priority
)
528 #ifndef HAVE_GLIBC_BACKTRACE
529 zlog(NULL
, priority
, "No backtrace available on this platform.");
535 size
= backtrace(array
, array_size(array
));
536 if (size
<= 0 || (size_t)size
> array_size(array
))
538 zlog_err("Cannot get backtrace, returned invalid # of frames %d "
539 "(valid range is between 1 and %lu)",
540 size
, (unsigned long)(array_size(array
)));
543 zlog(NULL
, priority
, "Backtrace for %d stack frames:", size
);
544 if (!(strings
= backtrace_symbols(array
, size
)))
546 zlog_err("Cannot get backtrace symbols (out of memory?)");
547 for (i
= 0; i
< size
; i
++)
548 zlog(NULL
, priority
, "[bt %d] %p",i
,array
[i
]);
552 for (i
= 0; i
< size
; i
++)
553 zlog(NULL
, priority
, "[bt %d] %s",i
,strings
[i
]);
556 #endif /* HAVE_GLIBC_BACKTRACE */
560 zlog (struct zlog
*zl
, int priority
, const char *format
, ...)
564 va_start(args
, format
);
565 vzlog (zl
, priority
, format
, args
);
569 #define ZLOG_FUNC(FUNCNAME,PRIORITY) \
571 FUNCNAME(const char *format, ...) \
574 va_start(args, format); \
575 vzlog (NULL, PRIORITY, format, args); \
579 ZLOG_FUNC(zlog_err
, LOG_ERR
)
581 ZLOG_FUNC(zlog_warn
, LOG_WARNING
)
583 ZLOG_FUNC(zlog_info
, LOG_INFO
)
585 ZLOG_FUNC(zlog_notice
, LOG_NOTICE
)
587 ZLOG_FUNC(zlog_debug
, LOG_DEBUG
)
592 _zlog_assert_failed (const char *assertion
, const char *file
,
593 unsigned int line
, const char *function
)
595 /* Force fallback file logging? */
596 if (zlog_default
&& !zlog_default
->fp
&&
597 ((logfile_fd
= open_crashlog()) >= 0) &&
598 ((zlog_default
->fp
= fdopen(logfile_fd
, "w")) != NULL
))
599 zlog_default
->maxlvl
[ZLOG_DEST_FILE
] = LOG_ERR
;
600 zlog(NULL
, LOG_CRIT
, "Assertion `%s' failed in file %s, line %u, function %s",
601 assertion
,file
,line
,(function
? function
: "?"));
602 zlog_backtrace(LOG_CRIT
);
607 /* Open log stream */
609 openzlog (const char *progname
, zlog_proto_t protocol
, u_short instance
,
610 int syslog_flags
, int syslog_facility
)
615 zl
= XCALLOC(MTYPE_ZLOG
, sizeof (struct zlog
));
617 zl
->ident
= progname
;
618 zl
->protocol
= protocol
;
619 zl
->instance
= instance
;
620 zl
->facility
= syslog_facility
;
621 zl
->syslog_options
= syslog_flags
;
623 /* Set default logging levels. */
624 for (i
= 0; i
< array_size(zl
->maxlvl
); i
++)
625 zl
->maxlvl
[i
] = ZLOG_DISABLED
;
626 zl
->maxlvl
[ZLOG_DEST_MONITOR
] = LOG_DEBUG
;
627 zl
->default_lvl
= LOG_DEBUG
;
629 openlog (progname
, syslog_flags
, zl
->facility
);
635 closezlog (struct zlog
*zl
)
642 if (zl
->filename
!= NULL
)
645 XFREE (MTYPE_ZLOG
, zl
);
648 /* Called from command.c. */
650 zlog_set_level (struct zlog
*zl
, zlog_dest_t dest
, int log_level
)
655 zl
->maxlvl
[dest
] = log_level
;
659 zlog_set_file (struct zlog
*zl
, const char *filename
, int log_level
)
664 /* There is opend file. */
665 zlog_reset_file (zl
);
667 /* Set default zl. */
672 oldumask
= umask (0777 & ~LOGFILE_MASK
);
673 fp
= fopen (filename
, "a");
679 zl
->filename
= strdup (filename
);
680 zl
->maxlvl
[ZLOG_DEST_FILE
] = log_level
;
682 logfile_fd
= fileno(fp
);
687 /* Reset opend file. */
689 zlog_reset_file (struct zlog
*zl
)
698 zl
->maxlvl
[ZLOG_DEST_FILE
] = ZLOG_DISABLED
;
707 /* Reopen log file. */
709 zlog_rotate (struct zlog
*zl
)
720 level
= zl
->maxlvl
[ZLOG_DEST_FILE
];
721 zl
->maxlvl
[ZLOG_DEST_FILE
] = ZLOG_DISABLED
;
728 oldumask
= umask (0777 & ~LOGFILE_MASK
);
729 zl
->fp
= fopen (zl
->filename
, "a");
734 zlog_err("Log rotate failed: cannot open file %s for append: %s",
735 zl
->filename
, safe_strerror(save_errno
));
738 logfile_fd
= fileno(zl
->fp
);
739 zl
->maxlvl
[ZLOG_DEST_FILE
] = level
;
745 /* Message lookup function. */
747 lookup (const struct message
*mes
, int key
)
749 const struct message
*pnt
;
751 for (pnt
= mes
; pnt
->key
!= 0; pnt
++)
758 /* Older/faster version of message lookup function, but requires caller to pass
759 * in the array size (instead of relying on a 0 key to terminate the search).
761 * The return value is the message string if found, or the 'none' pointer
762 * provided otherwise.
765 mes_lookup (const struct message
*meslist
, int max
, int index
,
766 const char *none
, const char *mesname
)
768 int pos
= index
- meslist
[0].key
;
770 /* first check for best case: index is in range and matches the key
771 * value in that slot.
772 * NB: key numbering might be offset from 0. E.g. protocol constants
775 if ((pos
>= 0) && (pos
< max
)
776 && (meslist
[pos
].key
== index
))
777 return meslist
[pos
].str
;
779 /* fall back to linear search */
783 for (i
= 0; i
< max
; i
++, meslist
++)
785 if (meslist
->key
== index
)
787 const char *str
= (meslist
->str
? meslist
->str
: none
);
789 zlog_debug ("message index %d [%s] found in %s at position %d (max is %d)",
790 index
, str
, mesname
, i
, max
);
795 zlog_err("message index %d not found in %s (max is %d)", index
, mesname
, max
);
800 /* Wrapper around strerror to handle case where it returns NULL. */
802 safe_strerror(int errnum
)
804 const char *s
= strerror(errnum
);
805 return (s
!= NULL
) ? s
: "Unknown error";
808 #define DESC_ENTRY(T) [(T)] = { (T), (#T), '\0' }
809 static const struct zebra_desc_table command_types
[] = {
810 DESC_ENTRY (ZEBRA_INTERFACE_ADD
),
811 DESC_ENTRY (ZEBRA_INTERFACE_DELETE
),
812 DESC_ENTRY (ZEBRA_INTERFACE_ADDRESS_ADD
),
813 DESC_ENTRY (ZEBRA_INTERFACE_ADDRESS_DELETE
),
814 DESC_ENTRY (ZEBRA_INTERFACE_UP
),
815 DESC_ENTRY (ZEBRA_INTERFACE_DOWN
),
816 DESC_ENTRY (ZEBRA_IPV4_ROUTE_ADD
),
817 DESC_ENTRY (ZEBRA_IPV4_ROUTE_DELETE
),
818 DESC_ENTRY (ZEBRA_IPV6_ROUTE_ADD
),
819 DESC_ENTRY (ZEBRA_IPV6_ROUTE_DELETE
),
820 DESC_ENTRY (ZEBRA_REDISTRIBUTE_ADD
),
821 DESC_ENTRY (ZEBRA_REDISTRIBUTE_DELETE
),
822 DESC_ENTRY (ZEBRA_REDISTRIBUTE_DEFAULT_ADD
),
823 DESC_ENTRY (ZEBRA_REDISTRIBUTE_DEFAULT_DELETE
),
824 DESC_ENTRY (ZEBRA_IPV4_NEXTHOP_LOOKUP
),
825 DESC_ENTRY (ZEBRA_IPV6_NEXTHOP_LOOKUP
),
826 DESC_ENTRY (ZEBRA_IPV4_IMPORT_LOOKUP
),
827 DESC_ENTRY (ZEBRA_IPV6_IMPORT_LOOKUP
),
828 DESC_ENTRY (ZEBRA_INTERFACE_RENAME
),
829 DESC_ENTRY (ZEBRA_ROUTER_ID_ADD
),
830 DESC_ENTRY (ZEBRA_ROUTER_ID_DELETE
),
831 DESC_ENTRY (ZEBRA_ROUTER_ID_UPDATE
),
832 DESC_ENTRY (ZEBRA_HELLO
),
833 DESC_ENTRY (ZEBRA_NEXTHOP_REGISTER
),
834 DESC_ENTRY (ZEBRA_NEXTHOP_UNREGISTER
),
835 DESC_ENTRY (ZEBRA_NEXTHOP_UPDATE
),
836 DESC_ENTRY (ZEBRA_INTERFACE_NBR_ADDRESS_ADD
),
837 DESC_ENTRY (ZEBRA_INTERFACE_NBR_ADDRESS_DELETE
),
838 DESC_ENTRY (ZEBRA_IMPORT_CHECK_UPDATE
),
839 DESC_ENTRY (ZEBRA_INTERFACE_BFD_DEST_DOWN
),
840 DESC_ENTRY (ZEBRA_BFD_DEST_REGISTER
),
841 DESC_ENTRY (ZEBRA_BFD_DEST_DEREGISTER
),
842 DESC_ENTRY (ZEBRA_BFD_DEST_UPDATE
),
846 static const struct zebra_desc_table unknown
= { 0, "unknown", '?' };
848 static const struct zebra_desc_table
*
849 zroute_lookup(u_int zroute
)
853 if (zroute
>= array_size(route_types
))
855 zlog_err("unknown zebra route type: %u", zroute
);
858 if (zroute
== route_types
[zroute
].type
)
859 return &route_types
[zroute
];
860 for (i
= 0; i
< array_size(route_types
); i
++)
862 if (zroute
== route_types
[i
].type
)
864 zlog_warn("internal error: route type table out of order "
865 "while searching for %u, please notify developers", zroute
);
866 return &route_types
[i
];
869 zlog_err("internal error: cannot find route type %u in table!", zroute
);
874 zebra_route_string(u_int zroute
)
876 return zroute_lookup(zroute
)->string
;
880 zebra_route_char(u_int zroute
)
882 return zroute_lookup(zroute
)->chr
;
886 zserv_command_string (unsigned int command
)
888 if (command
>= array_size(command_types
))
890 zlog_err ("unknown zserv command type: %u", command
);
891 return unknown
.string
;
893 return command_types
[command
].string
;
897 proto_name2num(const char *s
)
901 for (i
=0; i
<array_size(route_types
); ++i
)
902 if (strcasecmp(s
, route_types
[i
].string
) == 0)
903 return route_types
[i
].type
;
908 proto_redistnum(int afi
, const char *s
)
915 if (strncmp (s
, "k", 1) == 0)
916 return ZEBRA_ROUTE_KERNEL
;
917 else if (strncmp (s
, "c", 1) == 0)
918 return ZEBRA_ROUTE_CONNECT
;
919 else if (strncmp (s
, "s", 1) == 0)
920 return ZEBRA_ROUTE_STATIC
;
921 else if (strncmp (s
, "r", 1) == 0)
922 return ZEBRA_ROUTE_RIP
;
923 else if (strncmp (s
, "o", 1) == 0)
924 return ZEBRA_ROUTE_OSPF
;
925 else if (strncmp (s
, "i", 1) == 0)
926 return ZEBRA_ROUTE_ISIS
;
927 else if (strncmp (s
, "bg", 2) == 0)
928 return ZEBRA_ROUTE_BGP
;
929 else if (strncmp (s
, "ba", 2) == 0)
930 return ZEBRA_ROUTE_BABEL
;
931 else if (strncmp (s
, "t", 1) == 0)
932 return ZEBRA_ROUTE_TABLE
;
936 if (strncmp (s
, "k", 1) == 0)
937 return ZEBRA_ROUTE_KERNEL
;
938 else if (strncmp (s
, "c", 1) == 0)
939 return ZEBRA_ROUTE_CONNECT
;
940 else if (strncmp (s
, "s", 1) == 0)
941 return ZEBRA_ROUTE_STATIC
;
942 else if (strncmp (s
, "r", 1) == 0)
943 return ZEBRA_ROUTE_RIPNG
;
944 else if (strncmp (s
, "o", 1) == 0)
945 return ZEBRA_ROUTE_OSPF6
;
946 else if (strncmp (s
, "i", 1) == 0)
947 return ZEBRA_ROUTE_ISIS
;
948 else if (strncmp (s
, "bg", 2) == 0)
949 return ZEBRA_ROUTE_BGP
;
950 else if (strncmp (s
, "ba", 2) == 0)
951 return ZEBRA_ROUTE_BABEL
;
952 else if (strncmp (s
, "t", 1) == 0)
953 return ZEBRA_ROUTE_TABLE
;