[bgpd] bug #352: IPv6/Multicast address-family config not written out
[jleu-quagga.git] / lib / if.c
blobdb590f56c27222502fc5ad9cba6360b692f810d5
2 /*
3 * Interface functions.
4 * Copyright (C) 1997, 98 Kunihiro Ishiguro
6 * This file is part of GNU Zebra.
7 *
8 * GNU Zebra is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published
10 * by the Free Software Foundation; either version 2, or (at your
11 * option) any later version.
13 * GNU Zebra is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GNU Zebra; see the file COPYING. If not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #include <zebra.h>
26 #include "linklist.h"
27 #include "vector.h"
28 #include "vty.h"
29 #include "command.h"
30 #include "if.h"
31 #include "sockunion.h"
32 #include "prefix.h"
33 #include "memory.h"
34 #include "table.h"
35 #include "buffer.h"
36 #include "str.h"
37 #include "log.h"
39 /* Master list of interfaces. */
40 struct list *iflist;
42 /* One for each program. This structure is needed to store hooks. */
43 struct if_master
45 int (*if_new_hook) (struct interface *);
46 int (*if_delete_hook) (struct interface *);
47 } if_master;
49 /* Compare interface names, returning an integer greater than, equal to, or
50 * less than 0, (following the strcmp convention), according to the
51 * relationship between ifp1 and ifp2. Interface names consist of an
52 * alphabetic prefix and a numeric suffix. The primary sort key is
53 * lexicographic by name, and then numeric by number. No number sorts
54 * before all numbers. Examples: de0 < de1, de100 < fxp0 < xl0, devpty <
55 * devpty0, de0 < del0
56 */
57 int
58 if_cmp_func (struct interface *ifp1, struct interface *ifp2)
60 unsigned int l1, l2;
61 long int x1, x2;
62 char *p1, *p2;
63 int res;
65 p1 = ifp1->name;
66 p2 = ifp2->name;
68 while (*p1 && *p2) {
69 /* look up to any number */
70 l1 = strcspn(p1, "0123456789");
71 l2 = strcspn(p2, "0123456789");
73 /* name lengths are different -> compare names */
74 if (l1 != l2)
75 return (strcmp(p1, p2));
77 /* Note that this relies on all numbers being less than all letters, so
78 * that de0 < del0.
80 res = strncmp(p1, p2, l1);
82 /* names are different -> compare them */
83 if (res)
84 return res;
86 /* with identical name part, go to numeric part */
87 p1 += l1;
88 p2 += l1;
90 if (!*p1)
91 return -1;
92 if (!*p2)
93 return 1;
95 x1 = strtol(p1, &p1, 10);
96 x2 = strtol(p2, &p2, 10);
98 /* let's compare numbers now */
99 if (x1 < x2)
100 return -1;
101 if (x1 > x2)
102 return 1;
104 /* numbers were equal, lets do it again..
105 (it happens with name like "eth123.456:789") */
107 if (*p1)
108 return 1;
109 if (*p2)
110 return -1;
111 return 0;
114 /* Create new interface structure. */
115 struct interface *
116 if_create (const char *name, int namelen)
118 struct interface *ifp;
120 ifp = XCALLOC (MTYPE_IF, sizeof (struct interface));
121 ifp->ifindex = IFINDEX_INTERNAL;
123 assert (name);
124 assert (namelen <= INTERFACE_NAMSIZ); /* Need space for '\0' at end. */
125 strncpy (ifp->name, name, namelen);
126 ifp->name[namelen] = '\0';
127 if (if_lookup_by_name(ifp->name) == NULL)
128 listnode_add_sort (iflist, ifp);
129 else
130 zlog_err("if_create(%s): corruption detected -- interface with this "
131 "name exists already!", ifp->name);
132 ifp->connected = list_new ();
133 ifp->connected->del = (void (*) (void *)) connected_free;
135 if (if_master.if_new_hook)
136 (*if_master.if_new_hook) (ifp);
138 return ifp;
141 /* Delete interface structure. */
142 void
143 if_delete_retain (struct interface *ifp)
145 if (if_master.if_delete_hook)
146 (*if_master.if_delete_hook) (ifp);
148 /* Free connected address list */
149 list_delete (ifp->connected);
152 /* Delete and free interface structure. */
153 void
154 if_delete (struct interface *ifp)
156 listnode_delete (iflist, ifp);
158 if_delete_retain(ifp);
160 XFREE (MTYPE_IF, ifp);
163 /* Add hook to interface master. */
164 void
165 if_add_hook (int type, int (*func)(struct interface *ifp))
167 switch (type) {
168 case IF_NEW_HOOK:
169 if_master.if_new_hook = func;
170 break;
171 case IF_DELETE_HOOK:
172 if_master.if_delete_hook = func;
173 break;
174 default:
175 break;
179 /* Interface existance check by index. */
180 struct interface *
181 if_lookup_by_index (unsigned int index)
183 struct listnode *node;
184 struct interface *ifp;
186 for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp))
188 if (ifp->ifindex == index)
189 return ifp;
191 return NULL;
194 const char *
195 ifindex2ifname (unsigned int index)
197 struct interface *ifp;
199 return ((ifp = if_lookup_by_index(index)) != NULL) ?
200 ifp->name : "unknown";
203 unsigned int
204 ifname2ifindex (const char *name)
206 struct interface *ifp;
208 return ((ifp = if_lookup_by_name(name)) != NULL) ? ifp->ifindex : 0;
211 /* Interface existance check by interface name. */
212 struct interface *
213 if_lookup_by_name (const char *name)
215 struct listnode *node;
216 struct interface *ifp;
218 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
220 if (strcmp(name, ifp->name) == 0)
221 return ifp;
223 return NULL;
226 struct interface *
227 if_lookup_by_name_len(const char *name, size_t namelen)
229 struct listnode *node;
230 struct interface *ifp;
232 if (namelen > INTERFACE_NAMSIZ)
233 return NULL;
235 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
237 if (!memcmp(name, ifp->name, namelen) && (ifp->name[namelen] == '\0'))
238 return ifp;
240 return NULL;
243 /* Lookup interface by IPv4 address. */
244 struct interface *
245 if_lookup_exact_address (struct in_addr src)
247 struct listnode *node;
248 struct listnode *cnode;
249 struct interface *ifp;
250 struct prefix *p;
251 struct connected *c;
253 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
255 for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
257 p = c->address;
259 if (p && p->family == AF_INET)
261 if (IPV4_ADDR_SAME (&p->u.prefix4, &src))
262 return ifp;
266 return NULL;
269 /* Lookup interface by IPv4 address. */
270 struct interface *
271 if_lookup_address (struct in_addr src)
273 struct listnode *node;
274 struct prefix addr;
275 int bestlen = 0;
276 struct listnode *cnode;
277 struct interface *ifp;
278 struct connected *c;
279 struct interface *match;
281 addr.family = AF_INET;
282 addr.u.prefix4 = src;
283 addr.prefixlen = IPV4_MAX_BITLEN;
285 match = NULL;
287 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
289 for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
291 if (c->address && (c->address->family == AF_INET) &&
292 prefix_match(CONNECTED_PREFIX(c), &addr) &&
293 (c->address->prefixlen > bestlen))
295 bestlen = c->address->prefixlen;
296 match = ifp;
300 return match;
303 /* Get interface by name if given name interface doesn't exist create
304 one. */
305 struct interface *
306 if_get_by_name (const char *name)
308 struct interface *ifp;
310 return ((ifp = if_lookup_by_name(name)) != NULL) ? ifp :
311 if_create(name, strlen(name));
314 struct interface *
315 if_get_by_name_len(const char *name, size_t namelen)
317 struct interface *ifp;
319 return ((ifp = if_lookup_by_name_len(name, namelen)) != NULL) ? ifp :
320 if_create(name, namelen);
323 /* Does interface up ? */
325 if_is_up (struct interface *ifp)
327 return ifp->flags & IFF_UP;
330 /* Is interface running? */
332 if_is_running (struct interface *ifp)
334 return ifp->flags & IFF_RUNNING;
337 /* Is the interface operative, eg. either UP & RUNNING
338 or UP & !ZEBRA_INTERFACE_LINK_DETECTION */
340 if_is_operative (struct interface *ifp)
342 return ((ifp->flags & IFF_UP) &&
343 (ifp->flags & IFF_RUNNING || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION)));
346 /* Is this loopback interface ? */
348 if_is_loopback (struct interface *ifp)
350 /* XXX: Do this better, eg what if IFF_WHATEVER means X on platform M
351 * but Y on platform N?
353 return (ifp->flags & (IFF_LOOPBACK|IFF_NOXMIT|IFF_VIRTUAL));
356 /* Does this interface support broadcast ? */
358 if_is_broadcast (struct interface *ifp)
360 return ifp->flags & IFF_BROADCAST;
363 /* Does this interface support broadcast ? */
365 if_is_pointopoint (struct interface *ifp)
367 return ifp->flags & IFF_POINTOPOINT;
370 /* Does this interface support multicast ? */
372 if_is_multicast (struct interface *ifp)
374 return ifp->flags & IFF_MULTICAST;
377 /* Printout flag information into log */
378 const char *
379 if_flag_dump (unsigned long flag)
381 int separator = 0;
382 static char logbuf[BUFSIZ];
384 #define IFF_OUT_LOG(X,STR) \
385 if (flag & (X)) \
387 if (separator) \
388 strlcat (logbuf, ",", BUFSIZ); \
389 else \
390 separator = 1; \
391 strlcat (logbuf, STR, BUFSIZ); \
394 strlcpy (logbuf, "<", BUFSIZ);
395 IFF_OUT_LOG (IFF_UP, "UP");
396 IFF_OUT_LOG (IFF_BROADCAST, "BROADCAST");
397 IFF_OUT_LOG (IFF_DEBUG, "DEBUG");
398 IFF_OUT_LOG (IFF_LOOPBACK, "LOOPBACK");
399 IFF_OUT_LOG (IFF_POINTOPOINT, "POINTOPOINT");
400 IFF_OUT_LOG (IFF_NOTRAILERS, "NOTRAILERS");
401 IFF_OUT_LOG (IFF_RUNNING, "RUNNING");
402 IFF_OUT_LOG (IFF_NOARP, "NOARP");
403 IFF_OUT_LOG (IFF_PROMISC, "PROMISC");
404 IFF_OUT_LOG (IFF_ALLMULTI, "ALLMULTI");
405 IFF_OUT_LOG (IFF_OACTIVE, "OACTIVE");
406 IFF_OUT_LOG (IFF_SIMPLEX, "SIMPLEX");
407 IFF_OUT_LOG (IFF_LINK0, "LINK0");
408 IFF_OUT_LOG (IFF_LINK1, "LINK1");
409 IFF_OUT_LOG (IFF_LINK2, "LINK2");
410 IFF_OUT_LOG (IFF_MULTICAST, "MULTICAST");
411 IFF_OUT_LOG (IFF_NOXMIT, "NOXMIT");
412 IFF_OUT_LOG (IFF_NORTEXCH, "NORTEXCH");
413 IFF_OUT_LOG (IFF_VIRTUAL, "VIRTUAL");
414 IFF_OUT_LOG (IFF_IPV4, "IPv4");
415 IFF_OUT_LOG (IFF_IPV6, "IPv6");
417 strlcat (logbuf, ">", BUFSIZ);
419 return logbuf;
420 #undef IFF_OUT_LOG
423 /* For debugging */
424 static void
425 if_dump (struct interface *ifp)
427 struct listnode *node;
428 struct connected *c;
430 zlog_info ("Interface %s index %d metric %d mtu %d "
431 #ifdef HAVE_IPV6
432 "mtu6 %d "
433 #endif /* HAVE_IPV6 */
434 "%s",
435 ifp->name, ifp->ifindex, ifp->metric, ifp->mtu,
436 #ifdef HAVE_IPV6
437 ifp->mtu6,
438 #endif /* HAVE_IPV6 */
439 if_flag_dump (ifp->flags));
441 for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, c))
445 /* Interface printing for all interface. */
446 void
447 if_dump_all ()
449 struct listnode *node;
450 void *p;
452 for (ALL_LIST_ELEMENTS_RO (iflist, node, p))
453 if_dump (p);
456 DEFUN (interface_desc,
457 interface_desc_cmd,
458 "description .LINE",
459 "Interface specific description\n"
460 "Characters describing this interface\n")
462 struct interface *ifp;
464 if (argc == 0)
465 return CMD_SUCCESS;
467 ifp = vty->index;
468 if (ifp->desc)
469 XFREE (MTYPE_TMP, ifp->desc);
470 ifp->desc = argv_concat(argv, argc, 0);
472 return CMD_SUCCESS;
475 DEFUN (no_interface_desc,
476 no_interface_desc_cmd,
477 "no description",
478 NO_STR
479 "Interface specific description\n")
481 struct interface *ifp;
483 ifp = vty->index;
484 if (ifp->desc)
485 XFREE (MTYPE_TMP, ifp->desc);
486 ifp->desc = NULL;
488 return CMD_SUCCESS;
491 #ifdef SUNOS_5
492 /* Need to handle upgrade from SUNWzebra to Quagga. SUNWzebra created
493 * a seperate struct interface for each logical interface, so config
494 * file may be full of 'interface fooX:Y'. Solaris however does not
495 * expose logical interfaces via PF_ROUTE, so trying to track logical
496 * interfaces can be fruitless, for that reason Quagga only tracks
497 * the primary IP interface.
499 * We try accomodate SUNWzebra by:
500 * - looking up the interface name, to see whether it exists, if so
501 * its useable
502 * - for protocol daemons, this could only because zebra told us of
503 * the interface
504 * - for zebra, only because it learnt from kernel
505 * - if not:
506 * - search the name to see if it contains a sub-ipif / logical interface
507 * seperator, the ':' char. If it does:
508 * - text up to that char must be the primary name - get that name.
509 * if not:
510 * - no idea, just get the name in its entirety.
512 static struct interface *
513 if_sunwzebra_get (const char *name, size_t nlen)
515 struct interface *ifp;
516 size_t seppos = 0;
518 if ( (ifp = if_lookup_by_name_len(name, nlen)) != NULL)
519 return ifp;
521 /* hunt the primary interface name... */
522 while (seppos < nlen && name[seppos] != ':')
523 seppos++;
525 /* Wont catch seperator as last char, e.g. 'foo0:' but thats invalid */
526 if (seppos < nlen)
527 return if_get_by_name_len (name, seppos);
528 else
529 return if_get_by_name_len (name, nlen);
531 #endif /* SUNOS_5 */
533 DEFUN (interface,
534 interface_cmd,
535 "interface IFNAME",
536 "Select an interface to configure\n"
537 "Interface's name\n")
539 struct interface *ifp;
540 size_t sl;
542 if ((sl = strlen(argv[0])) > INTERFACE_NAMSIZ)
544 vty_out (vty, "%% Interface name %s is invalid: length exceeds "
545 "%d characters%s",
546 argv[0], INTERFACE_NAMSIZ, VTY_NEWLINE);
547 return CMD_WARNING;
550 #ifdef SUNOS_5
551 ifp = if_sunwzebra_get (argv[0], sl);
552 #else
553 ifp = if_get_by_name_len(argv[0], sl);
554 #endif /* SUNOS_5 */
556 vty->index = ifp;
557 vty->node = INTERFACE_NODE;
559 return CMD_SUCCESS;
562 DEFUN_NOSH (no_interface,
563 no_interface_cmd,
564 "no interface IFNAME",
565 NO_STR
566 "Delete a pseudo interface's configuration\n"
567 "Interface's name\n")
569 // deleting interface
570 struct interface *ifp;
572 ifp = if_lookup_by_name (argv[0]);
574 if (ifp == NULL)
576 vty_out (vty, "%% Interface %s does not exist%s", argv[0], VTY_NEWLINE);
577 return CMD_WARNING;
580 if (CHECK_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE))
582 vty_out (vty, "%% Only inactive interfaces can be deleted%s",
583 VTY_NEWLINE);
584 return CMD_WARNING;
587 if_delete(ifp);
589 return CMD_SUCCESS;
592 /* For debug purpose. */
593 DEFUN (show_address,
594 show_address_cmd,
595 "show address",
596 SHOW_STR
597 "address\n")
599 struct listnode *node;
600 struct listnode *node2;
601 struct interface *ifp;
602 struct connected *ifc;
603 struct prefix *p;
605 for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
607 for (ALL_LIST_ELEMENTS_RO (ifp->connected, node2, ifc))
609 p = ifc->address;
611 if (p->family == AF_INET)
612 vty_out (vty, "%s/%d%s", inet_ntoa (p->u.prefix4), p->prefixlen,
613 VTY_NEWLINE);
616 return CMD_SUCCESS;
619 /* Allocate connected structure. */
620 struct connected *
621 connected_new (void)
623 struct connected *new = XMALLOC (MTYPE_CONNECTED, sizeof (struct connected));
624 memset (new, 0, sizeof (struct connected));
625 return new;
628 /* Free connected structure. */
629 void
630 connected_free (struct connected *connected)
632 if (connected->address)
633 prefix_free (connected->address);
635 if (connected->destination)
636 prefix_free (connected->destination);
638 if (connected->label)
639 XFREE (MTYPE_CONNECTED_LABEL, connected->label);
641 XFREE (MTYPE_CONNECTED, connected);
644 /* Print if_addr structure. */
645 static void __attribute__ ((unused))
646 connected_log (struct connected *connected, char *str)
648 struct prefix *p;
649 struct interface *ifp;
650 char logbuf[BUFSIZ];
651 char buf[BUFSIZ];
653 ifp = connected->ifp;
654 p = connected->address;
656 snprintf (logbuf, BUFSIZ, "%s interface %s %s %s/%d ",
657 str, ifp->name, prefix_family_str (p),
658 inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
659 p->prefixlen);
661 p = connected->destination;
662 if (p)
664 strncat (logbuf, inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
665 BUFSIZ - strlen(logbuf));
667 zlog (NULL, LOG_INFO, logbuf);
670 /* If two connected address has same prefix return 1. */
671 static int
672 connected_same_prefix (struct prefix *p1, struct prefix *p2)
674 if (p1->family == p2->family)
676 if (p1->family == AF_INET &&
677 IPV4_ADDR_SAME (&p1->u.prefix4, &p2->u.prefix4))
678 return 1;
679 #ifdef HAVE_IPV6
680 if (p1->family == AF_INET6 &&
681 IPV6_ADDR_SAME (&p1->u.prefix6, &p2->u.prefix6))
682 return 1;
683 #endif /* HAVE_IPV6 */
685 return 0;
688 struct connected *
689 connected_delete_by_prefix (struct interface *ifp, struct prefix *p)
691 struct listnode *node;
692 struct listnode *next;
693 struct connected *ifc;
695 /* In case of same prefix come, replace it with new one. */
696 for (node = listhead (ifp->connected); node; node = next)
698 ifc = listgetdata (node);
699 next = node->next;
701 if (connected_same_prefix (ifc->address, p))
703 listnode_delete (ifp->connected, ifc);
704 return ifc;
707 return NULL;
710 /* Find the IPv4 address on our side that will be used when packets
711 are sent to dst. */
712 struct connected *
713 connected_lookup_address (struct interface *ifp, struct in_addr dst)
715 struct prefix addr;
716 struct listnode *cnode;
717 struct connected *c;
718 struct connected *match;
720 addr.family = AF_INET;
721 addr.u.prefix4 = dst;
722 addr.prefixlen = IPV4_MAX_BITLEN;
724 match = NULL;
726 for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c))
728 if (c->address && (c->address->family == AF_INET) &&
729 prefix_match(CONNECTED_PREFIX(c), &addr) &&
730 (!match || (c->address->prefixlen > match->address->prefixlen)))
731 match = c;
733 return match;
736 struct connected *
737 connected_add_by_prefix (struct interface *ifp, struct prefix *p,
738 struct prefix *destination)
740 struct connected *ifc;
742 /* Allocate new connected address. */
743 ifc = connected_new ();
744 ifc->ifp = ifp;
746 /* Fetch interface address */
747 ifc->address = prefix_new();
748 memcpy (ifc->address, p, sizeof(struct prefix));
750 /* Fetch dest address */
751 if (destination)
753 ifc->destination = prefix_new();
754 memcpy (ifc->destination, destination, sizeof(struct prefix));
757 /* Add connected address to the interface. */
758 listnode_add (ifp->connected, ifc);
759 return ifc;
762 #ifndef HAVE_IF_NAMETOINDEX
763 unsigned int
764 if_nametoindex (const char *name)
766 struct interface *ifp;
768 return ((ifp = if_lookup_by_name_len(name, strnlen(name, IFNAMSIZ))) != NULL)
769 ? ifp->ifindex : 0;
771 #endif
773 #ifndef HAVE_IF_INDEXTONAME
774 char *
775 if_indextoname (unsigned int ifindex, char *name)
777 struct interface *ifp;
779 if (!(ifp = if_lookup_by_index(ifindex)))
780 return NULL;
781 strncpy (name, ifp->name, IFNAMSIZ);
782 return ifp->name;
784 #endif
786 #if 0 /* this route_table of struct connected's is unused
787 * however, it would be good to use a route_table rather than
788 * a list..
790 /* Interface looking up by interface's address. */
791 /* Interface's IPv4 address reverse lookup table. */
792 struct route_table *ifaddr_ipv4_table;
793 /* struct route_table *ifaddr_ipv6_table; */
795 static void
796 ifaddr_ipv4_add (struct in_addr *ifaddr, struct interface *ifp)
798 struct route_node *rn;
799 struct prefix_ipv4 p;
801 p.family = AF_INET;
802 p.prefixlen = IPV4_MAX_PREFIXLEN;
803 p.prefix = *ifaddr;
805 rn = route_node_get (ifaddr_ipv4_table, (struct prefix *) &p);
806 if (rn)
808 route_unlock_node (rn);
809 zlog_info ("ifaddr_ipv4_add(): address %s is already added",
810 inet_ntoa (*ifaddr));
811 return;
813 rn->info = ifp;
816 static void
817 ifaddr_ipv4_delete (struct in_addr *ifaddr, struct interface *ifp)
819 struct route_node *rn;
820 struct prefix_ipv4 p;
822 p.family = AF_INET;
823 p.prefixlen = IPV4_MAX_PREFIXLEN;
824 p.prefix = *ifaddr;
826 rn = route_node_lookup (ifaddr_ipv4_table, (struct prefix *) &p);
827 if (! rn)
829 zlog_info ("ifaddr_ipv4_delete(): can't find address %s",
830 inet_ntoa (*ifaddr));
831 return;
833 rn->info = NULL;
834 route_unlock_node (rn);
835 route_unlock_node (rn);
838 /* Lookup interface by interface's IP address or interface index. */
839 static struct interface *
840 ifaddr_ipv4_lookup (struct in_addr *addr, unsigned int ifindex)
842 struct prefix_ipv4 p;
843 struct route_node *rn;
844 struct interface *ifp;
846 if (addr)
848 p.family = AF_INET;
849 p.prefixlen = IPV4_MAX_PREFIXLEN;
850 p.prefix = *addr;
852 rn = route_node_lookup (ifaddr_ipv4_table, (struct prefix *) &p);
853 if (! rn)
854 return NULL;
856 ifp = rn->info;
857 route_unlock_node (rn);
858 return ifp;
860 else
861 return if_lookup_by_index(ifindex);
863 #endif /* ifaddr_ipv4_table */
865 /* Initialize interface list. */
866 void
867 if_init (void)
869 iflist = list_new ();
870 #if 0
871 ifaddr_ipv4_table = route_table_init ();
872 #endif /* ifaddr_ipv4_table */
874 if (iflist) {
875 iflist->cmp = (int (*)(void *, void *))if_cmp_func;
876 return;
879 memset (&if_master, 0, sizeof if_master);