1 diff --exclude=CVS -uNr zebra/bgpd/bgpd.c zebra-ldp/bgpd/bgpd.c
2 --- zebra/bgpd/bgpd.c 2003-03-14 08:44:35.000000000 -0600
3 +++ zebra-ldp/bgpd/bgpd.c 2003-02-26 22:34:02.000000000 -0600
5 /* BGP process wide configuration. */
6 static struct bgp_master bgp_master;
8 +extern struct in_addr router_id_zebra;
10 /* BGP process wide configuration pointer to export. */
11 struct bgp_master *bm;
17 -/* Unset BGP router identifier. */
19 -bgp_router_id_unset (struct bgp *bgp)
22 - struct listnode *nn;
24 - if (! bgp_config_check (bgp, BGP_CONFIG_ROUTER_ID))
27 - bgp->router_id.s_addr = 0;
28 - bgp_config_unset (bgp, BGP_CONFIG_ROUTER_ID);
30 - /* Clear peer router id configuration. */
31 - LIST_LOOP (bgp->peer, peer, nn)
33 - peer->local_id.s_addr = 0;
36 - /* Set router-id from interface's address. */
37 - bgp_if_update_all ();
39 - /* Reset all BGP sessions to use new router-id. */
40 - LIST_LOOP (bgp->peer, peer, nn)
42 - if (peer->status == Established)
43 - bgp_notify_send (peer, BGP_NOTIFY_CEASE,
44 - BGP_NOTIFY_CEASE_CONFIG_CHANGE);
50 /* BGP's cluster-id control. */
54 bgp = bgp_create (as, name);
55 listnode_add (bm->bgp, bgp);
56 - bgp_if_update_all ();
57 + bgp_router_id_set(bgp, &router_id_zebra);
61 diff --exclude=CVS -uNr zebra/bgpd/bgpd.h zebra-ldp/bgpd/bgpd.h
62 --- zebra/bgpd/bgpd.h 2003-03-14 08:44:35.000000000 -0600
63 +++ zebra-ldp/bgpd/bgpd.h 2003-02-26 22:34:09.000000000 -0600
66 /* BGP router identifier. */
67 struct in_addr router_id;
68 + struct in_addr router_id_static;
70 /* BGP route reflector cluster ID. */
71 struct in_addr cluster_id;
72 diff --exclude=CVS -uNr zebra/bgpd/bgp_vty.c zebra-ldp/bgpd/bgp_vty.c
73 --- zebra/bgpd/bgp_vty.c 2003-03-14 08:44:34.000000000 -0600
74 +++ zebra-ldp/bgpd/bgp_vty.c 2003-02-26 22:33:38.000000000 -0600
76 #include "bgpd/bgp_route.h"
77 #include "bgpd/bgp_zebra.h"
79 +extern struct in_addr router_id_zebra;
81 /* Utility function to get address family from current node. */
83 bgp_node_afi (struct vty *vty)
88 + bgp->router_id_static = id;
89 bgp_router_id_set (bgp, &id);
96 - if (! IPV4_ADDR_SAME (&bgp->router_id, &id))
97 + if (! IPV4_ADDR_SAME (&bgp->router_id_static, &id))
99 vty_out (vty, "%% BGP router-id doesn't match%s", VTY_NEWLINE);
104 - bgp_router_id_unset (bgp);
105 + bgp->router_id_static.s_addr = 0;
106 + bgp_router_id_set (bgp, &router_id_zebra);
110 diff --exclude=CVS -uNr zebra/bgpd/bgp_zebra.c zebra-ldp/bgpd/bgp_zebra.c
111 --- zebra/bgpd/bgp_zebra.c 2003-03-14 08:44:34.000000000 -0600
112 +++ zebra-ldp/bgpd/bgp_zebra.c 2003-02-26 15:47:04.000000000 -0600
115 /* All information about zebra. */
116 static struct zclient *zclient = NULL;
117 +struct in_addr router_id_zebra;
119 -/* Update default router id. */
120 +/* Router-id update message from zebra. */
122 -bgp_if_update (struct interface *ifp)
123 +bgp_router_id_update (int command, struct zclient *zclient, zebra_size_t length)
127 + struct prefix router_id;
129 - struct listnode *nm;
132 - for (cn = listhead (ifp->connected); cn; nextnode (cn))
134 - struct connected *co;
135 - struct in_addr addr;
139 - if (co->address->family == AF_INET)
141 - addr = co->address->u.prefix4;
143 - /* Ignore NET127. */
144 - if (IPV4_NET127 (ntohl (addr.s_addr)))
148 - LIST_LOOP (bm->bgp, bgp, nn)
150 - /* Respect configured router id */
151 - if (! (bgp->config & BGP_CONFIG_ROUTER_ID))
152 - if (ntohl (bgp->router_id.s_addr) < ntohl (addr.s_addr))
154 - bgp->router_id = addr;
155 - LIST_LOOP (bgp->peer, peer, nm)
157 - peer->local_id = addr;
165 + zebra_router_id_update_read(zclient->ibuf,&router_id);
166 + router_id_zebra = router_id.u.prefix4;
169 -bgp_if_update_all ()
172 - struct interface *ifp;
173 + LIST_LOOP (bm->bgp, bgp, nn) {
174 + if (!bgp->router_id_static.s_addr)
175 + bgp_router_id_set (bgp, &router_id.u.prefix4);
178 - for (node = listhead (iflist); node; node = nextnode (node))
180 - ifp = getdata (node);
181 - bgp_if_update (ifp);
187 struct interface *ifp;
189 ifp = zebra_interface_add_read (zclient->ibuf);
190 - bgp_if_update (ifp);
198 - bgp_if_update (ifc->ifp);
200 if (if_is_up (ifc->ifp))
201 bgp_connected_add (ifc);
207 - bgp_if_update (ifc->ifp);
209 if (if_is_up (ifc->ifp))
210 bgp_connected_delete (ifc);
213 /* Set default values. */
214 zclient = zclient_new ();
215 zclient_init (zclient, ZEBRA_ROUTE_BGP);
216 + zclient->router_id_update = bgp_router_id_update;
217 zclient->interface_add = bgp_interface_add;
218 zclient->interface_delete = bgp_interface_delete;
219 zclient->interface_address_add = bgp_interface_address_add;
220 diff --exclude=CVS -uNr zebra/config.h.in zebra-ldp/config.h.in
221 --- zebra/config.h.in 2003-03-14 08:44:35.000000000 -0600
222 +++ zebra-ldp/config.h.in 2003-03-14 08:42:11.000000000 -0600
225 #undef PATH_ZEBRA_PID
228 +#undef PATH_MPLSD_PID
230 /* Define as the return type of signal handlers (`int' or `void'). */
233 diff --exclude=CVS -uNr zebra/configure.ac zebra-ldp/configure.ac
234 --- zebra/configure.ac 2003-03-14 08:44:36.000000000 -0600
235 +++ zebra-ldp/configure.ac 2003-03-14 08:37:17.000000000 -0600
237 [ --disable-ospfd do not build ospfd])
238 AC_ARG_ENABLE(ospf6d,
239 [ --disable-ospf6d do not build ospf6d])
240 +AC_ARG_ENABLE(mplsd,
241 +[ --disable-mplsd do not build mplsd])
242 AC_ARG_ENABLE(bgp-announce,
243 [ --disable-bgp-announce, turn off BGP route announcement])
244 AC_ARG_ENABLE(netlink,
249 +if test "${enable_mpsld}" = "no";then
255 case "${enable_ripngd}" in
256 "yes") RIPNGD="ripngd";;
267 AC_DEFINE_UNQUOTED(PATH_BGPD_PID, "$ac_piddir/bgpd.pid")
268 AC_DEFINE_UNQUOTED(PATH_OSPFD_PID, "$ac_piddir/ospfd.pid")
269 AC_DEFINE_UNQUOTED(PATH_OSPF6D_PID, "$ac_piddir/ospf6d.pid")
270 +AC_DEFINE_UNQUOTED(PATH_MPLSD_PID, "$ac_piddir/mplsd.pid")
273 dnl ---------------------------
275 ac_cv_htonl_works=no)])
276 AC_MSG_RESULT($ac_cv_htonl_works)
278 -AC_OUTPUT(Makefile lib/Makefile zebra/Makefile ripd/Makefile ripngd/Makefile bgpd/Makefile ospfd/Makefile ospf6d/Makefile vtysh/Makefile doc/Makefile)
279 +AC_OUTPUT(Makefile lib/Makefile zebra/Makefile ripd/Makefile ripngd/Makefile bgpd/Makefile ospfd/Makefile ospf6d/Makefile mplsd/Makefile vtysh/Makefile doc/Makefile)
283 diff --exclude=CVS -uNr zebra/lib/command.c zebra-ldp/lib/command.c
284 --- zebra/lib/command.c 2003-03-14 08:44:39.000000000 -0600
285 +++ zebra-ldp/lib/command.c 2003-02-26 22:35:07.000000000 -0600
286 @@ -2080,12 +2080,22 @@
290 + case MPLS_STATIC_NODE:
291 + case MPLS_LDP_NODE:
297 vty->node = CONFIG_NODE;
299 + case MPLS_IN_INSTR_NODE:
300 + case MPLS_OUT_INSTR_NODE:
301 + vty->node = MPLS_STATIC_NODE;
303 + case MPLS_LDP_IF_NODE:
304 + vty->node = INTERFACE_NODE;
309 @@ -2132,6 +2142,12 @@
314 + case MPLS_LDP_NODE:
315 + case MPLS_LDP_IF_NODE:
316 + case MPLS_STATIC_NODE:
317 + case MPLS_IN_INSTR_NODE:
318 + case MPLS_OUT_INSTR_NODE:
320 case KEYCHAIN_KEY_NODE:
322 diff --exclude=CVS -uNr zebra/lib/command.h zebra-ldp/lib/command.h
323 --- zebra/lib/command.h 2003-03-14 08:44:39.000000000 -0600
324 +++ zebra-ldp/lib/command.h 2003-02-26 15:47:28.000000000 -0600
326 AAA_NODE, /* AAA node. */
327 KEYCHAIN_NODE, /* Key-chain node. */
328 KEYCHAIN_KEY_NODE, /* Key-chain key node. */
329 + MPLS_IF_NODE, /* MPLS tunnel interface node */
330 + MPLS_LDP_NODE, /* MPLS LDP protocol node */
331 + MPLS_LDP_IF_NODE, /* MPLS LDP interface node */
332 + MPLS_STATIC_NODE, /* static MPLS protocol mode */
333 + MPLS_IN_INSTR_NODE, /* MPLS in-seg instructions */
334 + MPLS_OUT_INSTR_NODE, /* MPLS out-seg instructions */
335 INTERFACE_NODE, /* Interface mode node. */
336 ZEBRA_NODE, /* zebra connection node. */
337 TABLE_NODE, /* rtm_table selection node. */
338 diff --exclude=CVS -uNr zebra/lib/if.c zebra-ldp/lib/if.c
339 --- zebra/lib/if.c 2003-03-14 08:44:40.000000000 -0600
340 +++ zebra-ldp/lib/if.c 2003-02-26 15:47:30.000000000 -0600
345 +struct interface *if_getfirst()
347 + listnode node = listhead(iflist);
348 + return getdata(node);
351 +struct interface *if_getnext(struct interface *old)
353 + struct interface *ifp;
357 + for (node = listhead(iflist); node; nextnode(node)) {
358 + ifp = getdata(node);
362 + if (ifp->ifindex == old->ifindex) {
369 #ifndef HAVE_IF_INDEXTONAME
371 if_indextoname (unsigned int ifindex, char *name)
372 diff --exclude=CVS -uNr zebra/lib/if.h zebra-ldp/lib/if.h
373 --- zebra/lib/if.h 2003-03-14 08:44:40.000000000 -0600
374 +++ zebra-ldp/lib/if.h 2003-02-26 15:47:30.000000000 -0600
376 struct connected *connected_delete_by_prefix (struct interface *, struct prefix *);
377 int ifc_pointopoint (struct connected *);
379 +struct interface *if_getfirst();
380 +struct interface *if_getnext(struct interface*);
382 #ifndef HAVE_IF_NAMETOINDEX
383 unsigned int if_nametoindex (const char *);
385 diff --exclude=CVS -uNr zebra/lib/linklist.h zebra-ldp/lib/linklist.h
386 --- zebra/lib/linklist.h 2003-03-14 08:44:41.000000000 -0600
387 +++ zebra-ldp/lib/linklist.h 2003-02-26 15:47:31.000000000 -0600
390 #define nextnode(X) ((X) = (X)->next)
391 #define listhead(X) ((X)->head)
392 +#define listtail(X) ((X)->tail)
393 #define listcount(X) ((X)->count)
394 #define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL)
395 #define getdata(X) ((X)->data)
396 diff --exclude=CVS -uNr zebra/lib/log.c zebra-ldp/lib/log.c
397 --- zebra/lib/log.c 2003-03-14 08:44:41.000000000 -0600
398 +++ zebra-ldp/lib/log.c 2003-02-26 15:47:31.000000000 -0600
407 diff --exclude=CVS -uNr zebra/lib/log.h zebra-ldp/lib/log.h
408 --- zebra/lib/log.h 2003-03-14 08:44:41.000000000 -0600
409 +++ zebra-ldp/lib/log.h 2003-02-26 15:47:31.000000000 -0600
418 diff --exclude=CVS -uNr zebra/lib/memory.c zebra-ldp/lib/memory.c
419 --- zebra/lib/memory.c 2003-03-14 08:44:41.000000000 -0600
420 +++ zebra-ldp/lib/memory.c 2003-02-26 15:47:31.000000000 -0600
425 +struct memory_list memory_list_mpls[] =
427 + { MTYPE_MPLS_TOP, "MPLS " },
428 + { MTYPE_MPLS_IF, "MPLS IF " },
429 + { MTYPE_MPLS_STATIC, "MPLS static " },
430 + { MTYPE_MPLS_LDP, "LDP " },
431 + { MTYPE_MPLS_RIB, "RIB " },
435 struct memory_list memory_list_separator[] =
439 show_memory_vty (vty, memory_list_ospf6);
440 show_memory_vty (vty, memory_list_separator);
441 show_memory_vty (vty, memory_list_bgp);
442 + show_memory_vty (vty, memory_list_mpls);
450 +DEFUN (show_memory_mpls,
451 + show_memory_mpls_cmd,
452 + "show memory mpls",
454 + "Memory statistics\n"
457 + show_memory_vty (vty, memory_list_mpls);
458 + return CMD_SUCCESS;
461 DEFUN (show_memory_ospf,
462 show_memory_ospf_cmd,
465 install_element (VIEW_NODE, &show_memory_lib_cmd);
466 install_element (VIEW_NODE, &show_memory_rip_cmd);
467 install_element (VIEW_NODE, &show_memory_bgp_cmd);
468 + install_element (VIEW_NODE, &show_memory_mpls_cmd);
469 install_element (VIEW_NODE, &show_memory_ospf_cmd);
470 install_element (VIEW_NODE, &show_memory_ospf6_cmd);
473 install_element (ENABLE_NODE, &show_memory_lib_cmd);
474 install_element (ENABLE_NODE, &show_memory_rip_cmd);
475 install_element (ENABLE_NODE, &show_memory_bgp_cmd);
476 + install_element (ENABLE_NODE, &show_memory_mpls_cmd);
477 install_element (ENABLE_NODE, &show_memory_ospf_cmd);
478 install_element (ENABLE_NODE, &show_memory_ospf6_cmd);
480 diff --exclude=CVS -uNr zebra/lib/memory.h zebra-ldp/lib/memory.h
481 --- zebra/lib/memory.h 2003-03-14 08:44:41.000000000 -0600
482 +++ zebra-ldp/lib/memory.h 2003-02-26 22:35:13.000000000 -0600
484 MTYPE_COMMUNITY_LIST_ENTRY,
485 MTYPE_COMMUNITY_LIST_CONFIG,
496 diff --exclude=CVS -uNr zebra/lib/table.c zebra-ldp/lib/table.c
497 --- zebra/lib/table.c 2003-03-14 08:44:46.000000000 -0600
498 +++ zebra-ldp/lib/table.c 2003-02-26 15:47:40.000000000 -0600
504 +route_node_lookup2 (struct route_table *table, struct prefix *p)
506 + struct route_node *rn_in, *rn_tmp;
508 + if (!(rn_in = route_node_lookup(table,p))) {
509 + /* walk as far down the tree as we can */
510 + rn_in = table->top;
511 + while (rn_in && rn_in->p.prefixlen <= p->prefixlen &&
512 + prefix_match(&rn_in->p, p)) {
513 + rn_tmp = rn_in->link[check_bit(&p->u.prefix, rn_in->p.prefixlen)];
519 + route_lock_node(rn_in);
521 + /* rn_in is either the actual node or the furthest node in the tree */
522 + /* so get the 'next' one with 'info' */
523 + rn_in = route_next2(rn_in);
526 + if (rn_in && !rn_in->info) {
527 + route_unlock_node(rn_in);
533 /* Add node to routing table. */
535 route_node_get (struct route_table *table, struct prefix *p)
541 +route_next2 (struct route_node *rn_in)
543 + struct route_node *rn = rn_in;
544 + struct route_node *rn2;
546 + rn2 = route_next(rn);
548 + } while(rn && !rn->info);
550 + if (rn && rn->info) {
556 /* Unlock current node and lock next node until limit. */
558 route_next_until (struct route_node *node, struct route_node *limit)
559 diff --exclude=CVS -uNr zebra/lib/table.h zebra-ldp/lib/table.h
560 --- zebra/lib/table.h 2003-03-14 08:44:46.000000000 -0600
561 +++ zebra-ldp/lib/table.h 2003-02-26 15:47:40.000000000 -0600
563 #ifndef _ZEBRA_TABLE_H
564 #define _ZEBRA_TABLE_H
568 /* Routing table top structure. */
572 void route_node_delete (struct route_node *node);
573 struct route_node *route_top (struct route_table *);
574 struct route_node *route_next (struct route_node *);
575 +struct route_node *route_next2 (struct route_node *);
576 struct route_node *route_next_until (struct route_node *, struct route_node *);
577 struct route_node *route_node_get (struct route_table *, struct prefix *);
578 struct route_node *route_node_lookup (struct route_table *, struct prefix *);
579 +struct route_node *route_node_lookup2 (struct route_table *, struct prefix *);
580 struct route_node *route_lock_node (struct route_node *node);
581 struct route_node *route_node_match (struct route_table *, struct prefix *);
582 struct route_node *route_node_match_ipv4 (struct route_table *,
583 diff --exclude=CVS -uNr zebra/lib/thread.c zebra-ldp/lib/thread.c
584 --- zebra/lib/thread.c 2003-03-14 08:44:46.000000000 -0600
585 +++ zebra-ldp/lib/thread.c 2003-02-26 15:47:40.000000000 -0600
586 @@ -117,10 +117,26 @@
587 sizeof (struct thread_master));
590 +static int thread_in_list(struct thread_list *list, struct thread *thread)
594 + for (tt = list->head; tt; tt = tt->next)
604 /* Add a new thread to the list. */
606 thread_list_add (struct thread_list *list, struct thread *thread)
608 + assert(!thread_in_list(list,thread));
611 thread->prev = list->tail;
614 struct thread *point,
615 struct thread *thread)
617 + assert(!thread_in_list(list,thread));
619 thread->next = point;
620 thread->prev = point->prev;
623 static struct thread *
624 thread_list_delete (struct thread_list *list, struct thread *thread)
626 + assert(thread_in_list(list,thread));
629 thread->next->prev = thread->prev;
631 diff --exclude=CVS -uNr zebra/lib/vty.c zebra-ldp/lib/vty.c
632 --- zebra/lib/vty.c 2003-03-14 08:44:47.000000000 -0600
633 +++ zebra-ldp/lib/vty.c 2003-02-26 22:35:32.000000000 -0600
639 + case MPLS_IN_INSTR_NODE:
640 + case MPLS_OUT_INSTR_NODE:
641 + case MPLS_STATIC_NODE:
642 + case MPLS_LDP_NODE:
644 case KEYCHAIN_KEY_NODE:
646 @@ -1028,6 +1033,11 @@
651 + case MPLS_IN_INSTR_NODE:
652 + case MPLS_OUT_INSTR_NODE:
653 + case MPLS_STATIC_NODE:
654 + case MPLS_LDP_NODE:
656 case KEYCHAIN_KEY_NODE:
658 diff --exclude=CVS -uNr zebra/lib/zclient.c zebra-ldp/lib/zclient.c
659 --- zebra/lib/zclient.c 2003-03-14 08:44:47.000000000 -0600
660 +++ zebra-ldp/lib/zclient.c 2003-02-26 22:35:38.000000000 -0600
662 /* We need interface information. */
663 zebra_message_send (zclient, ZEBRA_INTERFACE_ADD);
665 + /* We need router-id information. */
666 + zebra_message_send (zclient, ZEBRA_ROUTER_ID_ADD);
668 /* Flush all redistribute request. */
669 for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
670 if (i != zclient->redist_default && zclient->redist[i])
675 +zapi_ipv4_set_mplsindex (struct zclient *zclient, struct prefix_ipv4 *p,
676 + struct in_addr *nexthop, unsigned int ifindex,
677 + unsigned int mplsindex)
682 + /* Reset stream. */
686 + /* Length place holder. */
687 + stream_putw (s, 0);
689 + /* Put command, type and nexthop. */
690 + stream_putc (s, ZEBRA_IPV4_SET_MPLSINDEX);
692 + /* Put prefix information. */
693 + psize = PSIZE (p->prefixlen);
694 + stream_putc (s, p->prefixlen);
695 + stream_write (s, (u_char *)&p->prefix, psize);
696 + stream_put_in_addr (s, nexthop);
697 + stream_putl (s, ifindex);
698 + stream_putl (s, mplsindex);
700 + /* Put length at the first point of the stream. */
701 + stream_putw_at (s, 0, stream_get_endp (s));
703 + return writen (zclient->sock, s->data, stream_get_endp (s));
707 zapi_ipv4_add (struct zclient *zclient, struct prefix_ipv4 *p,
708 struct zapi_ipv4 *api)
714 +/* Router-id update from zebra daemon. */
716 +zebra_router_id_update_read (struct stream *s, struct prefix *rid)
720 + /* Fetch interface address. */
721 + rid->family = stream_getc (s);
723 + plen = prefix_blen (rid);
724 + stream_get (&rid->u.prefix, s, plen);
725 + rid->prefixlen = stream_getc (s);
728 /* Interface addition from zebra daemon. */
730 zebra_interface_add_read (struct stream *s)
736 +zebra_interface_if_set_value (struct stream *s, struct interface *ifp)
738 + /* Read interface's index. */
739 + ifp->ifindex = stream_getl (s);
741 + /* Read interface's value. */
742 + ifp->flags = stream_getl (s);
743 + ifp->metric = stream_getl (s);
744 + ifp->mtu = stream_getl (s);
745 + ifp->bandwidth = stream_getl (s);
749 zebra_interface_address_add_read (struct stream *s)
755 + case ZEBRA_ROUTER_ID_UPDATE:
756 + if (zclient->router_id_update)
757 + ret = (*zclient->router_id_update) (command, zclient, length);
759 case ZEBRA_INTERFACE_ADD:
760 if (zclient->interface_add)
761 ret = (*zclient->interface_add) (command, zclient, length);
762 diff --exclude=CVS -uNr zebra/lib/zclient.h zebra-ldp/lib/zclient.h
763 --- zebra/lib/zclient.h 2003-03-14 08:44:47.000000000 -0600
764 +++ zebra-ldp/lib/zclient.h 2003-02-26 15:47:42.000000000 -0600
767 /* For struct interface and struct connected. */
771 /* For input/output buffer to zebra. */
772 #define ZEBRA_MAX_PACKET_SIZ 4096
774 u_char default_information;
776 /* Pointer to the callback functions. */
777 + int (*router_id_update) (int, struct zclient *, zebra_size_t);
778 int (*interface_add) (int, struct zclient *, zebra_size_t);
779 int (*interface_delete) (int, struct zclient *, zebra_size_t);
780 int (*interface_up) (int, struct zclient *, zebra_size_t);
785 +int zapi_ipv4_set_mplsindex (struct zclient *, struct prefix_ipv4 *,
786 + struct in_addr*, unsigned int, unsigned int);
789 zapi_ipv4_add (struct zclient *, struct prefix_ipv4 *, struct zapi_ipv4 *);
793 struct interface *zebra_interface_add_read (struct stream *);
794 struct interface *zebra_interface_state_read (struct stream *s);
795 +void zebra_interface_if_set_value (struct stream *, struct interface *);
796 struct connected *zebra_interface_address_add_read (struct stream *);
797 struct connected *zebra_interface_address_delete_read (struct stream *);
798 +void zebra_router_id_update_read (struct stream *s, struct prefix *rid);
802 /* IPv6 prefix add and delete function prototype. */
803 diff --exclude=CVS -uNr zebra/lib/zebra.h zebra-ldp/lib/zebra.h
804 --- zebra/lib/zebra.h 2003-03-14 08:44:47.000000000 -0600
805 +++ zebra-ldp/lib/zebra.h 2003-03-13 23:28:36.000000000 -0600
807 #define ZEBRA_IPV6_NEXTHOP_LOOKUP 16
808 #define ZEBRA_IPV4_IMPORT_LOOKUP 17
809 #define ZEBRA_IPV6_IMPORT_LOOKUP 18
810 -#define ZEBRA_MESSAGE_MAX 19
811 +#define ZEBRA_ROUTER_ID_ADD 19
812 +#define ZEBRA_ROUTER_ID_DELETE 20
813 +#define ZEBRA_ROUTER_ID_UPDATE 21
814 +#define ZEBRA_IPV4_SET_MPLSINDEX 22
815 +#define ZEBRA_MESSAGE_MAX 23
817 /* Zebra route's types. */
818 #define ZEBRA_ROUTE_SYSTEM 0
820 #define ZEBRA_ROUTE_OSPF 6
821 #define ZEBRA_ROUTE_OSPF6 7
822 #define ZEBRA_ROUTE_BGP 8
823 -#define ZEBRA_ROUTE_MAX 9
824 +#define ZEBRA_ROUTE_MPLS 9
825 +#define ZEBRA_ROUTE_MAX 10
827 /* Zebra's family types. */
828 #define ZEBRA_FAMILY_IPV4 1
830 #define ZEBRA_FLAG_SELECTED 0x10
831 #define ZEBRA_FLAG_CHANGED 0x20
832 #define ZEBRA_FLAG_STATIC 0x40
833 +#define ZEBRA_FLAG_MPLS_CHANGED 0x80
835 /* Zebra nexthop flags. */
836 #define ZEBRA_NEXTHOP_IFINDEX 1
837 diff --exclude=CVS -uNr zebra/Makefile.am zebra-ldp/Makefile.am
838 --- zebra/Makefile.am 2003-03-14 08:44:20.000000000 -0600
839 +++ zebra-ldp/Makefile.am 2003-02-26 15:46:34.000000000 -0600
841 ## Process this file with automake to produce Makefile.in.
843 -SUBDIRS = lib @ZEBRA@ @BGPD@ @RIPD@ @RIPNGD@ @OSPFD@ @OSPF6D@ @VTYSH@ doc
844 +SUBDIRS = lib @ZEBRA@ @BGPD@ @RIPD@ @RIPNGD@ @OSPFD@ @OSPF6D@ @MPLSD@ @VTYSH@ doc
846 EXTRA_DIST = aclocal.m4 SERVICES TODO REPORTING-BUGS vtysh/Makefile.in \
847 vtysh/Makefile.am update-autotools
848 diff --exclude=CVS -uNr zebra/mplsd/create-links zebra-ldp/mplsd/create-links
849 --- zebra/mplsd/create-links 1969-12-31 18:00:00.000000000 -0600
850 +++ zebra-ldp/mplsd/create-links 2003-02-26 15:47:42.000000000 -0600
854 +SRC=/home/jleu/personal/p4all/ldp-portable
856 +ln -s $SRC/ldp/ldp_addr.c
857 +ln -s $SRC/ldp/ldp_addr.h
858 +ln -s $SRC/ldp/ldp_adj.c
859 +ln -s $SRC/ldp/ldp_adj.h
860 +ln -s $SRC/ldp/ldp_attr.c
861 +ln -s $SRC/ldp/ldp_attr.h
862 +ln -s $SRC/ldp/ldp_buf.c
863 +ln -s $SRC/ldp/ldp_buf.h
864 +ln -s $SRC/ldp/ldp_cfg.c
865 +ln -s $SRC/ldp/ldp_cfg.h
866 +ln -s $SRC/ldp/ldp_defaults.h
867 +ln -s $SRC/ldp/ldp_entity.c
868 +ln -s $SRC/ldp/ldp_entity.h
869 +ln -s $SRC/ldp/ldp_fec.c
870 +ln -s $SRC/ldp/ldp_fec.h
871 +ln -s $SRC/ldp/ldp_global.c
872 +ln -s $SRC/ldp/ldp_global.h
873 +ln -s $SRC/ldp/ldp_hello.c
874 +ln -s $SRC/ldp/ldp_hello.h
875 +ln -s $SRC/ldp/ldp_hop.c
876 +ln -s $SRC/ldp/ldp_hop.h
877 +ln -s $SRC/ldp/ldp_hop_list.c
878 +ln -s $SRC/ldp/ldp_hop_list.h
879 +ln -s $SRC/ldp/ldp_if.c
880 +ln -s $SRC/ldp/ldp_if.h
881 +ln -s $SRC/ldp/ldp_inet_addr.c
882 +ln -s $SRC/ldp/ldp_inet_addr.h
883 +ln -s $SRC/ldp/ldp_init.c
884 +ln -s $SRC/ldp/ldp_init.h
885 +ln -s $SRC/ldp/ldp_inlabel.c
886 +ln -s $SRC/ldp/ldp_inlabel.h
887 +ln -s $SRC/ldp/ldp_keepalive.c
888 +ln -s $SRC/ldp/ldp_keepalive.h
889 +ln -s $SRC/ldp/ldp_label_abort.c
890 +ln -s $SRC/ldp/ldp_label_abort.h
891 +ln -s $SRC/ldp/ldp_label_mapping.c
892 +ln -s $SRC/ldp/ldp_label_mapping.h
893 +ln -s $SRC/ldp/ldp_label_rel_with.c
894 +ln -s $SRC/ldp/ldp_label_rel_with.h
895 +ln -s $SRC/ldp/ldp_label_request.c
896 +ln -s $SRC/ldp/ldp_label_request.h
897 +ln -s $SRC/ldp/ldp_mesg.c
898 +ln -s $SRC/ldp/ldp_mesg.h
899 +ln -s $SRC/ldp/ldp_nortel.c
900 +ln -s $SRC/ldp/ldp_nortel.h
901 +ln -s $SRC/ldp/ldp_notif.c
902 +ln -s $SRC/ldp/ldp_notif.h
903 +ln -s $SRC/ldp/ldp_outlabel.c
904 +ln -s $SRC/ldp/ldp_outlabel.h
905 +ln -s $SRC/ldp/ldp_pdu.h
906 +ln -s $SRC/ldp/ldp_pdu_setup.c
907 +ln -s $SRC/ldp/ldp_pdu_setup.h
908 +ln -s $SRC/ldp/ldp_peer.c
909 +ln -s $SRC/ldp/ldp_peer.h
910 +ln -s $SRC/ldp/ldp_resource.c
911 +ln -s $SRC/ldp/ldp_resource.h
912 +ln -s $SRC/ldp/ldp_session.c
913 +ln -s $SRC/ldp/ldp_session.h
914 +ln -s $SRC/ldp/ldp_state_funcs.c
915 +ln -s $SRC/ldp/ldp_state_machine.c
916 +ln -s $SRC/ldp/ldp_state_machine.h
917 +ln -s $SRC/ldp/ldp_struct.h
918 +ln -s $SRC/ldp/ldp_tunnel.c
919 +ln -s $SRC/ldp/ldp_tunnel.h
921 +ln -s $SRC/lsr/lsr_cfg.c
922 +ln -s $SRC/lsr/lsr_cfg.h
923 +ln -s $SRC/lsr/lsr_defaults.h
924 +ln -s $SRC/lsr/lsr_global.c
925 +ln -s $SRC/lsr/lsr_global.h
926 +ln -s $SRC/lsr/lsr_if.c
927 +ln -s $SRC/lsr/lsr_if.h
928 +ln -s $SRC/lsr/lsr_insegment.c
929 +ln -s $SRC/lsr/lsr_insegment.h
930 +ln -s $SRC/lsr/lsr_labelmanager.c
931 +ln -s $SRC/lsr/lsr_labelmanager.h
932 +ln -s $SRC/lsr/lsr_outsegment.c
933 +ln -s $SRC/lsr/lsr_outsegment.h
934 +ln -s $SRC/lsr/lsr_struct.h
935 +ln -s $SRC/lsr/lsr_xconnect.c
936 +ln -s $SRC/lsr/lsr_xconnect.h
937 +ln -s $SRC/lsr/lsr_ftn.c
938 +ln -s $SRC/lsr/lsr_ftn.h
940 +ln -s $SRC/common/mpls_struct.h
941 +ln -s $SRC/common/mpls_assert.h
942 +ln -s $SRC/common/mpls_fib_impl.h
943 +ln -s $SRC/common/mpls_ifmgr_impl.h
944 +ln -s $SRC/common/mpls_mm_impl.h
945 +ln -s $SRC/common/mpls_mpls_impl.h
946 +ln -s $SRC/common/mpls_policy_impl.h
947 +ln -s $SRC/common/mpls_refcnt.h
948 +ln -s $SRC/common/mpls_socket_impl.h
949 +ln -s $SRC/common/mpls_timer_impl.h
950 +ln -s $SRC/common/mpls_trace_impl.h
951 +ln -s $SRC/common/mpls_tree_impl.h
952 +ln -s $SRC/common/mpls_list.h
953 +ln -s $SRC/common/mpls_lock_impl.h
954 +ln -s $SRC/common/mpls_compare.h
955 +ln -s $SRC/common/mpls_compare.c
956 diff --exclude=CVS -uNr zebra/mplsd/delete-links zebra-ldp/mplsd/delete-links
957 --- zebra/mplsd/delete-links 1969-12-31 18:00:00.000000000 -0600
958 +++ zebra-ldp/mplsd/delete-links 2003-02-26 15:47:43.000000000 -0600
972 +rm -f ldp_defaults.h
983 +rm -f ldp_hop_list.c
984 +rm -f ldp_hop_list.h
987 +rm -f ldp_inet_addr.c
988 +rm -f ldp_inet_addr.h
993 +rm -f ldp_keepalive.c
994 +rm -f ldp_keepalive.h
995 +rm -f ldp_label_abort.c
996 +rm -f ldp_label_abort.h
997 +rm -f ldp_label_mapping.c
998 +rm -f ldp_label_mapping.h
999 +rm -f ldp_label_rel_with.c
1000 +rm -f ldp_label_rel_with.h
1001 +rm -f ldp_label_request.c
1002 +rm -f ldp_label_request.h
1009 +rm -f ldp_outlabel.c
1010 +rm -f ldp_outlabel.h
1012 +rm -f ldp_pdu_setup.c
1013 +rm -f ldp_pdu_setup.h
1016 +rm -f ldp_resource.c
1017 +rm -f ldp_resource.h
1018 +rm -f ldp_session.c
1019 +rm -f ldp_session.h
1020 +rm -f ldp_state_funcs.c
1021 +rm -f ldp_state_machine.c
1022 +rm -f ldp_state_machine.h
1029 +rm -f lsr_defaults.h
1034 +rm -f lsr_insegment.c
1035 +rm -f lsr_insegment.h
1036 +rm -f lsr_labelmanager.c
1037 +rm -f lsr_labelmanager.h
1038 +rm -f lsr_outsegment.c
1039 +rm -f lsr_outsegment.h
1041 +rm -f lsr_xconnect.c
1042 +rm -f lsr_xconnect.h
1046 +rm -f mpls_struct.h
1047 +rm -f mpls_assert.h
1048 +rm -f mpls_fib_impl.h
1049 +rm -f mpls_ifmgr_impl.h
1050 +rm -f mpls_mm_impl.h
1051 +rm -f mpls_mpls_impl.h
1052 +rm -f mpls_policy_impl.h
1053 +rm -f mpls_refcnt.h
1054 +rm -f mpls_socket_impl.h
1055 +rm -f mpls_timer_impl.h
1056 +rm -f mpls_trace_impl.h
1057 +rm -f mpls_tree_impl.h
1059 +rm -f mpls_lock_impl.h
1060 +rm -f mpls_compare.h
1061 +rm -f mpls_compare.c
1062 diff --exclude=CVS -uNr zebra/mplsd/impl_fib.c zebra-ldp/mplsd/impl_fib.c
1063 --- zebra/mplsd/impl_fib.c 1969-12-31 18:00:00.000000000 -0600
1064 +++ zebra-ldp/mplsd/impl_fib.c 2003-02-26 15:47:43.000000000 -0600
1067 +#include "prefix.h"
1070 +#include "memory.h"
1073 +#include "mpls_compare.h"
1076 +#include "ldp_struct.h"
1078 +void mpls_fib_close(mpls_fib_handle handle)
1082 +void mpls_fib_update_close(mpls_fib_handle handle)
1086 +mpls_fib_handle mpls_fib_open(const mpls_instance_handle handle,
1087 + const mpls_cfg_handle cfg, ldp_fib_callback callback)
1089 + struct mpls *mpls = mpls_get();
1090 + mpls->fib_callback = callback;
1094 +void mpls_fec2zebra_prefix(mpls_fec *lp, struct prefix *p)
1096 + switch(lp->type) {
1097 + case MPLS_FEC_PREFIX:
1098 + p->prefixlen = lp->u.prefix.length;
1099 + p->u.prefix4.s_addr = htonl(lp->u.prefix.network.u.ipv4);
1101 + case MPLS_FEC_HOST:
1102 + p->prefixlen = 32;
1103 + p->u.prefix4.s_addr = htonl(lp->u.host.u.ipv4);
1110 +void zebra_prefix2mpls_fec(struct prefix *p, struct mpls_nexthop *nh, mpls_fec *fec)
1112 + fec->u.prefix.length = p->prefixlen;
1113 + fec->type = MPLS_FEC_PREFIX;
1114 + fec->u.prefix.network.type = MPLS_FAMILY_IPV4;
1115 + fec->u.prefix.network.u.ipv4 = ntohl(p->u.prefix4.s_addr);
1116 + memcpy(&fec->nh, nh, sizeof(struct mpls_nexthop));
1119 +int list2fec(struct list *list, struct prefix *p, mpls_fec *entry, int num) {
1120 + struct listnode* ln;
1121 + struct mpls_nexthop* head;
1122 + struct mpls_nexthop* nh;
1125 + head = listhead(list) ? getdata(listhead(list)) : NULL;
1127 + LIST_LOOP(list, nh, ln) {
1128 + if (head->distance == nh->distance && head->metric == nh->metric) {
1129 + zebra_prefix2mpls_fec(p,nh,&entry[count]);
1134 + if (count >= num) {
1141 +int mpls_fib_get_route(mpls_fib_handle handle, const int num,
1142 + const mpls_fec * fec, mpls_fec * entry)
1145 + struct route_node *rn;
1148 + mpls_fec2zebra_prefix((mpls_fec*)fec,&p);
1150 + if ((rn = route_node_lookup(handle->table,&p))) {
1151 + count = list2fec((struct list*)rn->info,&rn->p,entry,num);
1152 + route_unlock_node(rn);
1158 +int mpls_fib_get_best_route(mpls_fib_handle handle, const int num,
1159 + const mpls_fec * dest, mpls_fec * entry)
1161 + struct route_node *rn;
1166 + mpls_fec2zebra_prefix((mpls_fec*)dest,&p);
1168 + for (len = 32; len >= 0 ; len--) {
1169 + p.prefixlen = len;
1170 + if ((rn = route_node_lookup(handle->table,&p))) {
1171 + count = list2fec((struct list*)rn->info,&rn->p,entry,num);
1172 + route_unlock_node(rn);
1178 +mpls_return_enum mpls_fib_getfirst_route(mpls_fib_handle handle, mpls_fec * dest)
1180 + struct route_node *rn;
1182 + if ((rn = route_top(handle->table))) {
1184 + rn = route_next2(rn);
1188 + list2fec((struct list*)rn->info,&rn->p,dest,1);
1189 + route_unlock_node(rn);
1190 + return MPLS_SUCCESS;
1194 + return MPLS_FAILURE;
1197 +mpls_return_enum mpls_fib_getnext_route(mpls_fib_handle handle, mpls_fec * dest)
1199 + struct route_node *rn_in;
1200 + struct listnode* ln;
1201 + struct list* list;
1202 + struct mpls_nexthop* nh;
1206 + mpls_fec2zebra_prefix(dest,&p);
1208 + if (!(rn_in = route_node_lookup2(handle->table,&p))) {
1209 + return MPLS_FAILURE;
1212 + list = (struct list*)rn_in->info;
1213 + LIST_LOOP(list, nh, ln) {
1215 + zebra_prefix2mpls_fec(&p, nh, dest);
1216 + route_unlock_node(rn_in);
1217 + return MPLS_SUCCESS;
1219 + if (!mpls_nexthop_compare(nh,&dest->nh)) {
1224 + if ((rn_in = route_next2(rn_in))) {
1225 + list2fec((struct list*)rn_in->info,&rn_in->p,dest,1);
1226 + route_unlock_node(rn_in);
1227 + return MPLS_SUCCESS;
1230 + return MPLS_FAILURE;
1233 +static struct mpls_nexthop* mpls_nexthop_create(struct mpls_nexthop* dup) {
1234 + struct mpls_nexthop *nh;
1235 + nh = XMALLOC (MTYPE_MPLS_TOP, sizeof (struct mpls_nexthop));
1237 + memcpy(nh, dup, sizeof(struct mpls_nexthop));
1239 + memset(nh, 0, sizeof(struct mpls_nexthop));
1244 +static void mpls_nexthop_delete(void* v) {
1245 + XFREE(MTYPE_MPLS_TOP, v);
1248 +static int local_mpls_nexthop_compare(void* a,void* b) {
1249 + return mpls_nexthop_compare((struct mpls_nexthop*)a,(struct mpls_nexthop*)b);
1252 +void ldp_ipv4_add(struct mpls *mpls, struct prefix_ipv4 *p,
1253 + struct mpls_nexthop *nexthop) {
1255 + struct route_node *rn;
1256 + struct list *list;
1257 + struct mpls_nexthop *active;
1258 + struct mpls_nexthop *head;
1259 + struct mpls_nexthop *nh = mpls_nexthop_create(nexthop);
1261 + if ((rn = route_node_lookup(mpls->table,(struct prefix*)p))) {
1262 + list = (struct list*)rn->info;
1263 + active = listhead(list) ? getdata(listhead(list)) : NULL;
1265 + rn = route_node_get(mpls->table,(struct prefix*)p);
1266 + route_lock_node(rn);
1267 + list = list_new();
1270 + list->cmp = local_mpls_nexthop_compare;
1272 + listnode_add_sort(list, nh);
1273 + head = getdata(listhead(list));
1275 + /* if the new route isn't the active route, do nothing */
1278 + route_unlock_node(rn);
1283 + /* we only get here is the new nh is the active one, which means we need
1284 + * to delete the only nh, THEN send in the new nh */
1285 + if (mpls->ldp && mpls->fib_callback) {
1286 + memset(&dest,0,sizeof(dest));
1288 + /* if their was a previouly active route, delete it */
1290 + zebra_prefix2mpls_fec((struct prefix*)p, active, &dest);
1291 + mpls->fib_callback(mpls->ldp->h, MPLS_UPDATE_DEL, &dest);
1294 + /* add the new route */
1295 + zebra_prefix2mpls_fec((struct prefix*)p, nh, &dest);
1296 + mpls->fib_callback(mpls->ldp->h, MPLS_UPDATE_ADD, &dest);
1299 + route_unlock_node(rn);
1303 +void ldp_ipv4_delete(struct mpls* mpls, struct prefix_ipv4* p,
1304 + struct mpls_nexthop* nexthop) {
1305 + struct route_node* rn;
1306 + struct list* list = NULL;
1307 + struct listnode* ln;
1308 + struct mpls_nexthop *active = NULL;
1309 + struct mpls_nexthop *head = NULL;
1310 + struct mpls_nexthop* nh = NULL;
1313 + if ((rn = route_node_lookup(mpls->table,(struct prefix*)p))) {
1314 + list = (struct list*)rn->info;
1315 + active = listhead(list) ? getdata(listhead(list)) : NULL;
1316 + LIST_LOOP(list, nh, ln) {
1317 + /* if they match, remove it */
1318 + if (!mpls_nexthop_compare(nh, nexthop)) {
1319 + list_delete_node(list, ln);
1323 + if (list_isempty(list)) {
1325 + route_unlock_node(rn);
1331 + head = (list && listhead(list)) ? getdata(listhead(list)) : NULL;
1334 + /* if we do not know about the route, do nothing */
1336 + route_unlock_node(rn);
1341 + /* otherwise, if we have a callback */
1342 + if (mpls->ldp && mpls->fib_callback) {
1343 + memset(&dest,0,sizeof(dest));
1345 + /* did we we just removed the active nexthop */
1346 + if (active == nh) {
1347 + /* if so send in a delete */
1348 + zebra_prefix2mpls_fec((struct prefix*)p, nexthop, &dest);
1349 + mpls->fib_callback(mpls->ldp->h, MPLS_UPDATE_DEL, &dest);
1350 + mpls_nexthop_delete(nh);
1352 + /* is there a active nexthop? */
1354 + /* if so, send in a add */
1355 + zebra_prefix2mpls_fec((struct prefix*)p, head, &dest);
1356 + mpls->fib_callback(mpls->ldp->h, MPLS_UPDATE_ADD, &dest);
1360 + route_unlock_node(rn);
1362 diff --exclude=CVS -uNr zebra/mplsd/impl_fib.h zebra-ldp/mplsd/impl_fib.h
1363 --- zebra/mplsd/impl_fib.h 1969-12-31 18:00:00.000000000 -0600
1364 +++ zebra-ldp/mplsd/impl_fib.h 2003-02-26 15:47:43.000000000 -0600
1366 +#ifndef LDP_IMPL_FIB_H
1367 +#define LDP_IMPL_FIB_H
1371 +#include "ldp_struct.h"
1374 +extern void mpls_fec2zebra_prefix(mpls_fec *lp, struct prefix *p);
1375 +extern void zebra_prefix2mpls_fec(struct prefix *p, mpls_fec *lp);
1376 +void ldp_ipv4_add(struct mpls *mpls, struct prefix_ipv4 *p,
1377 + struct mpls_nexthop *nexthop);
1378 +void ldp_ipv4_delete(struct mpls *mpls, struct prefix_ipv4 *p,
1379 + struct mpls_nexthop *nexthop);
1382 diff --exclude=CVS -uNr zebra/mplsd/impl_ifmgr.c zebra-ldp/mplsd/impl_ifmgr.c
1383 --- zebra/mplsd/impl_ifmgr.c 1969-12-31 18:00:00.000000000 -0600
1384 +++ zebra-ldp/mplsd/impl_ifmgr.c 2003-02-26 15:47:43.000000000 -0600
1390 +#include "ldp_struct.h"
1394 +static ldp_ifmgr_callback ifmgr_callback;
1395 +static int opened = 0;
1397 +static unsigned int mask_array[33] = { 0x00000000,
1398 + 0x80000000, 0xC0000000, 0xE0000000, 0xF0000000,
1399 + 0xF8000000, 0xFC000000, 0xFE000000, 0xFF000000,
1400 + 0xFF800000, 0xFFC00000, 0xFFE00000, 0xFFF00000,
1401 + 0xFFF80000, 0xFFFC0000, 0xFFFE0000, 0xFFFF0000,
1402 + 0xFFFF8000, 0xFFFFC000, 0xFFFFE000, 0xFFFFF000,
1403 + 0xFFFFF800, 0xFFFFFC00, 0xFFFFFE00, 0xFFFFFF00,
1404 + 0xFFFFFF80, 0xFFFFFFC0, 0xFFFFFFE0, 0xFFFFFFF0,
1405 + 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE, 0xFFFFFFFF };
1407 +mpls_ifmgr_handle mpls_ifmgr_open(mpls_instance_handle handle,
1408 + mpls_cfg_handle cfg, ldp_ifmgr_callback callback)
1411 + ifmgr_callback = callback;
1414 + return 0xdeadbeef;
1417 +void mpls_ifmgr_close(mpls_ifmgr_handle ifmgr_handle)
1422 +mpls_if_handle mpls_ifmgr_open_if(mpls_ifmgr_handle ifmgr_handle, const char *name)
1424 + mpls_if_handle ifh;
1425 + char name2[IFNAMSIZ + 1];
1426 + strncpy(name2,name,IFNAMSIZ);
1428 + ifh = if_lookup_by_name(name2);
1433 +mpls_return_enum mpls_ifmgr_get_address(mpls_ifmgr_handle ifmgr_handle,
1434 + mpls_if_handle if_handle, mpls_inet_addr * addr, mpls_inet_addr * mask,
1437 + struct connected *ifc;
1442 + *flags = if_handle->flags;
1445 + for (node = listhead(if_handle->connected); node; nextnode(node)) {
1446 + ifc = getdata(node);
1447 + if (ifc->address->u.prefix4.s_addr == htonl(INADDR_LOOPBACK)) {
1451 + if (!loop && (ifc->flags & ZEBRA_IFA_SECONDARY)) {
1455 + addr->type = MPLS_FAMILY_IPV4;
1456 + addr->u.ipv4 = ntohl(ifc->address->u.prefix4.s_addr);
1459 + mask->type = MPLS_FAMILY_IPV4;
1460 + mask->u.ipv4 = mask_array[ifc->address->prefixlen];
1462 + return MPLS_SUCCESS;
1464 + return MPLS_FAILURE;
1467 +mpls_return_enum mpls_ifmgr_get_mtu(mpls_ifmgr_handle ifmgr_handle,
1468 + mpls_if_handle if_handle, int *mtu)
1470 + *mtu = if_handle->mtu;
1471 + return MPLS_SUCCESS;
1474 +void mpls_ifmgr_close_if(mpls_ifmgr_handle ifmgr_handle, mpls_if_handle if_handle)
1478 +mpls_return_enum mpls_ifmgr_getnext_address(mpls_ifmgr_handle ifmgr_handle,
1479 + mpls_if_handle *handle, mpls_inet_addr *addr)
1481 + struct connected *ifc;
1485 + while ((*handle)) {
1486 + for (node = listhead((*handle)->connected); node; nextnode(node)) {
1487 + ifc = getdata(node);
1488 + if (ifc->address->u.prefix4.s_addr != htonl(INADDR_LOOPBACK)) {
1490 + addr->type = MPLS_FAMILY_IPV4;
1491 + addr->u.ipv4 = ntohl(ifc->address->u.prefix4.s_addr);
1492 + return MPLS_SUCCESS;
1493 + } else if (addr->u.ipv4 == ntohl(ifc->address->u.prefix4.s_addr)) {
1498 + (*handle) = if_getnext(*handle);
1501 + return MPLS_END_OF_LIST;
1504 +mpls_return_enum mpls_ifmgr_getfirst_address(mpls_ifmgr_handle ifmgr_handle,
1505 + mpls_if_handle *handle, mpls_inet_addr *addr)
1507 + struct connected *ifc;
1510 + (*handle) = if_getfirst();
1511 + while ((*handle)) {
1512 + for (node = listhead((*handle)->connected); node; nextnode(node)) {
1513 + ifc = getdata(node);
1514 + if (ifc->address->u.prefix4.s_addr != htonl(INADDR_LOOPBACK)) {
1515 + addr->type = MPLS_FAMILY_IPV4;
1516 + addr->u.ipv4 = ntohl(ifc->address->u.prefix4.s_addr);
1517 + return MPLS_SUCCESS;
1520 + (*handle) = if_getnext(*handle);
1522 + return MPLS_END_OF_LIST;
1525 +int ldp_address_add_callback(struct mpls *mpls, struct connected *c) {
1526 + mpls_inet_addr addr;
1529 + addr.type = MPLS_FAMILY_IPV4;
1530 + addr.u.ipv4 = ntohl(c->address->u.prefix4.s_addr);
1532 + ifmgr_callback(mpls->ldp->h,MPLS_UPDATE_ADD,&addr);
1538 +int ldp_address_delete_callback(struct mpls *mpls, struct connected *c) {
1539 + mpls_inet_addr addr;
1542 + addr.type = MPLS_FAMILY_IPV4;
1543 + addr.u.ipv4 = ntohl(c->address->u.prefix4.s_addr);
1545 + ifmgr_callback(mpls->ldp->h,MPLS_UPDATE_DEL,&addr);
1549 diff --exclude=CVS -uNr zebra/mplsd/impl_ifmgr.h zebra-ldp/mplsd/impl_ifmgr.h
1550 --- zebra/mplsd/impl_ifmgr.h 1969-12-31 18:00:00.000000000 -0600
1551 +++ zebra-ldp/mplsd/impl_ifmgr.h 2003-02-26 15:47:43.000000000 -0600
1553 +#ifndef LDP_IMPL_IFMGR_H
1554 +#define LDP_IMPL_IFMGR_H
1557 +#include "ldp_struct.h"
1559 +int ldp_address_add_callback(struct mpls *mpls, struct connected *c);
1560 +int ldp_address_delete_callback(struct mpls *mpls, struct connected *c);
1563 diff --exclude=CVS -uNr zebra/mplsd/impl_lock.c zebra-ldp/mplsd/impl_lock.c
1564 --- zebra/mplsd/impl_lock.c 1969-12-31 18:00:00.000000000 -0600
1565 +++ zebra-ldp/mplsd/impl_lock.c 2003-02-26 15:47:43.000000000 -0600
1567 +#include "ldp_struct.h"
1568 +#include "mpls_assert.h"
1569 +#include "mpls_mm_impl.h"
1571 +mpls_lock_handle mpls_lock_create(mpls_lock_key_type key)
1573 + int *i = mpls_malloc(sizeof(int));
1579 +void mpls_lock_get(mpls_lock_handle handle)
1581 + MPLS_ASSERT(*handle == 0);
1585 +void mpls_lock_release(mpls_lock_handle handle)
1587 + MPLS_ASSERT(*handle == 1);
1591 +void mpls_lock_delete(mpls_lock_handle handle)
1593 + mpls_free(handle);
1595 diff --exclude=CVS -uNr zebra/mplsd/impl_mm.c zebra-ldp/mplsd/impl_mm.c
1596 --- zebra/mplsd/impl_mm.c 1969-12-31 18:00:00.000000000 -0600
1597 +++ zebra-ldp/mplsd/impl_mm.c 2003-02-26 15:47:43.000000000 -0600
1599 +#include "ldp_struct.h"
1600 +#include "mpls_mm_impl.h"
1602 +#include <stdlib.h>
1604 +#include "memory.h"
1606 +static int _mm_count = 0;
1608 +void *mpls_malloc(mpls_size_type size)
1610 + void *mem = XMALLOC(MTYPE_MPLS_LDP, size);
1617 +void mpls_free(void *mem)
1620 + XFREE(MTYPE_MPLS_LDP,mem);
1623 +void mpls_mm_results()
1625 + fprintf(stderr, "LDP MM RESULTS: %d\n", _mm_count);
1627 diff --exclude=CVS -uNr zebra/mplsd/impl_mpls.c zebra-ldp/mplsd/impl_mpls.c
1628 --- zebra/mplsd/impl_mpls.c 1969-12-31 18:00:00.000000000 -0600
1629 +++ zebra-ldp/mplsd/impl_mpls.c 2003-03-12 22:53:25.000000000 -0600
1631 +#include <mplsd/ldp.h>
1634 +#include "stream.h"
1635 +#include "prefix.h"
1637 +#include "zclient.h"
1640 +#include "ldp_struct.h"
1641 +#include "ldp_entity.h"
1642 +#include "mpls_mpls_impl.h"
1643 +#include "mpls_socket_impl.h"
1644 +#include <linux/mpls.h>
1646 +#include "mpls_interface.h"
1647 +#include "impl_fib.h"
1649 +static int label = 10000;
1650 +extern struct zclient *zclient;
1651 +static int mplsd_socket = 0;
1653 +#define MPLS_LINUX 1
1655 +int mplsd_ioctl (u_long request, caddr_t buffer) {
1659 + if (!mplsd_socket) {
1660 + mplsd_socket = socket (AF_INET, SOCK_DGRAM, 0);
1661 + if (mplsd_socket < 0) {
1662 + perror ("socket");
1667 + ret = ioctl (mplsd_socket, request, buffer);
1679 +int do_mpls_labelspace(struct mpls_interface *mi) {
1680 + struct mpls_labelspace_req mls;
1682 + if (!mi || !mi->ifp->ifindex) {
1686 + memset(&mls,0,sizeof(struct mpls_labelspace_req));
1687 + mls.mls_ifindex = mi->ifp->ifindex;
1688 + mls.mls_labelspace = mi->labelspace;
1689 + if (mplsd_ioctl(SIOCSLABELSPACEMPLS,(caddr_t)&mls)) {
1696 +mpls_mpls_handle mpls_mpls_open(mpls_instance_handle user_data)
1698 + return socket(AF_INET, SOCK_STREAM, 0);
1701 +void mpls_mpls_close(mpls_mpls_handle handle)
1706 +mpls_return_enum mpls_mpls_outsegment_add(mpls_mpls_handle handle, mpls_outsegment * o)
1709 + struct mpls_out_label_req oreq;
1710 + struct mpls_instruction_req mir;
1711 + struct sockaddr_in sin;
1714 + memset(&oreq,0,sizeof(oreq));
1715 + memset(&mir,0,sizeof(mir));
1716 + oreq.mol_label.ml_type = MPLS_LABEL_KEY;
1717 + result = ioctl(handle,SIOCMPLSNHLFEADD,&oreq);
1718 + o->handle = oreq.mol_label.u.ml_key;
1720 + mir.mir_direction = MPLS_OUT;
1721 + mir.mir_label.ml_type = MPLS_LABEL_KEY;
1722 + mir.mir_label.u.ml_key = o->handle;
1723 + mir.mir_instruction[0].mir_opcode = MPLS_OP_PUSH;
1724 + mir.mir_instruction[0].mir_data.push.ml_type = MPLS_LABEL_GEN;
1725 + mir.mir_instruction[0].mir_data.push.u.ml_gen = o->label.u.gen;
1727 + mir.mir_instruction[1].mir_opcode = MPLS_OP_SET;
1728 + mir.mir_instruction[1].mir_data.set.mni_if = o->nexthop.if_handle->ifindex;
1729 + sin.sin_addr.s_addr = htonl(o->nexthop.ip.u.ipv4);
1730 + sin.sin_family = AF_INET;
1731 + memcpy(&mir.mir_instruction[1].mir_data.set.mni_addr,
1732 + &sin,sizeof(struct sockaddr));
1734 + mir.mir_instruction_length = 2;
1735 + result = ioctl(handle,SIOCSMPLSOUTINSTR,&mir);
1739 + sprintf(ifr.ifr_name,"mpls%d",o->handle);
1740 + memcpy(&ifr.ifr_data,&oreq.mol_label,sizeof(struct mpls_label));
1741 + result = ioctl(handle,SIOCMPLSTUNNELADD,&ifr);
1742 + ifr.ifr_flags = IFF_UP | IFF_POINTOPOINT | IFF_NOARP | IFF_RUNNING;
1743 + result = ioctl(handle,SIOCSIFFLAGS,&ifr);
1746 + return MPLS_SUCCESS;
1749 +void mpls_mpls_outsegment_del(mpls_mpls_handle handle, mpls_outsegment * o)
1752 + struct mpls_out_label_req oreq;
1757 + sprintf(ifr.ifr_name,"mpls%d",o->handle);
1758 + result = ioctl(handle,SIOCMPLSTUNNELDEL,&ifr);
1761 + oreq.mol_label.ml_type = MPLS_LABEL_KEY;
1762 + oreq.mol_label.u.ml_key = o->handle;
1763 + result = ioctl(handle,SIOCMPLSNHLFEDEL,&oreq);
1768 +mpls_return_enum mpls_mpls_insegment_add(mpls_mpls_handle handle,
1769 + mpls_insegment * i)
1772 + struct mpls_in_label_req ireq;
1776 + if (i->label.type == MPLS_LABEL_TYPE_NONE) {
1777 + i->label.type = MPLS_LABEL_TYPE_GENERIC;
1778 + i->label.u.gen = label++;
1782 + ireq.mil_label.ml_type = MPLS_LABEL_GEN;
1783 + ireq.mil_label.u.ml_gen = i->label.u.gen;
1784 + ireq.mil_label.ml_index = i->labelspace;
1787 + result = ioctl(handle,SIOCMPLSILMADD,&ireq);
1790 + return MPLS_SUCCESS;
1793 +void mpls_mpls_insegment_del(mpls_mpls_handle handle, mpls_insegment * i)
1796 + struct mpls_in_label_req ireq;
1799 + ireq.mil_label.ml_type = MPLS_LABEL_GEN;
1800 + ireq.mil_label.u.ml_gen = i->label.u.gen;
1801 + ireq.mil_label.ml_index = i->labelspace;
1803 + result = ioctl(handle,SIOCMPLSILMDEL,&ireq);
1807 +mpls_return_enum mpls_mpls_xconnect_add(mpls_mpls_handle handle, mpls_insegment * i, mpls_outsegment * o)
1810 + struct mpls_xconnect_req xreq;
1813 + xreq.mx_in.ml_type = MPLS_LABEL_GEN;
1814 + xreq.mx_in.u.ml_gen = i->label.u.gen;
1815 + xreq.mx_in.ml_index = i->labelspace;
1817 + xreq.mx_out.ml_type = MPLS_LABEL_KEY;
1818 + xreq.mx_out.u.ml_key = o->handle;
1820 + result = ioctl(handle,SIOCMPLSXCADD,&xreq);
1824 + return MPLS_SUCCESS;
1827 +void mpls_mpls_xconnect_del(mpls_mpls_handle handle, mpls_insegment * i,
1828 + mpls_outsegment * o)
1831 + struct mpls_xconnect_req xreq;
1834 + xreq.mx_in.ml_type = MPLS_LABEL_GEN;
1835 + xreq.mx_in.u.ml_gen = i->label.u.gen;
1836 + xreq.mx_in.ml_index = i->labelspace;
1838 + xreq.mx_out.ml_type = MPLS_LABEL_KEY;
1839 + xreq.mx_out.u.ml_key = o->handle;
1841 + result = ioctl(handle,SIOCMPLSXCDEL,&xreq);
1846 +mpls_return_enum mpls_mpls_fec2out_add(mpls_mpls_handle handle, mpls_fec * f,
1847 + mpls_outsegment * o)
1850 + struct in_addr addr;
1851 + unsigned int ifindex;
1852 + unsigned int mplsindex;
1855 + mplsindex = o->handle;
1856 + ifindex = o->nexthop.if_handle->ifindex;
1857 + addr.s_addr = htonl(o->nexthop.ip.u.ipv4);
1859 + mpls_fec2zebra_prefix(f,&p);
1860 + retval = zapi_ipv4_set_mplsindex(zclient,(struct prefix_ipv4*)&p,
1861 + &addr,ifindex,mplsindex);
1863 + return MPLS_SUCCESS;
1866 +void mpls_mpls_fec2out_del(mpls_mpls_handle handle, mpls_fec * f,
1867 + mpls_outsegment * o)
1870 + struct in_addr addr;
1871 + unsigned int ifindex;
1872 + unsigned int mplsindex;
1875 + mplsindex = o->handle;
1876 + ifindex = o->nexthop.if_handle->ifindex;
1877 + addr.s_addr = htonl(o->nexthop.ip.u.ipv4);
1879 + mpls_fec2zebra_prefix(f,&p);
1880 + retval = zapi_ipv4_set_mplsindex(zclient,(struct prefix_ipv4*)&p,
1884 +mpls_return_enum mpls_mpls_get_label_space_range(mpls_mpls_handle handle,
1887 + r->type = MPLS_LABEL_RANGE_GENERIC;
1888 + r->min.u.gen = 16;
1889 + r->max.u.gen = 0xFFFFF;
1891 + return MPLS_SUCCESS;
1893 diff --exclude=CVS -uNr zebra/mplsd/impl_mpls.h zebra-ldp/mplsd/impl_mpls.h
1894 --- zebra/mplsd/impl_mpls.h 1969-12-31 18:00:00.000000000 -0600
1895 +++ zebra-ldp/mplsd/impl_mpls.h 2003-02-26 15:47:43.000000000 -0600
1897 +#ifndef IMPL_MPLS_H
1898 +#define IMPL_MPLS_H
1900 +int do_mpls_labelspace(struct mpls_interface *mi);
1903 diff --exclude=CVS -uNr zebra/mplsd/impl_policy.c zebra-ldp/mplsd/impl_policy.c
1904 --- zebra/mplsd/impl_policy.c 1969-12-31 18:00:00.000000000 -0600
1905 +++ zebra-ldp/mplsd/impl_policy.c 2003-02-26 23:24:44.000000000 -0600
1909 +#include "ldp_struct.h"
1910 +#include "mpls_interface.h"
1911 +#include "impl_fib.h"
1914 +mpls_bool mpls_policy_import_check(mpls_instance_handle handle, mpls_fec * f,
1917 + return MPLS_BOOL_TRUE;
1920 +mpls_bool mpls_policy_ingress_check(mpls_instance_handle handle, mpls_fec * f, ldp_addr * nh)
1922 + return MPLS_BOOL_TRUE;
1925 +mpls_bool mpls_policy_egress_check(mpls_instance_handle handle, mpls_fec * fec)
1927 + struct ldp *ldp = handle;
1928 + int result = MPLS_BOOL_FALSE;
1930 + switch(ldp->egress) {
1931 + case LDP_EGRESS_ALL:
1932 + result = MPLS_BOOL_TRUE;
1934 + case LDP_EGRESS_LSRID:
1935 + case LDP_EGRESS_CONNECTED:
1937 + struct route_node *rn;
1940 + mpls_fec2zebra_prefix(fec,&p);
1941 + if ((rn = route_node_lookup(ldp->mpls->table,&p))) {
1942 + if (ldp->egress == LDP_EGRESS_LSRID) {
1943 + if (prefix_match(&rn->p, &ldp->mpls->router_id)) {
1944 + result = MPLS_BOOL_TRUE;
1947 + struct mpls_nexthop* nh =
1948 + (struct mpls_nexthop*)getdata(listhead((struct list*)rn->info));
1949 + result = nh->attached;
1951 + route_unlock_node(rn);
1961 +mpls_bool mpls_policy_export_check(mpls_instance_handle handle, mpls_fec * f, ldp_addr * nh)
1963 + return MPLS_BOOL_TRUE;
1966 +mpls_bool mpls_policy_address_export_check(mpls_instance_handle handle,
1967 + mpls_inet_addr *addr) {
1968 + struct ldp *ldp = handle;
1969 + mpls_bool flag = MPLS_BOOL_FALSE;
1970 + struct interface *ifp;
1971 + struct in_addr in;
1973 + in.s_addr = htonl(addr->u.ipv4);
1976 + switch (ldp->address) {
1977 + case LDP_ADDRESS_LDP:
1978 + if ((ifp = if_lookup_exact_address(in)) &&
1979 + ((struct mpls_interface*)(ifp->info))->ldp) {
1980 + flag = MPLS_BOOL_TRUE;
1982 + /* fall through */
1983 + case LDP_ADDRESS_LSRID:
1984 + if (in.s_addr == ldp->mpls->router_id.u.prefix4.s_addr) {
1985 + flag = MPLS_BOOL_TRUE;
1988 + case LDP_ADDRESS_ALL:
1989 + flag = MPLS_BOOL_TRUE;
1994 diff --exclude=CVS -uNr zebra/mplsd/impl_socket.c zebra-ldp/mplsd/impl_socket.c
1995 --- zebra/mplsd/impl_socket.c 1969-12-31 18:00:00.000000000 -0600
1996 +++ zebra-ldp/mplsd/impl_socket.c 2003-02-26 15:47:43.000000000 -0600
1999 +#include "thread.h"
2000 +#include "sockopt.h"
2004 +#include "ldp_struct.h"
2005 +#include "ldp_state_machine.h"
2006 +#include "mpls_mm_impl.h"
2008 +extern struct thread_master *master;
2010 +struct mpls_socket {
2013 + struct thread *read;
2014 + struct thread *write;
2018 +void _sockaddr2mpls_dest(const struct sockaddr *addr, mpls_dest * dest)
2020 + dest->addr.type = MPLS_FAMILY_IPV4;
2021 + switch (dest->addr.type) {
2022 + case MPLS_FAMILY_IPV4:
2023 + dest->port = ntohs(((struct sockaddr_in *)addr)->sin_port);
2024 + dest->addr.u.ipv4 = ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr);
2031 +void _mpls_dest2sockaddr(const mpls_dest * dest, struct sockaddr *addr)
2033 + memset(addr, 0, sizeof(struct sockaddr));
2035 + switch (dest->addr.type) {
2036 + case MPLS_FAMILY_IPV4:
2038 + addr->sa_family = AF_INET;
2039 + ((struct sockaddr_in *)addr)->sin_port = htons(dest->port);
2040 + ((struct sockaddr_in *)addr)->sin_addr.s_addr = htonl(dest->addr.u.ipv4);
2050 +int mplsd_read(struct thread *thread) {
2052 + struct mpls *mpls = mpls_get();
2053 + mpls_socket_handle socket = THREAD_ARG(thread);
2055 + socket->read = thread_add_read(master,mplsd_read,socket,socket->fd);
2057 + if (!mpls || !mpls->ldp) {
2061 + switch (socket->type) {
2062 + case MPLS_SOCKET_TCP_DATA:
2064 + retval = ldp_event(mpls->ldp->h, socket, socket->extra,
2065 + LDP_EVENT_TCP_DATA);
2068 + case MPLS_SOCKET_TCP_LISTEN:
2070 + retval = ldp_event(mpls->ldp->h, socket, socket->extra,
2071 + LDP_EVENT_TCP_LISTEN);
2074 + case MPLS_SOCKET_UDP_DATA:
2076 + retval = ldp_event(mpls->ldp->h, socket, socket->extra,
2077 + LDP_EVENT_UDP_DATA);
2088 +int mplsd_write(struct thread *thread) {
2089 + struct mpls *mpls = mpls_get();
2091 + mpls_socket_handle socket = THREAD_ARG(thread);
2092 + socket->write = thread_add_write(master,mplsd_write,socket,socket->fd);
2093 + if (socket->type != MPLS_SOCKET_TCP_CONNECT) {
2096 + retval = ldp_event(mpls->ldp->h, socket, socket->extra,
2097 + LDP_EVENT_TCP_CONNECT);
2102 +mpls_socket_mgr_handle mpls_socket_mgr_open(mpls_instance_handle user_data)
2104 + return 0xdeadbeef;
2107 +void mpls_socket_mgr_close(mpls_socket_mgr_handle handle)
2111 +void mpls_socket_close(mpls_socket_mgr_handle handle, mpls_socket_handle socket)
2114 + close(socket->fd);
2115 + mpls_free(socket);
2119 +mpls_socket_handle mpls_socket_create_tcp(mpls_socket_mgr_handle handle)
2121 + struct mpls_socket *sock;
2122 + sock = mpls_malloc(sizeof(struct mpls_socket));
2123 + memset(sock,0,sizeof(struct mpls_socket));
2124 + sock->fd = socket(AF_INET, SOCK_STREAM, 0);
2125 + MPLS_ASSERT(sock->fd > -1);
2129 +mpls_socket_handle mpls_socket_create_udp(mpls_socket_mgr_handle handle)
2131 + struct mpls_socket *sock;
2134 + sock = mpls_malloc(sizeof(struct mpls_socket));
2135 + memset(sock,0,sizeof(struct mpls_socket));
2136 + sock->fd = socket(AF_INET, SOCK_DGRAM, 0);
2137 + MPLS_ASSERT(sock->fd > -1);
2138 + if (setsockopt(sock->fd,IPPROTO_IP,IP_PKTINFO,&one,sizeof(one)) < 0) {
2139 + perror("PKTINFO");
2146 +mpls_socket_handle mpls_socket_tcp_accept(mpls_socket_mgr_handle handle,
2147 + mpls_socket_handle socket, mpls_dest * from)
2149 + struct mpls_socket *sock = mpls_malloc(sizeof(struct mpls_socket));
2150 + struct sockaddr addr;
2151 + int size = sizeof(addr);
2153 + if ((sock->fd = accept(socket->fd,&addr,&size)) < 0) {
2157 + _sockaddr2mpls_dest(&addr, from);
2161 +mpls_return_enum mpls_socket_bind(mpls_socket_mgr_handle handle,
2162 + mpls_socket_handle socket, const mpls_dest * local)
2164 + struct sockaddr addr;
2166 + _mpls_dest2sockaddr(local, &addr);
2168 + if (bind(socket->fd, &addr, sizeof(struct sockaddr_in)) < 0) {
2169 + return MPLS_FAILURE;
2172 + return MPLS_SUCCESS;
2175 +mpls_return_enum mpls_socket_tcp_listen(mpls_socket_mgr_handle handle,
2176 + mpls_socket_handle socket, int depth)
2178 + if (listen(socket->fd, depth) < 0) {
2179 + return MPLS_FAILURE;
2181 + return MPLS_SUCCESS;
2184 +mpls_return_enum mpls_socket_tcp_connect(mpls_socket_mgr_handle handle,
2185 + mpls_socket_handle socket, const mpls_dest * to)
2187 + struct sockaddr addr, *iaddr = NULL;
2190 + _mpls_dest2sockaddr(to, &addr);
2196 + if (connect(socket->fd, iaddr, sizeof(struct sockaddr)) < 0) {
2197 + if (errno == EINPROGRESS) {
2198 + return MPLS_NON_BLOCKING;
2201 + if (errno == EALREADY) {
2202 + return MPLS_SUCCESS;
2204 + perror("connect");
2205 + return MPLS_FAILURE;
2207 + return MPLS_SUCCESS;
2210 +mpls_return_enum mpls_socket_connect_status(mpls_socket_mgr_handle handle,
2211 + mpls_socket_handle socket)
2213 + int size = sizeof(int);
2216 + if (getsockopt(socket->fd, SOL_SOCKET, SO_ERROR, &num, &size) < 0) {
2217 + perror("getsockopt");
2218 + return MPLS_FAILURE;
2221 + return MPLS_SUCCESS;
2223 + perror("getsockopt");
2224 + return MPLS_NON_BLOCKING;
2227 +int mpls_socket_get_errno(const mpls_socket_mgr_handle handle,
2228 + mpls_socket_handle socket)
2233 +mpls_return_enum mpls_socket_options(mpls_socket_mgr_handle handle,
2234 + mpls_socket_handle socket, uint32_t flag)
2238 + if (flag & MPLS_SOCKOP_REUSE) {
2239 + if (setsockopt(socket->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&one,
2240 + sizeof(one)) < 0) {
2241 + return MPLS_FAILURE;
2244 + if (flag & MPLS_SOCKOP_NONBLOCK) {
2245 + if (fcntl(socket->fd, F_SETFL, O_NONBLOCK) < 0) {
2246 + return MPLS_FAILURE;
2249 + return MPLS_SUCCESS;
2252 +mpls_return_enum mpls_socket_multicast_options(mpls_socket_mgr_handle handle,
2253 + mpls_socket_handle socket, int ttl, int loop)
2258 + if (setsockopt(socket->fd,IPPROTO_IP,IP_MULTICAST_TTL,&one,sizeof(one))<0) {
2259 + return MPLS_FAILURE;
2262 + if (setsockopt(socket->fd,IPPROTO_IP,IP_MULTICAST_LOOP,&zero,sizeof(zero))<0) {
2263 + return MPLS_FAILURE;
2266 + return MPLS_SUCCESS;
2269 +mpls_return_enum mpls_socket_multicast_if_tx(mpls_socket_mgr_handle handle,
2270 + mpls_socket_handle socket, const ldp_if * iff)
2272 + struct in_addr addr;
2273 + unsigned int ifindex = 0;
2276 + if (iff == NULL) {
2277 + addr.s_addr = ntohl(INADDR_ANY);
2279 + ifindex = iff->handle->ifindex;
2282 + if (setsockopt_multicast_ipv4(socket->fd,IP_MULTICAST_IF,addr,0,ifindex)<0) {
2283 + return MPLS_FAILURE;
2286 + return MPLS_SUCCESS;
2289 +mpls_return_enum mpls_socket_multicast_if_join(mpls_socket_mgr_handle handle,
2290 + mpls_socket_handle socket, const ldp_if * iff, const mpls_inet_addr * mult)
2292 + struct in_addr addr;
2293 + unsigned int ifindex = 0;
2296 + if (iff == NULL) {
2297 + addr.s_addr = ntohl(INADDR_ANY);
2299 + ifindex = iff->handle->ifindex;
2302 + if (setsockopt_multicast_ipv4(socket->fd,IP_ADD_MEMBERSHIP,addr,
2303 + htonl(mult->u.ipv4),ifindex)<0) {
2304 + return MPLS_FAILURE;
2307 + return MPLS_SUCCESS;
2310 +void mpls_socket_multicast_if_drop(mpls_socket_mgr_handle handle,
2311 + mpls_socket_handle socket, const ldp_if * iff, const mpls_inet_addr * mult)
2313 + struct in_addr addr;
2314 + unsigned int ifindex = 0;
2317 + if (iff == NULL) {
2318 + addr.s_addr = ntohl(INADDR_ANY);
2320 + ifindex = iff->handle->ifindex;
2323 + if (setsockopt_multicast_ipv4(socket->fd,IP_DROP_MEMBERSHIP,addr,
2324 + htonl(mult->u.ipv4),ifindex)<0) {
2331 +mpls_return_enum mpls_socket_readlist_add(mpls_socket_mgr_handle handle,
2332 + mpls_socket_handle socket, void *extra, mpls_socket_enum type)
2334 + socket->type = type;
2335 + socket->extra = extra;
2336 + socket->read = thread_add_read(master,mplsd_read,socket,socket->fd);
2337 + MPLS_ASSERT(socket->read);
2338 + return MPLS_SUCCESS;
2341 +void mpls_socket_readlist_del(mpls_socket_mgr_handle handle,
2342 + mpls_socket_handle socket)
2344 + if (socket && socket->read) {
2345 + thread_cancel(socket->read);
2346 + socket->read = NULL;
2350 +mpls_return_enum mpls_socket_writelist_add(mpls_socket_mgr_handle handle,
2351 + mpls_socket_handle socket, void *extra, mpls_socket_enum type)
2353 + socket->type = type;
2354 + socket->extra = extra;
2355 + socket->write = thread_add_write(master,mplsd_write,socket,socket->fd);
2356 + MPLS_ASSERT(socket->write);
2357 + return MPLS_SUCCESS;
2360 +void mpls_socket_writelist_del(mpls_socket_mgr_handle handle,
2361 + mpls_socket_handle socket)
2364 + thread_cancel(socket->write);
2365 + socket->write = NULL;
2369 +int mpls_socket_tcp_read(mpls_socket_mgr_handle handle, mpls_socket_handle socket,
2370 + uint8_t * buffer, int size)
2372 + int ret = read(socket->fd,buffer,size);
2373 + if (ret < 0 && errno != EAGAIN) {
2374 + perror("mpls_socket_tcp_read");
2380 +int mpls_socket_tcp_write(mpls_socket_mgr_handle handle, mpls_socket_handle socket,
2381 + uint8_t * buffer, int size)
2383 + return write(socket->fd,buffer,size);
2386 +int mpls_socket_udp_sendto(mpls_socket_mgr_handle handle,
2387 + mpls_socket_handle socket, uint8_t * buffer, int size, const mpls_dest * to)
2389 + struct sockaddr addr;
2392 + _mpls_dest2sockaddr(to, &addr);
2394 + retval = sendto(socket->fd,buffer,size,0,&addr,sizeof(struct sockaddr));
2399 +int mpls_socket_udp_recvfrom(mpls_socket_mgr_handle handle,
2400 + mpls_socket_handle socket, uint8_t * buffer, int size, mpls_dest * from)
2403 + unsigned int ifindex = 0;
2405 + struct cmsghdr *cmsg;
2406 + struct in_pktinfo *pktinfo;
2407 + struct sockaddr addr;
2408 + char buff [sizeof (*cmsg) + sizeof (*pktinfo)];
2409 + struct msghdr msgh = {&addr, sizeof(struct sockaddr), &iov, 1, buff,
2410 + sizeof (*cmsg) + sizeof (*pktinfo), 0};
2412 + iov.iov_base = buffer;
2413 + iov.iov_len = size;
2414 + ret = recvmsg(socket->fd,&msgh,0);
2416 + if (ret < 0 && errno != EAGAIN) {
2420 + cmsg = CMSG_FIRSTHDR(&msgh);
2422 + if (cmsg != NULL &&
2423 + cmsg->cmsg_level == IPPROTO_IP &&
2424 + cmsg->cmsg_type == IP_PKTINFO) {
2425 + pktinfo = (struct in_pktinfo *)CMSG_DATA(cmsg);
2426 + ifindex = pktinfo->ipi_ifindex;
2427 + from->if_handle = if_lookup_by_index(ifindex);
2428 + _sockaddr2mpls_dest((const struct sockaddr*)&addr, from);
2433 diff --exclude=CVS -uNr zebra/mplsd/impl_timer.c zebra-ldp/mplsd/impl_timer.c
2434 --- zebra/mplsd/impl_timer.c 1969-12-31 18:00:00.000000000 -0600
2435 +++ zebra-ldp/mplsd/impl_timer.c 2003-02-26 15:47:43.000000000 -0600
2437 +#include "ldp_struct.h"
2438 +#include "mpls_timer_impl.h"
2439 +#include "mpls_mm_impl.h"
2441 +#include "thread.h"
2443 +struct mpls_timer {
2444 + struct thread *timer;
2445 + mpls_time_unit_enum unit;
2449 + mpls_cfg_handle g;
2450 + void (*callback) (mpls_timer_handle timer, void *extra, mpls_cfg_handle g);
2454 +extern struct thread_master *master;
2456 +int mpls_timer(struct thread* thread) {
2457 + mpls_timer_handle timer = THREAD_ARG(thread);
2459 + timer->active = 0;
2460 + if (timer->type == MPLS_TIMER_REOCCURRING) {
2461 + timer->timer = thread_add_timer(master,mpls_timer,timer,timer->duration);
2462 + timer->active = 1;
2464 + timer->callback(timer,timer->extra,timer->g);
2469 +mpls_timer_mgr_handle mpls_timer_open(mpls_instance_handle user_data)
2471 + return 0xdeadbeef;
2474 +void mpls_timer_close(mpls_timer_mgr_handle handle)
2478 +mpls_timer_handle mpls_timer_create(mpls_timer_mgr_handle handle,
2479 + mpls_time_unit_enum unit, int duration, void *extra, mpls_cfg_handle g,
2480 + void (*callback) (mpls_timer_handle timer, void *extra, mpls_cfg_handle g))
2482 + struct mpls_timer *timer;
2483 + timer = mpls_malloc(sizeof(struct mpls_timer));
2484 + timer->unit = unit;
2485 + timer->duration = duration;
2486 + timer->extra = extra;
2488 + timer->callback = callback;
2489 + timer->active = 0;
2494 +mpls_return_enum mpls_timer_modify(mpls_timer_mgr_handle handle,
2495 + mpls_timer_handle timer, int duration)
2498 + return MPLS_FAILURE;
2500 + timer->duration = duration;
2501 + return MPLS_SUCCESS;
2504 +void mpls_timer_delete(mpls_timer_mgr_handle handle, mpls_timer_handle timer)
2511 +mpls_return_enum mpls_timer_start(mpls_timer_mgr_handle handle,
2512 + mpls_timer_handle timer, mpls_timer_type_enum type)
2515 + return MPLS_FAILURE;
2517 + timer->type = type;
2518 + timer->timer = thread_add_timer(master,mpls_timer,timer,timer->duration);
2519 + timer->active = 1;
2520 + return MPLS_SUCCESS;
2523 +void mpls_timer_stop(mpls_timer_mgr_handle handle, mpls_timer_handle timer)
2525 + if (timer && timer->active) {
2526 + thread_cancel(timer->timer);
2527 + timer->timer = NULL;
2530 diff --exclude=CVS -uNr zebra/mplsd/impl_tree.c zebra-ldp/mplsd/impl_tree.c
2531 --- zebra/mplsd/impl_tree.c 1969-12-31 18:00:00.000000000 -0600
2532 +++ zebra-ldp/mplsd/impl_tree.c 2003-02-26 15:47:43.000000000 -0600
2537 +#include "ldp_struct.h"
2538 +#include "mpls_mm_impl.h"
2539 +#include "mpls_tree_impl.h"
2541 +mpls_tree_handle mpls_tree_create(int depth)
2543 + return route_table_init();
2546 +mpls_return_enum mpls_tree_insert(mpls_tree_handle tree, uint32_t key, int length,
2549 + struct route_node *node;
2552 + p.family = AF_INET;
2553 + p.prefixlen = length;
2554 + p.u.prefix4.s_addr = key;
2556 + if ((node = route_node_get(tree,&p))) {
2557 + /* result is that the node is 'held', it will be held */
2558 + /* until it is deleted from the tree */
2559 + node->info = info;
2560 + return MPLS_SUCCESS;
2562 + return MPLS_FAILURE;
2565 +mpls_return_enum mpls_tree_remove(mpls_tree_handle tree, uint32_t key, int length,
2568 + struct route_node *node;
2571 + p.family = AF_INET;
2572 + p.prefixlen = length;
2573 + p.u.prefix4.s_addr = key;
2575 + if ((node = route_node_lookup(tree,&p))) {
2576 + *info = node->info;
2577 + node->info = NULL;
2578 + route_unlock_node(node);
2579 + route_unlock_node(node);
2580 + return MPLS_SUCCESS;
2582 + return MPLS_FAILURE;
2585 +mpls_return_enum mpls_tree_replace(mpls_tree_handle tree, uint32_t key, int length,
2586 + void *new, void **old)
2588 + struct route_node *node;
2591 + p.family = AF_INET;
2592 + p.prefixlen = length;
2593 + p.u.prefix4.s_addr = key;
2595 + if ((node = route_node_lookup(tree,&p))) {
2596 + *old = node->info;
2598 + route_unlock_node(node);
2599 + return MPLS_SUCCESS;
2601 + return MPLS_FAILURE;
2604 +mpls_return_enum mpls_tree_get(mpls_tree_handle tree, uint32_t key, int length,
2607 + struct route_node *node;
2610 + p.family = AF_INET;
2611 + p.prefixlen = length;
2612 + p.u.prefix4.s_addr = key;
2614 + if ((node = route_node_lookup(tree,&p))) {
2615 + *info = node->info;
2616 + route_unlock_node(node);
2617 + return MPLS_SUCCESS;
2619 + return MPLS_FAILURE;
2622 +mpls_return_enum mpls_tree_get_longest(mpls_tree_handle tree, uint32_t key,
2625 + struct route_node *node;
2628 + p.family = AF_INET;
2630 + p.u.prefix4.s_addr = key;
2632 + if ((node = route_node_match(tree,&p))) {
2633 + *info = node->info;
2634 + route_unlock_node(node);
2635 + return MPLS_SUCCESS;
2637 + return MPLS_FAILURE;
2640 +void mpls_tree_dump(const mpls_tree_handle tree, ldp_tree_callback callback)
2644 +void mpls_tree_delete(mpls_tree_handle tree)
2646 + route_table_finish(tree);
2649 +mpls_return_enum mpls_tree_getfirst(mpls_tree_handle tree, uint32_t * key,
2650 + int *length, void **info)
2652 + struct route_node *node;
2655 + p.family = AF_INET;
2657 + p.u.prefix4.s_addr = 0;
2659 + if ((node = route_node_match(tree,&p))) {
2660 + *info = node->info;
2661 + *length = node->p.prefixlen;
2662 + *key = node->p.u.prefix4.s_addr;
2663 + route_unlock_node(node);
2664 + return MPLS_SUCCESS;
2666 + return MPLS_FAILURE;
2669 +mpls_return_enum mpls_tree_getnext(mpls_tree_handle tree, uint32_t * key,
2670 + int *length, void **info)
2672 + struct route_node *node;
2675 + p.family = AF_INET;
2676 + p.prefixlen = *length;
2677 + p.u.prefix4.s_addr = *key;
2679 + if (!(node = route_node_match(tree,&p))) {
2680 + return MPLS_FAILURE;
2683 + if ((node = route_next(node))) {
2684 + *info = node->info;
2685 + *length = node->p.prefixlen;
2686 + *key = node->p.u.prefix4.s_addr;
2687 + route_unlock_node(node);
2688 + return MPLS_SUCCESS;
2690 + return MPLS_FAILURE;
2692 diff --exclude=CVS -uNr zebra/mplsd/ldp.c zebra-ldp/mplsd/ldp.c
2693 --- zebra/mplsd/ldp.c 1969-12-31 18:00:00.000000000 -0600
2694 +++ zebra-ldp/mplsd/ldp.c 2003-02-26 15:47:43.000000000 -0600
2698 +#include "memory.h"
2702 +#include "ldp_cfg.h"
2703 +#include "ldp_struct.h"
2704 +#include "ldp_interface.h"
2707 +#include "mpls_interface.h"
2709 +int ldp_shutdown(struct ldp *ldp) {
2712 + g.admin_state = MPLS_ADMIN_DISABLE;
2713 + return ldp_cfg_global_set(ldp->h,&g,LDP_GLOBAL_CFG_ADMIN_STATE);
2716 +int ldp_startup(struct ldp *ldp) {
2719 + g.admin_state = MPLS_ADMIN_ENABLE;
2720 + return ldp_cfg_global_set(ldp->h,&g,LDP_GLOBAL_CFG_ADMIN_STATE);
2723 +int ldp_admin_state_start(struct ldp *ldp) {
2724 + if (ldp->admin_up == MPLS_BOOL_TRUE) {
2725 + return ldp_shutdown(ldp);
2727 + return MPLS_SUCCESS;
2730 +int ldp_admin_state_finish(struct ldp *ldp) {
2731 + if (ldp->admin_up == MPLS_BOOL_TRUE) {
2732 + return ldp_startup(ldp);
2734 + return MPLS_SUCCESS;
2737 +int do_ldp_router_id_update(struct ldp *ldp, unsigned int router_id) {
2739 + g.lsr_identifier.type = MPLS_FAMILY_IPV4;
2740 + g.lsr_identifier.u.ipv4 = router_id;
2741 + return ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_LSR_IDENTIFIER);
2744 +int ldp_router_id_update(struct ldp *ldp, struct prefix *router_id) {
2746 + zlog_info("router-id update %s", inet_ntoa(router_id->u.prefix4));
2748 + if (!ldp->lsr_id_is_static) {
2749 + ldp_admin_state_start(ldp);
2751 + do_ldp_router_id_update(ldp, ntohl(router_id->u.prefix4.s_addr));
2753 + ldp_admin_state_finish(ldp);
2758 +static struct ldp *ldp_new(struct mpls *mpls) {
2759 + struct ldp *new = XMALLOC(MTYPE_MPLS_LDP, sizeof(struct ldp));
2762 + memset(new,0,sizeof(*new));
2764 + new->h = ldp_cfg_open(new);
2765 + new->admin_up = MPLS_BOOL_TRUE;
2766 + new->lsr_id_is_static = 0;
2768 + new->egress = LDP_EGRESS_CONNECTED;
2769 + new->address = LDP_ADDRESS_ALL;
2771 + g.lsr_identifier.type = MPLS_FAMILY_IPV4;
2772 + g.lsr_identifier.u.ipv4 = ntohl(mpls->router_id.u.prefix4.s_addr);
2773 + g.admin_state = MPLS_ADMIN_ENABLE;
2775 + g.lsr_handle = mpls->h;
2777 + ldp_cfg_global_set(new->h,&g,
2778 + LDP_GLOBAL_CFG_LSR_IDENTIFIER|LDP_GLOBAL_CFG_LSR_HANDLE|
2779 + LDP_GLOBAL_CFG_ADMIN_STATE);
2784 +struct ldp *ldp_get() {
2785 + struct mpls_interface *mi;
2786 + struct interface *ifp;
2789 + struct mpls *mpls = mpls_get();
2794 + mpls->ldp = ldp_new(mpls);
2795 + for (node = listhead(mpls->iflist); node; nextnode(node)) {
2796 + ifp = getdata(node);
2797 + mi = (struct mpls_interface*)ifp->info;
2798 + if (mi->ldp && mi->ldp->create_on_hold == MPLS_BOOL_TRUE) {
2799 + ldp_interface_create(mi);
2806 +void ldp_finish(struct ldp *ldp) {
2807 + struct mpls *mpls = ldp->mpls;
2808 + struct interface *ifp;
2809 + struct mpls_interface *mi;
2812 + for (node = listhead(mpls->iflist); node; nextnode(node)) {
2813 + ifp = getdata(node);
2814 + mi = (struct mpls_interface*)ifp->info;
2815 + if (mi->ldp && mi->ldp->entity.index) {
2816 + ldp_interface_delete(mi);
2820 + ldp_admin_state_start(ldp);
2821 + ldp_cfg_close(ldp->h);
2822 + XFREE(MTYPE_MPLS_LDP,ldp);
2825 diff --exclude=CVS -uNr zebra/mplsd/ldp.h zebra-ldp/mplsd/ldp.h
2826 --- zebra/mplsd/ldp.h 1969-12-31 18:00:00.000000000 -0600
2827 +++ zebra-ldp/mplsd/ldp.h 2003-02-26 15:47:43.000000000 -0600
2833 +#include "prefix.h"
2835 +#include "ldp_struct.h"
2842 + LDP_EGRESS_CONNECTED
2847 + LDP_ADDRESS_LSRID,
2849 +} ldp_address_mode;
2852 + struct mpls *mpls;
2853 + mpls_cfg_handle h;
2854 + mpls_bool admin_up;
2855 + mpls_bool lsr_id_is_static;
2856 + ldp_egress_mode egress;
2857 + ldp_address_mode address;
2860 +struct ldp *ldp_get();
2862 +int ldp_router_id_update(struct ldp *ldp, struct prefix *router_id);
2863 +int do_ldp_router_id_update(struct ldp *ldp, unsigned int router_id);
2864 +void ldp_finish(struct ldp *ldp);
2866 +int ldp_admin_state_start(struct ldp *ldp);
2867 +int ldp_admin_state_finish(struct ldp *ldp);
2870 diff --exclude=CVS -uNr zebra/mplsd/ldp_interface.c zebra-ldp/mplsd/ldp_interface.c
2871 --- zebra/mplsd/ldp_interface.c 1969-12-31 18:00:00.000000000 -0600
2872 +++ zebra-ldp/mplsd/ldp_interface.c 2003-02-26 15:47:43.000000000 -0600
2875 +#include "memory.h"
2878 +#include "ldp_cfg.h"
2879 +#include "ldp_struct.h"
2882 +#include "mpls_interface.h"
2884 +struct ldp_interface *ldp_if_new(struct mpls_interface *mi) {
2885 + struct ldp_interface *li;
2887 + li = XMALLOC(MTYPE_MPLS_LDP, sizeof(struct ldp_interface));
2888 + memset(li, 0, sizeof(struct ldp_interface));
2891 + li->admin_up = MPLS_BOOL_TRUE;
2892 + li->create_on_hold = MPLS_BOOL_FALSE;
2893 + ldp_entity_set_defaults(&li->entity);
2898 +void ldp_if_free(struct ldp_interface *li) {
2899 + XFREE(MTYPE_MPLS_LDP, li);
2902 +void ldp_interface_create(struct mpls_interface *mi) {
2903 + struct ldp *ldp = mi->mpls->ldp;
2905 + mi->ldp->create_on_hold = MPLS_BOOL_FALSE;
2907 + strncpy(mi->ldp->iff.name,mi->ifp->name,IFNAMSIZ);
2908 + mi->ldp->iff.label_space = mi->labelspace;
2910 + ldp_cfg_if_set(ldp->h, &mi->ldp->iff, LDP_CFG_ADD | LDP_IF_CFG_LABEL_SPACE);
2912 + mi->ldp->entity.sub_index = mi->ldp->iff.index;
2913 + mi->ldp->entity.entity_type = LDP_DIRECT;
2914 + mi->ldp->entity.admin_state = MPLS_OPER_DOWN;
2916 + ldp_cfg_entity_set(ldp->h, &mi->ldp->entity,
2917 + LDP_CFG_ADD | LDP_ENTITY_CFG_SUB_INDEX | LDP_ENTITY_CFG_ADMIN_STATE);
2919 + ldp_cfg_entity_get(ldp->h, &mi->ldp->entity, 0xFFFFFFFF);
2920 + ldp_cfg_if_get(ldp->h, &mi->ldp->iff, 0xFFFFFFFF);
2922 + ldp_interface_admin_state_finish(mi);
2925 +void ldp_interface_delete(struct mpls_interface *mi) {
2926 + struct ldp *ldp = mi->mpls->ldp;
2928 + mi->ldp->create_on_hold = MPLS_BOOL_TRUE;
2929 + mi->ldp->entity.admin_state = MPLS_OPER_DOWN;
2932 + ldp_interface_admin_state_start(mi);
2933 + ldp_cfg_entity_set(ldp->h, &mi->ldp->entity, LDP_CFG_DEL);
2934 + ldp_cfg_if_set(ldp->h, &mi->ldp->iff, LDP_CFG_DEL);
2936 + mi->ldp->entity.index = 0;
2937 + mi->ldp->iff.index = 0;
2940 +int ldp_interface_startup(struct mpls_interface *mi) {
2941 + struct ldp *ldp = mi->mpls->ldp;
2943 + if (!mi->ldp->iff.index) {
2944 + return MPLS_FAILURE;
2947 + mi->ldp->entity.admin_state = MPLS_OPER_UP;
2948 + ldp_cfg_entity_set(ldp->h, &mi->ldp->entity, LDP_ENTITY_CFG_ADMIN_STATE);
2950 + return MPLS_SUCCESS;
2953 +int ldp_interface_shutdown(struct mpls_interface *mi) {
2954 + struct ldp *ldp = mi->mpls->ldp;
2956 + if (!mi->ldp->iff.index) {
2957 + return MPLS_FAILURE;
2960 + mi->ldp->entity.admin_state = MPLS_ADMIN_DISABLE;
2961 + ldp_cfg_entity_set(ldp->h, &mi->ldp->entity, LDP_ENTITY_CFG_ADMIN_STATE);
2963 + return MPLS_SUCCESS;
2966 +int ldp_interface_admin_state_start(struct mpls_interface *mi) {
2967 + if (mi->ldp->admin_up == MPLS_BOOL_TRUE && mpls_if_is_up(mi)) {
2968 + return ldp_interface_shutdown(mi);
2970 + return MPLS_SUCCESS;
2973 +int ldp_interface_admin_state_finish(struct mpls_interface *mi) {
2974 + if (mi->ldp->admin_up == MPLS_BOOL_TRUE && mpls_if_is_up(mi)) {
2975 + return ldp_interface_startup(mi);
2977 + return MPLS_SUCCESS;
2980 +void ldp_if_up(struct mpls_interface *mi) {
2981 + if (mi->ldp && mi->ldp->admin_up == MPLS_BOOL_TRUE) {
2982 + ldp_interface_startup(mi);
2986 +void ldp_if_down(struct mpls_interface *mi) {
2987 + if (mi->ldp && mi->ldp->admin_up == MPLS_BOOL_TRUE) {
2988 + ldp_interface_shutdown(mi);
2991 diff --exclude=CVS -uNr zebra/mplsd/ldp_interface.h zebra-ldp/mplsd/ldp_interface.h
2992 --- zebra/mplsd/ldp_interface.h 1969-12-31 18:00:00.000000000 -0600
2993 +++ zebra-ldp/mplsd/ldp_interface.h 2003-02-26 15:47:43.000000000 -0600
2998 +#include "ldp_struct.h"
3000 +struct mpls_interface;
3002 +struct ldp_interface {
3003 + struct mpls_interface *mi;
3004 + ldp_entity entity;
3006 + mpls_bool admin_up;
3007 + mpls_bool create_on_hold;
3010 +struct ldp_interface *ldp_if_new(struct mpls_interface *mi);
3011 +void ldp_if_free(struct ldp_interface *li);
3013 +void ldp_if_up(struct mpls_interface *mi);
3014 +void ldp_if_down(struct mpls_interface *mi);
3016 +int ldp_interface_startup(struct mpls_interface *mi);
3017 +int ldp_interface_shutdown(struct mpls_interface *mi);
3019 +void ldp_interface_create(struct mpls_interface *mi);
3020 +void ldp_interface_delete(struct mpls_interface *mi);
3021 +int ldp_interface_admin_state_start(struct mpls_interface *mi);
3022 +int ldp_interface_admin_state_finish(struct mpls_interface *mi);
3026 diff --exclude=CVS -uNr zebra/mplsd/ldp_vty.c zebra-ldp/mplsd/ldp_vty.c
3027 --- zebra/mplsd/ldp_vty.c 1969-12-31 18:00:00.000000000 -0600
3028 +++ zebra-ldp/mplsd/ldp_vty.c 2003-02-26 15:47:44.000000000 -0600
3033 +#include "ldp_cfg.h"
3034 +#include "ldp_struct.h"
3035 +#include "ldp_interface.h"
3037 +#include "impl_mpls.h"
3040 +#include "mpls_interface.h"
3042 +#include "command.h"
3043 +#include "zclient.h"
3046 +uint32_t ldp_traceflags = 0;
3047 +uint8_t trace_buffer[16834];
3048 +int trace_buffer_len = 0;
3050 +char *session_state[6] = { "NONE", "NON-EXIST", "INIT",
3051 + "OPENSENT", "OPENRECV", "OPERATIONAL" };
3052 +char *adj_role[3] = { "INVALID", "PASSIVE", "ACTIVE" };
3053 +char *attr_state[12] = { "REQ_RECV", "REQ_SENT", "MAP_RECV", "MAP_SENT",
3054 + "WITH_SENT", "WITH_RECV", "NO_LABEL_RESOURCE_SENT",
3055 + "NO_LABEL_RESOURCE_RECV", "ABORT_SENT", "ABORT_RECV",
3056 + "NOTIF_SENT", "NOTIF_RECV" };
3057 +char *oper_state[2] = { "UP", "DOWN" };
3058 +char *control_mode[3] = { "UNKNOWN", "INDEPENDENT", "ORDERED" };
3059 +char *retention_mode[3] = { "UNKNOWN", "LIBERAL", "CONSERVATIVE" };
3060 +char *repair_mode[3] = { "UNKNOWN", "LOCAL", "GLOBAL" };
3061 +char *loop_detect_mode[5] = { "NONE", "HOPCOUNT", "PATHVECTOR",
3062 + "HOPCOUNT PATHVECTOR", "OTHER" };
3063 +char *bool[2] = { "FALSE", "TRUE" };
3064 +char *admin_state[3] = { "NONE", "ENABLED", "DISABLED" };
3065 +char *distribution_mode[2] = { "UNSOLICITED", "ONDEMAND" };
3067 +extern struct zclient *zclient;
3072 + "MPLS configuration\n"
3073 + "Start LDP configuration\n") {
3075 + vty->node = MPLS_LDP_NODE;
3076 + vty->index = ldp_get();
3078 + return CMD_SUCCESS;
3081 +DEFUN (no_mpls_ldp,
3085 + "MPLS configuration\n"
3086 + "Global LDP configuration\n") {
3087 + struct mpls *mpls = mpls_get();
3090 + vty_out (vty, "There isn't active an LDP instance.%s", VTY_NEWLINE);
3091 + return CMD_WARNING;
3094 + ldp_finish(mpls->ldp);
3095 + return CMD_SUCCESS;
3098 +DEFUN (mpls_ldp_lsrid,
3099 + mpls_ldp_lsrid_cmd,
3101 + "LDP Label Switch Router Identifier\n"
3103 + struct ldp *ldp = (struct ldp*)vty->index;
3105 + ldp->lsr_id_is_static = MPLS_BOOL_TRUE;
3107 + ldp_admin_state_start(ldp);
3108 + do_ldp_router_id_update(ldp, ntohl(inet_addr(argv[0])));
3109 + ldp_admin_state_finish(ldp);
3111 + return CMD_SUCCESS;
3114 +DEFUN (no_mpls_ldp_lsrid,
3115 + no_mpls_ldp_lsrid_cmd,
3119 + struct ldp *ldp = (struct ldp*)vty->index;
3121 + ldp->lsr_id_is_static = MPLS_BOOL_FALSE;
3123 + ldp_admin_state_start(ldp);
3124 + do_ldp_router_id_update(ldp, ntohl(ldp->mpls->router_id.u.prefix4.s_addr));
3125 + ldp_admin_state_finish(ldp);
3127 + return CMD_SUCCESS;
3130 +DEFUN (mpls_ldp_disable,
3131 + mpls_ldp_disable_cmd,
3134 + struct ldp *ldp = (struct ldp*)vty->index;
3136 + ldp_admin_state_start(ldp);
3137 + ldp->admin_up = MPLS_BOOL_FALSE;
3138 + ldp_admin_state_finish(ldp);
3140 + return CMD_SUCCESS;
3143 +DEFUN (no_mpls_ldp_disable,
3144 + no_mpls_ldp_disable_cmd,
3148 + struct ldp *ldp = (struct ldp*)vty->index;
3150 + ldp_admin_state_start(ldp);
3151 + ldp->admin_up = MPLS_BOOL_TRUE;
3152 + ldp_admin_state_finish(ldp);
3154 + return CMD_SUCCESS;
3157 +DEFUN (mpls_ldp_lsp_control_mode,
3158 + mpls_ldp_lsp_control_mode_cmd,
3159 + "lsp-control-mode (independent|ordered)",
3161 + "independent or ordered control mode\n") {
3162 + struct ldp *ldp = (struct ldp*)vty->index;
3165 + if (!strcmp(argv[0],"independent")) {
3166 + g.lsp_control_mode = LDP_CONTROL_INDEPENDENT;
3167 + } else if (!strcmp(argv[0],"ordered")) {
3168 + g.lsp_control_mode = LDP_CONTROL_ORDERED;
3170 + return CMD_WARNING;
3173 + ldp_admin_state_start(ldp);
3174 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_CONTROL_MODE);
3175 + ldp_admin_state_finish(ldp);
3177 + return CMD_SUCCESS;
3180 +DEFUN (no_mpls_ldp_lsp_control_mode,
3181 + no_mpls_ldp_lsp_control_mode_cmd,
3182 + "no lsp-control-mode",
3184 + "control mode\n") {
3185 + struct ldp *ldp = (struct ldp*)vty->index;
3188 + g.lsp_control_mode = LDP_GLOBAL_DEF_CONTROL_MODE;
3190 + ldp_admin_state_start(ldp);
3191 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_CONTROL_MODE);
3192 + ldp_admin_state_finish(ldp);
3194 + return CMD_SUCCESS;
3197 +DEFUN (mpls_ldp_label_retention_mode,
3198 + mpls_ldp_label_retention_mode_cmd,
3199 + "label-retention-mode (liberal|conservative)",
3200 + "label retention mode\n"
3201 + "liberal or conservative retention mode\n") {
3202 + struct ldp *ldp = (struct ldp*)vty->index;
3205 + if (!strcmp(argv[0],"liberal")) {
3206 + g.label_retention_mode = LDP_RETENTION_LIBERAL;
3207 + } else if (!strcmp(argv[0],"conservative")) {
3208 + g.label_retention_mode = LDP_RETENTION_CONSERVATIVE;
3210 + return CMD_WARNING;
3213 + ldp_admin_state_start(ldp);
3214 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_RETENTION_MODE);
3215 + ldp_admin_state_finish(ldp);
3217 + return CMD_SUCCESS;
3220 +DEFUN (no_mpls_ldp_label_retention_mode,
3221 + no_mpls_ldp_label_retention_mode_cmd,
3222 + "no label-retention-mode",
3224 + "label retiontion mode\n") {
3225 + struct ldp *ldp = (struct ldp*)vty->index;
3228 + g.label_retention_mode = LDP_GLOBAL_DEF_RETENTION_MODE;
3230 + ldp_admin_state_start(ldp);
3231 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_RETENTION_MODE);
3232 + ldp_admin_state_finish(ldp);
3234 + return CMD_SUCCESS;
3237 +DEFUN (mpls_ldp_lsp_repair_mode,
3238 + mpls_ldp_lsp_repair_mode_cmd,
3239 + "lsp-repair-mode (local|global)",
3241 + "local or global repair mode\n") {
3242 + struct ldp *ldp = (struct ldp*)vty->index;
3245 + if (!strcmp(argv[0],"local")) {
3246 + g.lsp_repair_mode = LDP_REPAIR_LOCAL;
3247 + } else if (!strcmp(argv[0],"global")) {
3248 + g.lsp_repair_mode = LDP_REPAIR_GLOBAL;
3250 + return CMD_WARNING;
3252 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_REPAIR_MODE);
3254 + return CMD_SUCCESS;
3257 +DEFUN (no_mpls_ldp_lsp_repair_mode,
3258 + no_mpls_ldp_lsp_repair_mode_cmd,
3259 + "no lsp-repair-mode",
3261 + "repair mode\n") {
3262 + struct ldp *ldp = (struct ldp*)vty->index;
3265 + g.lsp_repair_mode = LDP_GLOBAL_DEF_REPAIR_MODE;
3266 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_REPAIR_MODE);
3268 + return CMD_SUCCESS;
3271 +DEFUN (mpls_ldp_propogate_release,
3272 + mpls_ldp_propogate_release_cmd,
3273 + "propagate-release",
3274 + "propagate release\n") {
3275 + struct ldp *ldp = (struct ldp*)vty->index;
3278 + g.propagate_release = MPLS_BOOL_TRUE;
3279 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_PROPOGATE_RELEASE);
3281 + return CMD_SUCCESS;
3284 +DEFUN (no_mpls_ldp_propogate_release,
3285 + no_mpls_ldp_propogate_release_cmd,
3286 + "no propagate-release",
3288 + "propagate release\n") {
3289 + struct ldp *ldp = (struct ldp*)vty->index;
3292 + g.propagate_release = MPLS_BOOL_FALSE;
3293 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_PROPOGATE_RELEASE);
3295 + return CMD_SUCCESS;
3298 +DEFUN (mpls_ldp_label_merge,
3299 + mpls_ldp_label_merge_cmd,
3301 + "label merge\n") {
3302 + struct ldp *ldp = (struct ldp*)vty->index;
3305 + g.label_merge = MPLS_BOOL_TRUE;
3307 + ldp_admin_state_start(ldp);
3308 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_LABEL_MERGE);
3309 + ldp_admin_state_finish(ldp);
3311 + return CMD_SUCCESS;
3314 +DEFUN (no_mpls_ldp_label_merge,
3315 + no_mpls_ldp_label_merge_cmd,
3318 + "label merge\n") {
3319 + struct ldp *ldp = (struct ldp*)vty->index;
3322 + g.label_merge = MPLS_BOOL_FALSE;
3324 + ldp_admin_state_start(ldp);
3325 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_LABEL_MERGE);
3326 + ldp_admin_state_finish(ldp);
3328 + return CMD_SUCCESS;
3331 +DEFUN (mpls_ldp_loop_detection_mode,
3332 + mpls_ldp_loop_detection_mode_cmd,
3333 + "loop-detection-mode (hop|path|both)",
3334 + "loop detection\n"
3335 + "Path Vector, Hop Count, or both\n") {
3336 + struct ldp *ldp = (struct ldp*)vty->index;
3339 + if (!strncmp(argv[0],"hop",3)) {
3340 + g.loop_detection_mode = LDP_LOOP_HOPCOUNT;
3341 + } else if (!strncmp(argv[0],"path",4)) {
3342 + g.loop_detection_mode = LDP_LOOP_PATHVECTOR;
3343 + } else if (!strncmp(argv[0],"both",4)) {
3344 + g.loop_detection_mode = LDP_LOOP_HOPCOUNT_PATHVECTOR;
3346 + return CMD_WARNING;
3348 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_LOOP_DETECTION_MODE);
3350 + return CMD_SUCCESS;
3353 +DEFUN (no_mpls_ldp_loop_detection_mode,
3354 + no_mpls_ldp_loop_detection_mode_cmd,
3355 + "no loop-detection-mode (path|hop|both)",
3357 + "loop detection\n") {
3358 + struct ldp *ldp = (struct ldp*)vty->index;
3361 + g.loop_detection_mode = LDP_LOOP_NONE;
3362 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_LOOP_DETECTION_MODE);
3364 + return CMD_SUCCESS;
3367 +DEFUN (mpls_ldp_ttl_less_domain,
3368 + mpls_ldp_ttl_less_domain_cmd,
3369 + "ttl-less-domain",
3370 + "TTL-less domain\n") {
3371 + struct ldp *ldp = (struct ldp*)vty->index;
3374 + g.ttl_less_domain = MPLS_BOOL_TRUE;
3375 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_TTLLESS_DOMAIN);
3377 + return CMD_SUCCESS;
3380 +DEFUN (no_mpls_ldp_ttl_less_domain,
3381 + no_mpls_ldp_ttl_less_domain_cmd,
3382 + "no ttl-less-domain",
3384 + "TTL-less domain\n") {
3385 + struct ldp *ldp = (struct ldp*)vty->index;
3388 + g.ttl_less_domain = MPLS_BOOL_FALSE;
3389 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_TTLLESS_DOMAIN);
3391 + return CMD_SUCCESS;
3394 +DEFUN (mpls_ldp_local_tcp_port,
3395 + mpls_ldp_local_tcp_port_cmd,
3396 + "local-tcp-port <1-65535>",
3397 + "local TCP port\n"
3398 + "TCP port number\n") {
3399 + struct ldp *ldp = (struct ldp*)vty->index;
3402 + g.local_tcp_port = atoi(argv[0]);
3404 + ldp_admin_state_start(ldp);
3405 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_LOCAL_TCP_PORT);
3406 + ldp_admin_state_finish(ldp);
3408 + return CMD_SUCCESS;
3411 +DEFUN (no_mpls_ldp_local_tcp_port,
3412 + no_mpls_ldp_local_tcp_port_cmd,
3413 + "no local-tcp-port",
3415 + "local TCP port\n") {
3416 + struct ldp *ldp = (struct ldp*)vty->index;
3419 + g.local_tcp_port = LDP_GLOBAL_DEF_LOCAL_TCP_PORT;
3421 + ldp_admin_state_start(ldp);
3422 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_LOCAL_TCP_PORT);
3423 + ldp_admin_state_finish(ldp);
3425 + return CMD_SUCCESS;
3428 +DEFUN (mpls_ldp_local_udp_port,
3429 + mpls_ldp_local_udp_port_cmd,
3430 + "local-udp-port <1-65535>",
3431 + "local UDP port\n"
3432 + "UDP port number\n") {
3433 + struct ldp *ldp = (struct ldp*)vty->index;
3436 + g.local_udp_port = atoi(argv[0]);
3438 + ldp_admin_state_start(ldp);
3439 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_LOCAL_UDP_PORT);
3440 + ldp_admin_state_finish(ldp);
3442 + return CMD_SUCCESS;
3445 +DEFUN (no_mpls_ldp_local_udp_port,
3446 + no_mpls_ldp_local_udp_port_cmd,
3447 + "no local-udp-port",
3449 + "local UDP port\n") {
3450 + struct ldp *ldp = (struct ldp*)vty->index;
3453 + g.local_udp_port = LDP_GLOBAL_DEF_LOCAL_UDP_PORT;
3455 + ldp_admin_state_start(ldp);
3456 + ldp_cfg_global_set(ldp->h,&g, LDP_GLOBAL_CFG_LOCAL_UDP_PORT);
3457 + ldp_admin_state_finish(ldp);
3459 + return CMD_SUCCESS;
3462 +DEFUN (mpls_ldp_trace_address,
3463 + mpls_ldp_trace_address_cmd,
3466 + "Address PDUs\n") {
3467 + ldp_traceflags |= LDP_TRACE_FLAG_ADDRESS;
3468 + return CMD_SUCCESS;
3471 +DEFUN (mpls_ldp_trace_binding,
3472 + mpls_ldp_trace_binding_cmd,
3475 + "Label Bindings\n") {
3476 + ldp_traceflags |= LDP_TRACE_FLAG_BINDING;
3477 + return CMD_SUCCESS;
3480 +DEFUN (mpls_ldp_trace_debug,
3481 + mpls_ldp_trace_debug_cmd,
3484 + "Debug Messages\n") {
3485 + ldp_traceflags |= LDP_TRACE_FLAG_DEBUG;
3486 + return CMD_SUCCESS;
3489 +DEFUN (mpls_ldp_trace_error,
3490 + mpls_ldp_trace_error_cmd,
3493 + "Error Conditions\n") {
3494 + ldp_traceflags |= LDP_TRACE_FLAG_ERROR;
3495 + return CMD_SUCCESS;
3498 +DEFUN (mpls_ldp_trace_event,
3499 + mpls_ldp_trace_event_cmd,
3503 + ldp_traceflags |= LDP_TRACE_FLAG_EVENT;
3504 + return CMD_SUCCESS;
3507 +DEFUN (mpls_ldp_trace_general,
3508 + mpls_ldp_trace_general_cmd,
3511 + "General Messages\n") {
3512 + ldp_traceflags |= LDP_TRACE_FLAG_GENERAL;
3513 + return CMD_SUCCESS;
3516 +DEFUN (mpls_ldp_trace_init,
3517 + mpls_ldp_trace_init_cmd,
3521 + ldp_traceflags |= LDP_TRACE_FLAG_INIT;
3522 + return CMD_SUCCESS;
3525 +DEFUN (mpls_ldp_trace_label,
3526 + mpls_ldp_trace_label_cmd,
3530 + ldp_traceflags |= LDP_TRACE_FLAG_LABEL;
3531 + return CMD_SUCCESS;
3534 +DEFUN (mpls_ldp_trace_normal,
3535 + mpls_ldp_trace_normal_cmd,
3538 + "Normal Messages\n") {
3539 + ldp_traceflags |= LDP_TRACE_FLAG_NORMAL;
3540 + return CMD_SUCCESS;
3543 +DEFUN (mpls_ldp_trace_notif,
3544 + mpls_ldp_trace_notif_cmd,
3545 + "trace notification",
3547 + "Notification PDUs\n") {
3548 + ldp_traceflags |= LDP_TRACE_FLAG_NOTIF;
3549 + return CMD_SUCCESS;
3552 +DEFUN (mpls_ldp_trace_packet_dump,
3553 + mpls_ldp_trace_packet_dump_cmd,
3554 + "trace packet-dump",
3556 + "Packet Dump\n") {
3557 + ldp_traceflags |= LDP_TRACE_FLAG_PACKET_DUMP;
3558 + return CMD_SUCCESS;
3561 +DEFUN (mpls_ldp_trace_packet,
3562 + mpls_ldp_trace_packet_cmd,
3565 + "Packet tracing\n") {
3566 + ldp_traceflags |= LDP_TRACE_FLAG_PACKET;
3567 + return CMD_SUCCESS;
3570 +DEFUN (mpls_ldp_trace_path,
3571 + mpls_ldp_trace_path_cmd,
3575 + ldp_traceflags |= LDP_TRACE_FLAG_PATH;
3576 + return CMD_SUCCESS;
3579 +DEFUN (mpls_ldp_trace_periodic,
3580 + mpls_ldp_trace_periodic_cmd,
3583 + "Periodic PDUs\n") {
3584 + ldp_traceflags |= LDP_TRACE_FLAG_PERIODIC;
3585 + return CMD_SUCCESS;
3588 +DEFUN (mpls_ldp_trace_policy,
3589 + mpls_ldp_trace_policy_cmd,
3592 + "Policy tracing\n") {
3593 + ldp_traceflags |= LDP_TRACE_FLAG_POLICY;
3594 + return CMD_SUCCESS;
3597 +DEFUN (mpls_ldp_trace_route,
3598 + mpls_ldp_trace_route_cmd,
3601 + "Route Lookup tracing\n") {
3602 + ldp_traceflags |= LDP_TRACE_FLAG_ROUTE;
3603 + return CMD_SUCCESS;
3606 +DEFUN (mpls_ldp_trace_state,
3607 + mpls_ldp_trace_state_cmd,
3610 + "State transitions\n") {
3611 + ldp_traceflags |= LDP_TRACE_FLAG_STATE;
3612 + return CMD_SUCCESS;
3615 +DEFUN (mpls_ldp_trace_task,
3616 + mpls_ldp_trace_task_cmd,
3619 + "Task tracing\n") {
3620 + ldp_traceflags |= LDP_TRACE_FLAG_TASK;
3621 + return CMD_SUCCESS;
3624 +DEFUN (mpls_ldp_trace_timer,
3625 + mpls_ldp_trace_timer_cmd,
3628 + "Timer tracing\n") {
3629 + ldp_traceflags |= LDP_TRACE_FLAG_TIMER;
3630 + return CMD_SUCCESS;
3633 +DEFUN (mpls_ldp_trace_all,
3634 + mpls_ldp_trace_all_cmd,
3637 + "All tracing\n") {
3638 + ldp_traceflags |= LDP_TRACE_FLAG_ALL;
3639 + return CMD_SUCCESS;
3642 +DEFUN (mpls_ldp_trace_none,
3643 + mpls_ldp_trace_none_cmd,
3646 + "Turn off all tracing\n") {
3647 + ldp_traceflags = 0;
3648 + return CMD_SUCCESS;
3651 +/* address and egress changes should result in an event which goes through
3652 + all of the existing FECs/addresses and decides which to withdrawl and then
3653 + ask the system for which additional FECs/addresses should be sent */
3655 +DEFUN (mpls_ldp_address,
3656 + mpls_ldp_address_cmd,
3657 + "address-mode (lsr-id|ldp)",
3658 + "Addresses this LSR will announce\n"
3660 + "Only LDP interfaces\n") {
3661 + struct ldp *ldp = (struct ldp*)vty->index;
3662 + if (!strncmp(argv[0], "lsr-id",6)) {
3663 + ldp->address = LDP_ADDRESS_LSRID;
3664 + } else if (!strncmp(argv[0], "ldp",3)) {
3665 + ldp->address = LDP_ADDRESS_LDP;
3667 + return CMD_WARNING;
3669 + return CMD_SUCCESS;
3672 +DEFUN (no_mpls_ldp_address,
3673 + no_mpls_ldp_address_cmd,
3674 + "no address-mode",
3676 + "Addresses this LSR will announce\n") {
3677 + struct ldp *ldp = (struct ldp*)vty->index;
3678 + ldp->address = LDP_ADDRESS_ALL;
3679 + return CMD_SUCCESS;
3682 +DEFUN (mpls_ldp_egress,
3683 + mpls_ldp_egress_cmd,
3684 + "egress (lsr-id|connected)",
3685 + "Filter FECs this LSR will send mappings for\n"
3687 + "All connected subnets\n") {
3688 + struct ldp *ldp = (struct ldp*)vty->index;
3689 + if (!strncmp(argv[0], "lsr-id",6)) {
3690 + ldp->egress = LDP_EGRESS_LSRID;
3691 + } else if (!strncmp(argv[0], "connected", 9)) {
3692 + ldp->egress = LDP_EGRESS_CONNECTED;
3694 + return CMD_WARNING;
3696 + return CMD_SUCCESS;
3699 +DEFUN (no_mpls_ldp_egress,
3700 + no_mpls_ldp_egress_cmd,
3703 + "Filter FECs this LSR will send mappings for\n") {
3704 + struct ldp *ldp = (struct ldp*)vty->index;
3705 + ldp->egress = LDP_EGRESS_ALL;
3706 + return CMD_SUCCESS;
3710 +DEFUN (mpls_ldp_egress_list,
3711 + mpls_ldp_egress_list_cmd,
3712 + "egress access-list (<1-199>|<1300-2699>|WORD)",
3713 + "Filter FECs this LSR will send mappings for\n"
3714 + "IP access-list number\n"
3715 + "IP access-list number (expanded range)\n"
3716 + "IP Access-list name\n") {
3717 + return CMD_SUCCESS;
3720 +DEFUN (no_mpls_ldp_egress_list,
3721 + no_mpls_ldp_egress_list_cmd,
3722 + "no egress access-list (<1-199>|<1300-2699>|WORD)",
3724 + "Filter FECs this LSR will send mappings for\n"
3725 + "IP access-list number\n"
3726 + "IP access-list number (expanded range)\n"
3727 + "IP Access-list name\n") {
3728 + return CMD_SUCCESS;
3732 +DEFUN (mpls_show_ldp, mpls_show_ldp_cmd,
3735 + "LDP global setting\n") {
3736 + struct mpls *mpls = mpls_get();
3740 + vty_out (vty, "There isn't an active LDP instance.%s", VTY_NEWLINE);
3741 + return CMD_WARNING;
3744 + ldp_cfg_global_get(mpls->ldp->h,&g,0xFFFFFFFF);
3746 + vty_out(vty, "LSR-ID: %08x Admin State: %s%s",
3747 + g.lsr_identifier.u.ipv4, admin_state[g.admin_state], VTY_NEWLINE);
3748 + vty_out(vty, "Transport Address: %08x%s", g.transport_address.u.ipv4,
3750 + vty_out(vty, "Control Mode: %s\tRepair Mode: %s%s",
3751 + control_mode[g.lsp_control_mode], repair_mode[g.lsp_repair_mode],
3753 + vty_out(vty, "Propogate Release: %s\tLabel Merge: %s%s",
3754 + bool[g.propagate_release], bool[g.label_merge], VTY_NEWLINE);
3755 + vty_out(vty, "Retention Mode: %s\tLoop Detection Mode: %s%s",
3756 + retention_mode[g.label_retention_mode],
3757 + loop_detect_mode[g.loop_detection_mode], VTY_NEWLINE);
3758 + vty_out(vty, "TTL-less-domain: %s%s", bool[g.ttl_less_domain],
3760 + vty_out(vty, "Local TCP Port: %d\tLocal UDP Port: %d%s",
3761 + g.local_tcp_port, g.local_udp_port, VTY_NEWLINE);
3762 + vty_out(vty, "Keep-alive Time: %d\tKeep-alive Interval: %d%s",
3763 + g.keepalive_timer, g.keepalive_interval, VTY_NEWLINE);
3764 + vty_out(vty, "Hello Time: %d\tHello Interval: %d%s",
3765 + g.hellotime_timer, g.hellotime_interval, VTY_NEWLINE);
3767 + return CMD_SUCCESS;
3770 +void convert_seconds_to_string(uint32_t secs, char* buf) {
3779 + mins = div(secs, 60);
3780 + if (mins.quot >= 60) {
3781 + hours = div(mins.quot, 60);
3782 + if (hours.quot >= 24) {
3783 + days = div(hours.quot, 24);
3787 + sprintf(buf, "%dd %02d:%02d:%02d", days.quot, h, m, s);
3804 + sprintf(buf,"%02d:%02d:%02d", h, m, s);
3807 +DEFUN (mpls_show_ldp_neighbor, mpls_show_ldp_neighbor_cmd,
3808 + "show ldp neighbor",
3810 + "LDP related commands\n"
3811 + "Discovered neighbors\n"
3812 + "LDP identifier\n") {
3813 + struct mpls *mpls = mpls_get();
3814 + struct ldp *ldp = mpls->ldp;
3822 + uint32_t time_now;
3823 + char time_buf[13];
3824 + struct in_addr lsr;
3825 + struct in_addr src;
3826 + struct in_addr tr;
3827 + int label_space = 0;
3833 +Peer LDP Ident: 7.1.1.1:0; Local LDP Ident 8.1.1.1:0
3834 + TCP connection: 7.1.1.1.646 - 8.1.1.1.11006
3835 + State: Oper; Msgs sent/rcvd: 4/411; Downstream
3837 + LDP discovery sources:
3839 + Addresses bound to peer LDP Ident:
3840 + 2.0.0.29 7.1.1.1 59.0.0.199 212.10.1.1
3846 + vty_out (vty, "There isn't an active LDP instance.%s", VTY_NEWLINE);
3847 + return CMD_WARNING;
3850 + ldp_cfg_global_get(ldp->h,&g,0xFFFFFFFF);
3854 + while (ldp_cfg_adj_getnext(ldp->h, &adj, 0xFFFFFFFF) ==
3858 + if (adj.entity_index) {
3859 + e.index = adj.entity_index;
3860 + ldp_cfg_entity_get(ldp->h,&e,0xFFFFFFFF);
3861 + if (e.entity_type == LDP_DIRECT) {
3862 + iff.index = e.sub_index;
3863 + ldp_cfg_if_get(ldp->h,&iff,0xFFFFFFFF);
3864 + label_space = iff.label_space;
3866 + peer.index = e.sub_index;
3867 + ldp_cfg_peer_get(ldp->h,&peer,0xFFFFFFFF);
3868 + label_space = peer.label_space;
3872 + lsr.s_addr = htonl(adj.remote_lsr_address.u.ipv4);
3873 + vty_out(vty, "Peer LDP Ident: %s:%d; Local LDP Ident: ", inet_ntoa(lsr),
3874 + adj.remote_label_space);
3875 + lsr.s_addr = htonl(g.lsr_identifier.u.ipv4);
3876 + vty_out(vty, "%s:%d%s", inet_ntoa(lsr), label_space, VTY_NEWLINE);
3878 + if (adj.session_index) {
3879 + s.index = adj.session_index;
3881 + if (ldp_cfg_session_get(ldp->h,&s,0xFFFFFFFF) != MPLS_SUCCESS) {
3886 + vty_out(vty, "\tTCP connection: %s.%d", inet_ntoa(tr),
3887 + g.local_tcp_port);
3889 + src.s_addr = htonl(s.remote_dest.addr.u.ipv4);
3890 + vty_out(vty, " - %s.%d%s", inet_ntoa(src), s.remote_dest.port,
3893 + vty_out(vty, "\tState: %s; Msgs sent/recv: %d/%d; %s%s",
3894 + session_state[s.state], s.mesg_tx, s.mesg_rx,
3895 + distribution_mode[s.oper_distribution_mode], VTY_NEWLINE);
3896 + time_now = time(NULL);
3897 + convert_seconds_to_string(time_now - s.oper_up, time_buf);
3898 + vty_out(vty, "\tUp time: %s%s", time_buf, VTY_NEWLINE);
3900 + vty_out(vty, "\tLDP discovery sources:%s", VTY_NEWLINE);
3902 + vty_out(vty, "\tTCP connection: %s%s", "n/a", VTY_NEWLINE);
3903 + vty_out(vty, "\tState: discovery; Msgs sent/recv: -/-;%s",VTY_NEWLINE);
3904 + vty_out(vty, "\tUp time: %s%s", "-", VTY_NEWLINE);
3905 + vty_out(vty, "\tLDP discovery sources:%s", VTY_NEWLINE);
3907 + vty_out(vty, "\t ");
3909 + if (e.entity_type == LDP_DIRECT) {
3910 + vty_out(vty, "%s ", iff.name);
3912 + vty_out(vty, "%s ", peer.peer_name);
3914 + vty_out(vty, "%s", VTY_NEWLINE);
3916 + if (adj.session_index) {
3917 + vty_out(vty, "\tAddresses bound to peer:%s", VTY_NEWLINE);
3921 + while (ldp_cfg_session_raddr_getnext(ldp->h, &s, &addr, 0xFFFFFFFF) ==
3923 + lsr.s_addr = htonl(addr.address.u.ipv4);
3924 + vty_out(vty, "\t");
3925 + if (!addr_count) {
3926 + vty_out(vty, " ");
3929 + vty_out(vty, "%s",inet_ntoa(lsr));
3932 + if (addr_count == 4) {
3933 + vty_out(vty, "%s", VTY_NEWLINE);
3937 + vty_out(vty, "%s", VTY_NEWLINE);
3940 + vty_out(vty, "%s", VTY_NEWLINE);
3942 + vty_out(vty, "\tNo discovered neighbors%s", VTY_NEWLINE);
3944 + vty_out(vty, "%s", VTY_NEWLINE);
3946 + return CMD_SUCCESS;
3949 +DEFUN (mpls_show_ldp_session, mpls_show_ldp_session_cmd,
3950 + "show ldp session [A.B.C.D:E]",
3952 + "LDP related commands\n"
3953 + "Session information\n"
3954 + "LDP identifier\n") {
3955 + struct mpls *mpls = mpls_get();
3956 + struct ldp *ldp = mpls->ldp;
3957 + ldp_session session;
3959 + struct in_addr in;
3963 + vty_out (vty, "There isn't active LDP instance.%s", VTY_NEWLINE);
3964 + return CMD_WARNING;
3967 + session.index = 0;
3968 + while (ldp_cfg_session_getnext(ldp->h, &session, 0xFFFFFFFF) == MPLS_SUCCESS) {
3970 + in.s_addr = htonl(session.remote_dest.addr.u.ipv4);
3971 + vty_out(vty, "%-2d %s %-3d %s%s", session.index,
3972 + inet_ntoa(in), session.oper_keepalive,
3973 + session_state[session.state], VTY_NEWLINE);
3975 + while (ldp_cfg_session_raddr_getnext(ldp->h, &session,
3976 + &addr, 0xFFFFFFFF) == MPLS_SUCCESS) {
3977 + in.s_addr = htonl(addr.address.u.ipv4);
3978 + vty_out(vty, "\t%s%s",inet_ntoa(in), VTY_NEWLINE);
3982 + vty_out(vty, " no established sessions%s", VTY_NEWLINE);
3985 + return CMD_SUCCESS;
3988 +DEFUN (mpls_show_ldp_discovery, mpls_show_ldp_discovery_cmd,
3989 + "show ldp discovery",
3991 + "LDP related commands\n"
3992 + "Discovery information\n") {
3993 + struct mpls *mpls = mpls_get();
3994 + struct ldp *ldp = mpls->ldp;
3999 + ldp_entity entity;
4001 + struct in_addr dst;
4005 + vty_out (vty, "There isn't an active LDP instance.%s", VTY_NEWLINE);
4006 + return CMD_WARNING;
4009 + vty_out(vty, "%s", VTY_NEWLINE);
4011 + ldp_cfg_global_get(ldp->h,&g,0xFFFFFFFF);
4012 + dst.s_addr = htonl(g.lsr_identifier.u.ipv4);
4013 + vty_out(vty, "Local LSR Identifier: %s%s", inet_ntoa(dst), VTY_NEWLINE);
4014 + vty_out(vty, "%s", VTY_NEWLINE);
4015 + vty_out(vty, "Interface Discovery Sources:%s", VTY_NEWLINE);
4019 + while (ldp_cfg_if_getnext(ldp->h, &iff, 0xFFFFFFFF) == MPLS_SUCCESS) {
4022 + vty_out(vty, "\t%s: ", iff.name);
4023 + if (iff.oper_state != MPLS_OPER_UP) {
4024 + vty_out(vty, "down");
4026 + vty_out(vty, "xmit");
4027 + entity.index = iff.entity_index;
4028 + if (ldp_cfg_entity_get(ldp->h, &entity, 0xFFFFFFFF) != MPLS_SUCCESS) {
4032 + adj.index = entity.adj_index;
4033 + if (ldp_cfg_adj_get(ldp->h, &adj, 0xFFFFFFFF) == MPLS_SUCCESS) {
4035 + vty_out(vty, "/recv%s", VTY_NEWLINE);
4038 + dst.s_addr = htonl(adj.remote_lsr_address.u.ipv4);
4039 + vty_out(vty, "\t LDP Id: %s:%d%s ", inet_ntoa(dst),
4040 + adj.remote_label_space, VTY_NEWLINE);
4042 + } while (ldp_cfg_entity_adj_getnext(ldp->h, &entity) == MPLS_SUCCESS);
4045 + vty_out(vty, "%s", VTY_NEWLINE);
4049 + vty_out(vty, "\tNo configured interfaces%s", VTY_NEWLINE);
4052 + vty_out(vty, "%s", VTY_NEWLINE);
4053 + vty_out(vty, "Targeted Discovery Sources:%s", VTY_NEWLINE);
4057 + while (ldp_cfg_peer_getnext(ldp->h, &peer, 0xFFFFFFFF) ==
4061 + dst.s_addr = htonl(peer.dest.addr.u.ipv4);
4062 + vty_out(vty, "\t%s: xmit ", inet_ntoa(dst));
4063 + while (ldp_cfg_adj_getnext(ldp->h, &adj, 0xFFFFFFFF) == MPLS_SUCCESS) {
4064 + if (peer.entity_index == adj.entity_index) {
4066 + vty_out(vty, "/recv%s", VTY_NEWLINE);
4069 + dst.s_addr = htonl(adj.remote_lsr_address.u.ipv4);
4070 + vty_out(vty, "\t LDP Id: %s:%d%s ", inet_ntoa(dst),
4071 + adj.remote_label_space, VTY_NEWLINE);
4075 + vty_out(vty, "%s", VTY_NEWLINE);
4079 + vty_out(vty, "\tNo configured peers%s", VTY_NEWLINE);
4081 + vty_out(vty, "%s", VTY_NEWLINE);
4083 + return CMD_SUCCESS;
4086 +void ldp_print_label(struct vty *vty, mpls_label_struct *l) {
4088 + case MPLS_LABEL_TYPE_NONE:
4089 + vty_out(vty, "label: unknown");
4091 + case MPLS_LABEL_TYPE_GENERIC:
4092 + vty_out(vty, "label: gen %d",l->u.gen);
4094 + case MPLS_LABEL_TYPE_ATM:
4095 + vty_out(vty, "label: atm %d/%d",l->u.atm.vpi,l->u.atm.vci);
4097 + case MPLS_LABEL_TYPE_FR:
4098 + vty_out(vty, "label: dlci %d",l->u.fr.dlci);
4103 +DEFUN (mpls_show_ldp_database, mpls_show_ldp_database_cmd,
4104 + "show ldp database [A.B.C.D:E]",
4106 + "LDP related commands\n"
4107 + "Labeling information\n"
4108 + "LDP identifier\n") {
4109 + struct mpls *mpls = mpls_get();
4110 + struct ldp *ldp = mpls->ldp;
4111 + ldp_session session;
4117 + struct in_addr fec;
4120 + vty_out (vty, "There isn't an active LDP instance.%s", VTY_NEWLINE);
4121 + return CMD_WARNING;
4125 + while (ldp_cfg_attr_getnext(ldp->h, &attr, 0xFFFFFFFF) == MPLS_SUCCESS) {
4128 + fec.s_addr = htonl(attr.fecTlv.fecElArray[0].addressEl.address);
4130 + vty_out(vty, " %s/%d ", inet_ntoa(fec),
4131 + attr.fecTlv.fecElArray[0].addressEl.preLen);
4133 + session.index = attr.session_index;
4134 + if (ldp_cfg_session_get(ldp->h, &session, 0xFFFFFFFF) != MPLS_SUCCESS) {
4135 + vty_out(vty, "no session%s",VTY_NEWLINE);
4139 + adj.index = session.adj_index;
4140 + if (ldp_cfg_adj_get(ldp->h, &adj, 0xFFFFFFFF) != MPLS_SUCCESS) {
4141 + vty_out(vty, "no adj%s",VTY_NEWLINE);
4145 + switch(attr.state) {
4146 + case LDP_LSP_STATE_MAP_RECV:
4147 + vty_out(vty, "remote binding: ");
4148 + out.index = attr.outlabel_index;
4149 + if (ldp_cfg_outlabel_get(ldp->h, &out, 0xFFFFFFFF) != MPLS_SUCCESS) {
4150 + vty_out(vty, "no outlabel");
4152 + ldp_print_label(vty,&out.info.label);
4154 + fec.s_addr = htonl(adj.remote_lsr_address.u.ipv4);
4155 + vty_out(vty, " lsr: %s:%d ", inet_ntoa(fec), adj.remote_label_space);
4156 + if (attr.ingress == MPLS_BOOL_TRUE) {
4157 + vty_out(vty, "ingress");
4160 + case LDP_LSP_STATE_MAP_SENT:
4161 + in.index = attr.inlabel_index;
4162 + if (ldp_cfg_inlabel_get(ldp->h, &in, 0xFFFFFFFF) != MPLS_SUCCESS) {
4163 + vty_out(vty, "no inlabel%s", VTY_NEWLINE);
4166 + vty_out(vty, "local binding: ");
4167 + ldp_print_label(vty,&in.info.label);
4169 + case LDP_LSP_STATE_WITH_SENT:
4170 + case LDP_LSP_STATE_WITH_RECV:
4171 + case LDP_LSP_STATE_NO_LABEL_RESOURCE_SENT:
4172 + case LDP_LSP_STATE_NO_LABEL_RESOURCE_RECV:
4173 + case LDP_LSP_STATE_ABORT_SENT:
4174 + case LDP_LSP_STATE_ABORT_RECV:
4175 + case LDP_LSP_STATE_NOTIF_SENT:
4176 + case LDP_LSP_STATE_NOTIF_RECV:
4177 + case LDP_LSP_STATE_REQ_RECV:
4178 + case LDP_LSP_STATE_REQ_SENT:
4179 + vty_out(vty, "%s:\t", attr_state[attr.state]);
4180 + fec.s_addr = htonl(adj.remote_lsr_address.u.ipv4);
4181 + vty_out(vty, "lsr: %s:%d", inet_ntoa(fec), adj.remote_label_space);
4186 + vty_out(vty, "%s", VTY_NEWLINE);
4189 + vty_out(vty, " no labeling info has been exchanged%s", VTY_NEWLINE);
4192 + return CMD_SUCCESS;
4198 + "MPLS interface configuration\n"
4200 + struct interface *ifp = vty->index;
4201 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4202 + struct mpls *mpls = mi->mpls;
4205 + /* user is trying to create a new LDP interface */
4206 + /* if a labelspace hasn't been set yet, set it to 0 */
4207 + if (mi->labelspace == -1) {
4208 + mi->labelspace = 0;
4209 + do_mpls_labelspace(mi);
4211 + mi->ldp = ldp_if_new(mi);
4214 + /* if the global LDP has been created, go ahead and tell LDP about it
4215 + * otherwise just mark the interface as "on hold"
4218 + ldp_interface_create(mi);
4220 + mi->ldp->create_on_hold = MPLS_BOOL_TRUE;
4223 + vty->node = MPLS_LDP_IF_NODE;
4225 + return CMD_SUCCESS;
4232 + "MPLS interface configuration\n"
4234 + struct interface *ifp = vty->index;
4235 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4238 + ldp_interface_delete(mi);
4239 + ldp_if_free(mi->ldp);
4242 + return CMD_SUCCESS;
4245 +DEFUN(ldp_if_distribution_mode,
4246 + ldp_if_distribution_mode_cmd,
4247 + "distribution-mode (dod|du)",
4248 + "MPLS interface configuration\n"
4249 + "distribution mode\n"
4250 + "Downstream on Demand or Downstream unsolicited\n") {
4251 + struct interface *ifp = vty->index;
4252 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4253 + struct ldp_interface *li = mi->ldp;
4254 + struct mpls *mpls = mi->mpls;
4255 + struct ldp *ldp = mpls->ldp;
4257 + if (!strncmp(argv[0],"dod",3)) {
4258 + li->entity.label_distribution_mode = LDP_DISTRIBUTION_ONDEMAND;
4259 + } else if (!strncmp(argv[0],"du",2)) {
4260 + li->entity.label_distribution_mode = LDP_DISTRIBUTION_UNSOLICITED;
4262 + return CMD_WARNING;
4266 + li->create_on_hold = MPLS_BOOL_TRUE;
4267 + return CMD_SUCCESS;
4269 + ldp_interface_admin_state_start(mi);
4270 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_DISTRIBUTION_MODE);
4271 + ldp_interface_admin_state_finish(mi);
4272 + return CMD_SUCCESS;
4275 +DEFUN(no_ldp_if_distribution_mode,
4276 + no_ldp_if_distribution_mode_cmd,
4277 + "no distribution-mode",
4279 + "MPLS interface configuration\n"
4280 + "distribution mode\n") {
4281 + struct interface *ifp = vty->index;
4282 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4283 + struct ldp_interface *li = mi->ldp;
4284 + struct mpls *mpls = mi->mpls;
4285 + struct ldp *ldp = mpls->ldp;
4287 + li->entity.label_distribution_mode = LDP_ENTITY_DEF_DISTRIBUTION_MODE;
4289 + li->create_on_hold = MPLS_BOOL_TRUE;
4290 + return CMD_SUCCESS;
4293 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_DISTRIBUTION_MODE);
4294 + return CMD_SUCCESS;
4297 +DEFUN(ldp_if_remote_tcp_port,
4298 + ldp_if_remote_tcp_port_cmd,
4299 + "remote-tcp-port <1-65535>",
4300 + "MPLS interface configuration\n"
4301 + "remote LDP port\n"
4302 + "port number\n") {
4303 + struct interface *ifp = vty->index;
4304 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4305 + struct ldp_interface *li = mi->ldp;
4306 + struct mpls *mpls = mi->mpls;
4307 + struct ldp *ldp = mpls->ldp;
4309 + li->entity.remote_tcp_port = atoi(argv[0]);
4311 + li->create_on_hold = MPLS_BOOL_TRUE;
4312 + return CMD_SUCCESS;
4315 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_REMOTE_TCP);
4316 + return CMD_SUCCESS;
4319 +DEFUN(no_ldp_if_remote_tcp_port,
4320 + no_ldp_if_remote_tcp_port_cmd,
4321 + "no remote-tcp-port",
4323 + "MPLS interface configuration\n"
4324 + "remote LDP port\n") {
4325 + struct interface *ifp = vty->index;
4326 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4327 + struct ldp_interface *li = mi->ldp;
4328 + struct mpls *mpls = mi->mpls;
4330 + li->entity.remote_tcp_port = LDP_ENTITY_DEF_REMOTE_TCP;
4332 + li->create_on_hold = MPLS_BOOL_TRUE;
4333 + return CMD_SUCCESS;
4336 + ldp_cfg_entity_set(mpls->ldp->h, &li->entity, LDP_ENTITY_CFG_REMOTE_TCP);
4337 + return CMD_SUCCESS;
4340 +DEFUN(ldp_if_remote_udp_port,
4341 + ldp_if_remote_udp_port_cmd,
4342 + "remote-udp-port <1-65535>",
4343 + "MPLS interface configuration\n"
4344 + "remote LDP port\n"
4345 + "port number\n") {
4346 + struct interface *ifp = vty->index;
4347 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4348 + struct ldp_interface *li = mi->ldp;
4349 + struct mpls *mpls = mi->mpls;
4350 + struct ldp *ldp = mpls->ldp;
4352 + li->entity.remote_udp_port = atoi(argv[0]);
4354 + li->create_on_hold = MPLS_BOOL_TRUE;
4355 + return CMD_SUCCESS;
4358 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_REMOTE_UDP);
4359 + return CMD_SUCCESS;
4362 +DEFUN(no_ldp_if_remote_udp_port,
4363 + no_ldp_if_remote_udp_port_cmd,
4364 + "no remote-udp-port",
4366 + "MPLS interface configuration\n"
4367 + "remote LDP port\n") {
4368 + struct interface *ifp = vty->index;
4369 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4370 + struct ldp_interface *li = mi->ldp;
4371 + struct mpls *mpls = mi->mpls;
4372 + struct ldp *ldp = mpls->ldp;
4374 + li->entity.remote_udp_port = LDP_ENTITY_DEF_REMOTE_UDP;
4376 + li->create_on_hold = MPLS_BOOL_TRUE;
4377 + return CMD_SUCCESS;
4380 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_REMOTE_UDP);
4381 + return CMD_SUCCESS;
4384 +DEFUN(ldp_if_max_pdu,
4385 + ldp_if_max_pdu_cmd,
4386 + "max-pdu <64-9182>",
4387 + "MPLS interface configuration\n"
4388 + "maximum LDP PDU size\n"
4390 + struct interface *ifp = vty->index;
4391 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4392 + struct ldp_interface *li = mi->ldp;
4393 + struct mpls *mpls = mi->mpls;
4394 + struct ldp *ldp = mpls->ldp;
4396 + li->entity.max_pdu = atoi(argv[0]);
4398 + li->create_on_hold = MPLS_BOOL_TRUE;
4399 + return CMD_SUCCESS;
4402 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_MAX_PDU);
4403 + return CMD_SUCCESS;
4406 +DEFUN(no_ldp_if_max_pdu,
4407 + no_ldp_if_max_pdu_cmd,
4410 + "MPLS interface configuration\n"
4411 + "maximum LDP pdu size\n") {
4412 + struct interface *ifp = vty->index;
4413 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4414 + struct ldp_interface *li = mi->ldp;
4415 + struct mpls *mpls = mi->mpls;
4416 + struct ldp *ldp = mpls->ldp;
4418 + li->entity.max_pdu = LDP_ENTITY_DEF_MAX_PDU;
4420 + li->create_on_hold = MPLS_BOOL_TRUE;
4421 + return CMD_SUCCESS;
4424 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_MAX_PDU);
4425 + return CMD_SUCCESS;
4428 +DEFUN(ldp_if_hello_interval,
4429 + ldp_if_hello_interval_cmd,
4430 + "hello-interval <1-60>",
4431 + "MPLS interface configuration\n"
4432 + "hello interval\n"
4433 + "interval in seconds\n") {
4434 + struct interface *ifp = vty->index;
4435 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4436 + struct ldp_interface *li = mi->ldp;
4437 + struct mpls *mpls = mi->mpls;
4438 + struct ldp *ldp = mpls->ldp;
4440 + li->entity.hellotime_interval = atoi(argv[0]);
4442 + li->create_on_hold = MPLS_BOOL_TRUE;
4443 + return CMD_SUCCESS;
4446 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_HELLOTIME_INTERVAL);
4447 + return CMD_SUCCESS;
4450 +DEFUN(no_ldp_if_hello_interval,
4451 + no_ldp_if_hello_interval_cmd,
4452 + "no hello-interval",
4454 + "MPLS interface configuration\n"
4455 + "hello interval\n") {
4456 + struct interface *ifp = vty->index;
4457 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4458 + struct ldp_interface *li = mi->ldp;
4459 + struct mpls *mpls = mi->mpls;
4460 + struct ldp *ldp = mpls->ldp;
4462 + li->entity.hellotime_interval = LDP_ENTITY_DEF_HELLOTIME_INTERVAL;
4464 + li->create_on_hold = MPLS_BOOL_TRUE;
4465 + return CMD_SUCCESS;
4468 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_HELLOTIME_INTERVAL);
4469 + return CMD_SUCCESS;
4472 +DEFUN(ldp_if_keepalive_interval,
4473 + ldp_if_keepalive_interval_cmd,
4474 + "keepalive-interval <1-60>",
4475 + "MPLS interface configuration\n"
4476 + "keepalive interval\n"
4477 + "interval in seconds\n") {
4478 + struct interface *ifp = vty->index;
4479 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4480 + struct ldp_interface *li = mi->ldp;
4481 + struct mpls *mpls = mi->mpls;
4482 + struct ldp *ldp = mpls->ldp;
4484 + li->entity.keepalive_interval = atoi(argv[0]);
4486 + li->create_on_hold = MPLS_BOOL_TRUE;
4487 + return CMD_SUCCESS;
4490 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_KEEPALIVE_INTERVAL);
4491 + return CMD_SUCCESS;
4494 +DEFUN(no_ldp_if_keepalive_interval,
4495 + no_ldp_if_keepalive_interval_cmd,
4496 + "no keepalive-interval",
4498 + "MPLS interface configuration\n"
4499 + "keepalive interval\n") {
4500 + struct interface *ifp = vty->index;
4501 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4502 + struct ldp_interface *li = mi->ldp;
4503 + struct mpls *mpls = mi->mpls;
4504 + struct ldp *ldp = mpls->ldp;
4506 + li->entity.keepalive_interval = LDP_ENTITY_DEF_KEEPALIVE_INTERVAL;
4508 + li->create_on_hold = MPLS_BOOL_TRUE;
4509 + return CMD_SUCCESS;
4512 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_KEEPALIVE_INTERVAL);
4513 + return CMD_SUCCESS;
4516 +DEFUN(ldp_if_max_session_attempt,
4517 + ldp_if_max_session_attempt_cmd,
4518 + "max-session-attempt <0-1024>",
4519 + "MPLS interface configuration\n"
4520 + "maximum LDP session setup attempt\n"
4521 + "Number of attempts (0 means keep trying)\n") {
4522 + struct interface *ifp = vty->index;
4523 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4524 + struct ldp_interface *li = mi->ldp;
4525 + struct mpls *mpls = mi->mpls;
4526 + struct ldp *ldp = mpls->ldp;
4528 + li->entity.session_setup_count = atoi(argv[0]);
4530 + li->create_on_hold = MPLS_BOOL_TRUE;
4531 + return CMD_SUCCESS;
4534 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_SESSION_SETUP_COUNT);
4535 + return CMD_SUCCESS;
4538 +DEFUN(no_ldp_if_max_session_attempt,
4539 + no_ldp_if_max_session_attempt_cmd,
4540 + "no max-session-attempt\n",
4542 + "MPLS interface configuration\n"
4543 + "maximum LDP session setup attempt\n") {
4544 + struct interface *ifp = vty->index;
4545 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4546 + struct ldp_interface *li = mi->ldp;
4547 + struct mpls *mpls = mi->mpls;
4548 + struct ldp *ldp = mpls->ldp;
4550 + li->entity.session_setup_count = LDP_ENTITY_DEF_SESSIONSETUP_COUNT;
4552 + li->create_on_hold = MPLS_BOOL_TRUE;
4553 + return CMD_SUCCESS;
4556 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_SESSION_SETUP_COUNT);
4557 + return CMD_SUCCESS;
4560 +DEFUN(ldp_if_max_path_vector,
4561 + ldp_if_max_path_vector_cmd,
4562 + "max-path-vector <1-255>",
4563 + "MPLS interface configuration\n"
4564 + "maximum path vector\n"
4565 + "number of entries\n") {
4566 + struct interface *ifp = vty->index;
4567 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4568 + struct ldp_interface *li = mi->ldp;
4569 + struct mpls *mpls = mi->mpls;
4570 + struct ldp *ldp = mpls->ldp;
4572 + li->entity.path_vector_limit = atoi(argv[0]);
4574 + li->create_on_hold = MPLS_BOOL_TRUE;
4575 + return CMD_SUCCESS;
4578 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_PATHVECTOR_LIMIT);
4579 + return CMD_SUCCESS;
4582 +DEFUN(no_ldp_if_max_path_vector,
4583 + no_ldp_if_max_path_vector_cmd,
4584 + "no max-path-vector",
4586 + "MPLS interface configuration\n"
4587 + "maximum path vector\n") {
4588 + struct interface *ifp = vty->index;
4589 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4590 + struct ldp_interface *li = mi->ldp;
4591 + struct mpls *mpls = mi->mpls;
4592 + struct ldp *ldp = mpls->ldp;
4594 + li->entity.path_vector_limit = LDP_ENTITY_DEF_PATHVECTOR_LIMIT;
4596 + li->create_on_hold = MPLS_BOOL_TRUE;
4597 + return CMD_SUCCESS;
4600 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_PATHVECTOR_LIMIT);
4601 + return CMD_SUCCESS;
4604 +DEFUN(ldp_if_max_hop_count,
4605 + ldp_if_max_hop_count_cmd,
4606 + "max-hop-count <1-1024>",
4607 + "MPLS interface configuration\n"
4608 + "maximum hop count\n"
4609 + "number of hops\n") {
4610 + struct interface *ifp = vty->index;
4611 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4612 + struct ldp_interface *li = mi->ldp;
4613 + struct mpls *mpls = mi->mpls;
4614 + struct ldp *ldp = mpls->ldp;
4616 + li->entity.hop_count_limit = atoi(argv[0]);
4618 + li->create_on_hold = MPLS_BOOL_TRUE;
4619 + return CMD_SUCCESS;
4622 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_HOPCOUNT_LIMIT);
4623 + return CMD_SUCCESS;
4626 +DEFUN(no_ldp_if_max_hop_count,
4627 + no_ldp_if_max_hop_count_cmd,
4628 + "no max-hop-count",
4630 + "MPLS interface configuration\n"
4631 + "maximum hop count\n") {
4632 + struct interface *ifp = vty->index;
4633 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4634 + struct ldp_interface *li = mi->ldp;
4635 + struct mpls *mpls = mi->mpls;
4636 + struct ldp *ldp = mpls->ldp;
4638 + li->entity.hop_count_limit = LDP_ENTITY_DEF_HOPCOUNT_LIMIT;
4640 + li->create_on_hold = MPLS_BOOL_TRUE;
4641 + return CMD_SUCCESS;
4644 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_HOPCOUNT_LIMIT);
4645 + return CMD_SUCCESS;
4648 +DEFUN(ldp_if_max_label_requests,
4649 + ldp_if_max_label_requests_cmd,
4650 + "max-label-requests <0-1024>",
4651 + "MPLS interface configuration\n"
4652 + "maximum times to make a request for a FEC\n"
4653 + "Number of attempts (0 means keep trying)\n") {
4654 + struct interface *ifp = vty->index;
4655 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4656 + struct ldp_interface *li = mi->ldp;
4657 + struct mpls *mpls = mi->mpls;
4658 + struct ldp *ldp = mpls->ldp;
4660 + li->entity.label_request_count = atoi(argv[0]);
4662 + li->create_on_hold = MPLS_BOOL_TRUE;
4663 + return CMD_SUCCESS;
4666 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_REQUEST_COUNT);
4667 + return CMD_SUCCESS;
4670 +DEFUN(no_ldp_if_max_label_requests,
4671 + no_ldp_if_max_label_requests_cmd,
4672 + "no max-label-requests",
4674 + "MPLS interface configuration\n"
4675 + "maximum times to make a request for a FEC\n") {
4676 + struct interface *ifp = vty->index;
4677 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4678 + struct ldp_interface *li = mi->ldp;
4679 + struct mpls *mpls = mi->mpls;
4680 + struct ldp *ldp = mpls->ldp;
4682 + li->entity.label_request_count = LDP_ENTITY_DEF_REQUEST_COUNT;
4684 + li->create_on_hold = MPLS_BOOL_TRUE;
4685 + return CMD_SUCCESS;
4688 + ldp_cfg_entity_set(ldp->h, &li->entity, LDP_ENTITY_CFG_REQUEST_COUNT);
4689 + return CMD_SUCCESS;
4693 +DEFUN(ldp_if_ttl_less_domain,
4694 + ldp_if_ttl_less_domain_cmd,
4695 + "ttl-less-domain",
4696 + "MPLS interface configuration\n"
4697 + "TTL less domain\n") {
4698 + struct interface *ifp = vty->index;
4699 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4700 + struct ldp_interface *li = mi->ldp;
4701 + struct mpls *mpls = mi->mpls;
4702 + struct ldp *ldp = mpls->ldp;
4704 + li->entity.remote_in_ttl_less_domain = MPLS_BOOL_TRUE;
4706 + li->create_on_hold = MPLS_BOOL_TRUE;
4707 + return CMD_SUCCESS;
4710 + return CMD_SUCCESS;
4713 +DEFUN(no_ldp_if_ttl_less_domain,
4714 + no_ldp_if_ttl_less_domain_cmd,
4715 + "no ttl-less-domain",
4717 + "MPLS interface configuration\n"
4718 + "TTL less domain\n") {
4719 + struct interface *ifp = vty->index;
4720 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
4721 + struct ldp_interface *li = mi->ldp;
4722 + struct mpls *mpls = mi->mpls;
4723 + struct ldp *ldp = mpls->ldp;
4725 + li->entity.remote_in_ttl_less_domain = MPLS_BOOL_FALSE;
4727 + return CMD_SUCCESS;
4730 + return CMD_SUCCESS;
4734 +static int ldp_if_config_write (struct vty *vty) {
4738 +static int ldp_config_write (struct vty *vty) {
4739 + struct mpls *mpls = mpls_get();
4740 + struct ldp *ldp = mpls->ldp;
4745 + vty_out (vty, "!%s", VTY_NEWLINE);
4746 + vty_out (vty, "mpls ldp%s", VTY_NEWLINE);
4749 + if (ldp_traceflags & LDP_TRACE_FLAG_ADDRESS)
4750 + vty_out (vty, " trace address%s", VTY_NEWLINE);
4751 + if (ldp_traceflags & LDP_TRACE_FLAG_BINDING)
4752 + vty_out (vty, " trace binding%s", VTY_NEWLINE);
4753 + if (ldp_traceflags & LDP_TRACE_FLAG_DEBUG)
4754 + vty_out (vty, " trace debug%s", VTY_NEWLINE);
4755 + if (ldp_traceflags & LDP_TRACE_FLAG_ERROR)
4756 + vty_out (vty, " trace error%s", VTY_NEWLINE);
4757 + if (ldp_traceflags & LDP_TRACE_FLAG_EVENT)
4758 + vty_out (vty, " trace event%s", VTY_NEWLINE);
4759 + if (ldp_traceflags & LDP_TRACE_FLAG_GENERAL)
4760 + vty_out (vty, " trace general%s", VTY_NEWLINE);
4761 + if (ldp_traceflags & LDP_TRACE_FLAG_INIT)
4762 + vty_out (vty, " trace init%s", VTY_NEWLINE);
4763 + if (ldp_traceflags & LDP_TRACE_FLAG_LABEL)
4764 + vty_out (vty, " trace label%s", VTY_NEWLINE);
4765 + if (ldp_traceflags & LDP_TRACE_FLAG_NORMAL)
4766 + vty_out (vty, " trace normal%s", VTY_NEWLINE);
4767 + if (ldp_traceflags & LDP_TRACE_FLAG_NOTIF)
4768 + vty_out (vty, " trace notification%s", VTY_NEWLINE);
4769 + if (ldp_traceflags & LDP_TRACE_FLAG_PACKET_DUMP)
4770 + vty_out (vty, " trace packet-dump%s", VTY_NEWLINE);
4771 + if (ldp_traceflags & LDP_TRACE_FLAG_PACKET)
4772 + vty_out (vty, " trace packet%s", VTY_NEWLINE);
4773 + if (ldp_traceflags & LDP_TRACE_FLAG_PATH)
4774 + vty_out (vty, " trace path%s", VTY_NEWLINE);
4775 + if (ldp_traceflags & LDP_TRACE_FLAG_PERIODIC)
4776 + vty_out (vty, " trace periodic%s", VTY_NEWLINE);
4777 + if (ldp_traceflags & LDP_TRACE_FLAG_POLICY)
4778 + vty_out (vty, " trace policy%s", VTY_NEWLINE);
4779 + if (ldp_traceflags & LDP_TRACE_FLAG_ROUTE)
4780 + vty_out (vty, " trace route%s", VTY_NEWLINE);
4781 + if (ldp_traceflags & LDP_TRACE_FLAG_STATE)
4782 + vty_out (vty, " trace state%s", VTY_NEWLINE);
4783 + if (ldp_traceflags & LDP_TRACE_FLAG_TASK)
4784 + vty_out (vty, " trace task%s", VTY_NEWLINE);
4785 + if (ldp_traceflags & LDP_TRACE_FLAG_TIMER)
4786 + vty_out (vty, " trace timer%s", VTY_NEWLINE);
4788 + ldp_cfg_global_get(ldp->h,&g, 0xFFFFFFFF);
4790 + if (g.lsp_control_mode != LDP_GLOBAL_DEF_CONTROL_MODE) {
4791 + vty_out (vty, " lsp-control-mode ");
4792 + if (g.lsp_control_mode == LDP_CONTROL_INDEPENDENT) {
4793 + vty_out (vty, "independent%s", VTY_NEWLINE);
4795 + vty_out (vty, "ordered%s", VTY_NEWLINE);
4798 + if (g.label_retention_mode != LDP_GLOBAL_DEF_RETENTION_MODE) {
4799 + vty_out (vty, " label-retention-mode ");
4800 + if (g.label_retention_mode == LDP_RETENTION_LIBERAL) {
4801 + vty_out (vty, "liberal%s", VTY_NEWLINE);
4803 + vty_out (vty, "conservative%s", VTY_NEWLINE);
4806 + if (g.lsp_repair_mode != LDP_GLOBAL_DEF_REPAIR_MODE) {
4807 + vty_out (vty, " lsp-repair-mode ");
4808 + if (g.lsp_repair_mode == LDP_REPAIR_LOCAL) {
4809 + vty_out (vty, "local%s", VTY_NEWLINE);
4811 + vty_out (vty, "global%s", VTY_NEWLINE);
4814 + if (g.propagate_release != LDP_GLOBAL_DEF_PROPOGATE_RELEASE) {
4815 + if (g.propagate_release == MPLS_BOOL_TRUE) {
4816 + vty_out (vty, " propagate-release%s", VTY_NEWLINE);
4818 + vty_out (vty, " no propagate-release%s", VTY_NEWLINE);
4821 + if (g.label_merge != LDP_GLOBAL_DEF_LABEL_MERGE) {
4822 + if (g.label_merge == MPLS_BOOL_TRUE) {
4823 + vty_out (vty, " label-merge%s", VTY_NEWLINE);
4825 + vty_out (vty, " no label-merge%s", VTY_NEWLINE);
4828 + if (g.loop_detection_mode != LDP_GLOBAL_DEF_LOOP_DETECTION_MODE) {
4829 + if (g.loop_detection_mode == LDP_LOOP_HOPCOUNT) {
4830 + vty_out (vty, " loop-detection-mode hop%s", VTY_NEWLINE);
4831 + } else if (g.loop_detection_mode == LDP_LOOP_PATHVECTOR) {
4832 + vty_out (vty, " loop-detection-mode path%s", VTY_NEWLINE);
4833 + } else if (g.loop_detection_mode == LDP_LOOP_HOPCOUNT_PATHVECTOR) {
4834 + vty_out (vty, " loop-detection-mode both%s", VTY_NEWLINE);
4836 + vty_out (vty, " no loop-detection-mode%s", VTY_NEWLINE);
4839 + if (g.ttl_less_domain != MPLS_BOOL_FALSE) {
4840 + vty_out (vty, " ttl-less-domain%s", VTY_NEWLINE);
4842 + if (g.local_tcp_port != LDP_GLOBAL_DEF_LOCAL_TCP_PORT) {
4843 + vty_out (vty, " local-tcp-port %d%s", g.local_tcp_port, VTY_NEWLINE);
4845 + if (g.local_udp_port != LDP_GLOBAL_DEF_LOCAL_UDP_PORT) {
4846 + vty_out (vty, " local-udp-port %d%s", g.local_udp_port, VTY_NEWLINE);
4849 + switch (ldp->egress) {
4850 + case LDP_EGRESS_LSRID:
4851 + vty_out (vty, " egress lsr-id%s", VTY_NEWLINE);
4853 + case LDP_EGRESS_CONNECTED:
4854 + vty_out (vty, " egress connected%s", VTY_NEWLINE);
4860 + switch (ldp->address) {
4861 + case LDP_ADDRESS_LSRID:
4862 + vty_out (vty, " address-mode lsr-id%s", VTY_NEWLINE);
4864 + case LDP_ADDRESS_LDP:
4865 + vty_out (vty, " address-mode ldp%s", VTY_NEWLINE);
4874 +int ldp_interface_config_write(struct vty *vty, struct mpls_interface *mi) {
4875 + struct ldp_interface *li;
4876 + struct mpls *mpls;
4881 + if (mi && mi->ldp) {
4886 + if (li->entity.index) {
4887 + e.index = li->entity.index;
4888 + ldp_cfg_entity_get(ldp->h, &e, 0xFFFFFFFF);
4890 + memcpy(&e,&li->entity,sizeof(ldp_entity));
4893 + vty_out(vty, " mpls ldp%s", VTY_NEWLINE);
4896 + if (e.label_distribution_mode != LDP_ENTITY_DEF_DISTRIBUTION_MODE) {
4897 + vty_out(vty, " distribution-mode ");
4898 + if (e.label_distribution_mode == LDP_DISTRIBUTION_ONDEMAND) {
4899 + vty_out(vty, "dod%s", VTY_NEWLINE);
4901 + vty_out(vty, "du%s", VTY_NEWLINE);
4904 + if (e.remote_tcp_port != LDP_ENTITY_DEF_REMOTE_TCP) {
4905 + vty_out(vty, " remote-tcp-port %d%s", e.remote_tcp_port,
4908 + if (e.remote_udp_port != LDP_ENTITY_DEF_REMOTE_UDP) {
4909 + vty_out(vty, " remote-udp-port %d%s", e.remote_udp_port,
4912 + if (e.max_pdu != LDP_ENTITY_DEF_MAX_PDU) {
4913 + vty_out(vty, " max-pdu %d%s", e.max_pdu, VTY_NEWLINE);
4915 + if (e.hellotime_interval != LDP_ENTITY_DEF_HELLOTIME_INTERVAL) {
4916 + vty_out(vty, " hello-interval %d%s", e.hellotime_interval,
4919 + if (e.keepalive_interval != LDP_ENTITY_DEF_KEEPALIVE_INTERVAL) {
4920 + vty_out(vty, " keepalive-interval %d%s",
4921 + e.keepalive_interval, VTY_NEWLINE);
4923 + if (e.session_setup_count != LDP_ENTITY_DEF_SESSIONSETUP_COUNT) {
4924 + vty_out(vty, " max-session-attempt %d%s",
4925 + e.session_setup_count, VTY_NEWLINE);
4927 + if (e.path_vector_limit != LDP_ENTITY_DEF_PATHVECTOR_LIMIT) {
4928 + vty_out(vty, " max-path-vector %d%s",
4929 + e.path_vector_limit, VTY_NEWLINE);
4931 + if (e.hop_count_limit != LDP_ENTITY_DEF_HOPCOUNT_LIMIT) {
4932 + vty_out(vty, " max-hop-count %d%s",
4933 + e.hop_count_limit, VTY_NEWLINE);
4935 + if (e.label_request_count != LDP_ENTITY_DEF_REQUEST_COUNT) {
4936 + vty_out(vty, " max-label-requests %d%s",
4937 + e.label_request_count, VTY_NEWLINE);
4939 + vty_out(vty, " !%s",VTY_NEWLINE);
4945 +void ldp_vty_show_init() {
4947 + install_element(VIEW_NODE, &mpls_show_ldp_cmd);
4948 + install_element(ENABLE_NODE, &mpls_show_ldp_cmd);
4950 + install_element(VIEW_NODE, &mpls_show_ldp_neighbor_cmd);
4951 + install_element(ENABLE_NODE, &mpls_show_ldp_neighbor_cmd);
4953 + install_element(VIEW_NODE, &mpls_show_ldp_session_cmd);
4954 + install_element(ENABLE_NODE, &mpls_show_ldp_session_cmd);
4956 + install_element(VIEW_NODE, &mpls_show_ldp_discovery_cmd);
4957 + install_element(ENABLE_NODE, &mpls_show_ldp_discovery_cmd);
4959 + install_element(VIEW_NODE, &mpls_show_ldp_database_cmd);
4960 + install_element(ENABLE_NODE, &mpls_show_ldp_database_cmd);
4963 +static struct cmd_node ldp_if_node = {MPLS_LDP_IF_NODE,"%s(config-if-ldp)# ",1};
4965 +void ldp_vty_if_init() {
4967 + install_node (&ldp_if_node, ldp_if_config_write);
4968 + install_default (MPLS_LDP_IF_NODE);
4970 + install_element(INTERFACE_NODE,&ldp_intf_cmd);
4971 + install_element(INTERFACE_NODE,&no_ldp_intf_cmd);
4973 + install_element(MPLS_LDP_IF_NODE,&ldp_if_remote_tcp_port_cmd);
4974 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_remote_tcp_port_cmd);
4976 + install_element(MPLS_LDP_IF_NODE,&ldp_if_remote_udp_port_cmd);
4977 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_remote_udp_port_cmd);
4979 + install_element(MPLS_LDP_IF_NODE,&ldp_if_max_pdu_cmd);
4980 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_max_pdu_cmd);
4982 + install_element(MPLS_LDP_IF_NODE,&ldp_if_hello_interval_cmd);
4983 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_hello_interval_cmd);
4985 + install_element(MPLS_LDP_IF_NODE,&ldp_if_keepalive_interval_cmd);
4986 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_keepalive_interval_cmd);
4989 + install_element(MPLS_LDP_IF_NODE,&ldp_if_loop_detect_mode_cmd);
4990 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_loop_detect_mode_cmd);
4993 + install_element(MPLS_LDP_IF_NODE,&ldp_if_max_session_attempt_cmd);
4994 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_max_session_attempt_cmd);
4996 + install_element(MPLS_LDP_IF_NODE,&ldp_if_max_path_vector_cmd);
4997 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_max_path_vector_cmd);
4999 + install_element(MPLS_LDP_IF_NODE,&ldp_if_max_hop_count_cmd);
5000 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_max_hop_count_cmd);
5002 + install_element(MPLS_LDP_IF_NODE,&ldp_if_max_label_requests_cmd);
5003 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_max_label_requests_cmd);
5005 + install_element(MPLS_LDP_IF_NODE,&ldp_if_distribution_mode_cmd);
5006 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_distribution_mode_cmd);
5009 + install_element(MPLS_LDP_IF_NODE,&ldp_if_ttl_less_domain_cmd);
5010 + install_element(MPLS_LDP_IF_NODE,&no_ldp_if_ttl_less_domain_cmd);
5014 +static struct cmd_node ldp_node = {MPLS_LDP_NODE,"%s(config-ldp)# ",1};
5016 +void ldp_vty_init () {
5018 + install_node (&ldp_node, ldp_config_write);
5019 + install_default (MPLS_LDP_NODE);
5021 + install_element (CONFIG_NODE, &mpls_ldp_cmd);
5022 + install_element (CONFIG_NODE, &no_mpls_ldp_cmd);
5024 + install_element (MPLS_LDP_NODE, &mpls_ldp_disable_cmd);
5025 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_disable_cmd);
5027 + install_element (MPLS_LDP_NODE, &mpls_ldp_lsrid_cmd);
5028 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_lsrid_cmd);
5030 + install_element (MPLS_LDP_NODE, &mpls_ldp_lsp_control_mode_cmd);
5031 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_lsp_control_mode_cmd);
5033 + install_element (MPLS_LDP_NODE, &mpls_ldp_label_retention_mode_cmd);
5034 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_label_retention_mode_cmd);
5036 + install_element (MPLS_LDP_NODE, &mpls_ldp_lsp_repair_mode_cmd);
5037 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_lsp_repair_mode_cmd);
5039 + install_element (MPLS_LDP_NODE, &mpls_ldp_propogate_release_cmd);
5040 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_propogate_release_cmd);
5042 + install_element (MPLS_LDP_NODE, &mpls_ldp_label_merge_cmd);
5043 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_label_merge_cmd);
5045 + install_element (MPLS_LDP_NODE, &mpls_ldp_loop_detection_mode_cmd);
5046 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_loop_detection_mode_cmd);
5048 + install_element (MPLS_LDP_NODE, &mpls_ldp_ttl_less_domain_cmd);
5049 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_ttl_less_domain_cmd);
5051 + install_element (MPLS_LDP_NODE, &mpls_ldp_local_tcp_port_cmd);
5052 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_local_tcp_port_cmd);
5054 + install_element (MPLS_LDP_NODE, &mpls_ldp_local_udp_port_cmd);
5055 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_local_udp_port_cmd);
5057 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_address_cmd);
5058 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_binding_cmd);
5059 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_debug_cmd);
5060 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_error_cmd);
5061 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_event_cmd);
5062 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_general_cmd);
5063 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_init_cmd);
5064 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_label_cmd);
5065 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_normal_cmd);
5066 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_notif_cmd);
5067 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_packet_dump_cmd);
5068 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_packet_cmd);
5069 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_path_cmd);
5070 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_periodic_cmd);
5071 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_policy_cmd);
5072 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_route_cmd);
5073 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_state_cmd);
5074 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_task_cmd);
5075 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_timer_cmd);
5076 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_all_cmd);
5077 + install_element (MPLS_LDP_NODE, &mpls_ldp_trace_none_cmd);
5079 + install_element (MPLS_LDP_NODE, &mpls_ldp_egress_cmd);
5080 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_egress_cmd);
5081 + install_element (MPLS_LDP_NODE, &mpls_ldp_address_cmd);
5082 + install_element (MPLS_LDP_NODE, &no_mpls_ldp_address_cmd);
5084 diff --exclude=CVS -uNr zebra/mplsd/ldp_vty.h zebra-ldp/mplsd/ldp_vty.h
5085 --- zebra/mplsd/ldp_vty.h 1969-12-31 18:00:00.000000000 -0600
5086 +++ zebra-ldp/mplsd/ldp_vty.h 2003-02-26 15:47:44.000000000 -0600
5091 +#include "mpls_interface.h"
5093 +int ldp_interface_config_write(struct vty *vty, struct mpls_interface *mi);
5094 +void ldp_vty_show_init();
5095 +void ldp_vty_if_init();
5096 +void ldp_vty_init();
5099 diff --exclude=CVS -uNr zebra/mplsd/Makefile.am zebra-ldp/mplsd/Makefile.am
5100 --- zebra/mplsd/Makefile.am 1969-12-31 18:00:00.000000000 -0600
5101 +++ zebra-ldp/mplsd/Makefile.am 2003-02-26 15:47:42.000000000 -0600
5103 +## Process this file with automake to produce Makefile.in.
5105 +INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib
5106 +DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
5107 +INSTALL_SDATA=@INSTALL@ -m 600
5109 +sbin_PROGRAMS = mplsd
5112 +impl_fib.c impl_ifmgr.c impl_lock.c impl_mm.c impl_mpls.c \
5113 +impl_policy.c impl_socket.c impl_timer.c impl_tree.c \
5114 +mpls.c mpls_interface.c mpls_zebra.c mpls_main.c mpls_vty.c\
5115 +static.c static_vty.c \
5116 +ldp.c ldp_interface.c ldp_vty.c\
5117 +ldp_addr.c ldp_adj.c \
5118 +ldp_attr.c ldp_buf.c ldp_cfg.c ldp_entity.c ldp_fec.c ldp_global.c \
5119 +ldp_hello.c ldp_hop.c ldp_hop_list.c ldp_if.c ldp_inet_addr.c \
5120 +ldp_init.c ldp_inlabel.c ldp_keepalive.c ldp_label_abort.c \
5121 +ldp_label_mapping.c ldp_label_rel_with.c ldp_label_request.c \
5122 +ldp_mesg.c ldp_nortel.c ldp_notif.c ldp_outlabel.c \
5123 +ldp_pdu_setup.c ldp_peer.c \
5124 +ldp_resource.c ldp_session.c ldp_state_funcs.c \
5125 +ldp_state_machine.c ldp_tunnel.c \
5127 +lsr_cfg.c lsr_global.c lsr_if.c lsr_insegment.c lsr_labelmanager.c \
5128 +lsr_outsegment.c lsr_xconnect.c lsr_ftn.c
5132 +mpls.h mpls_interface.h mpls_zebra.h mpls_vty.h \
5133 +ldp.h ldp_interface.h ldp_vty.h \
5134 +static.h static_vty.h \
5135 +ldp_addr.h ldp_adj.h ldp_attr.h ldp_buf.h ldp_cfg.h \
5136 +ldp_defaults.h ldp_entity.h ldp_fec.h \
5137 +ldp_global.h mpls_handle_type.h ldp_hello.h ldp_hop.h \
5138 +ldp_hop_list.h ldp_if.h ldp_inet_addr.h \
5139 +ldp_init.h ldp_inlabel.h ldp_keepalive.h ldp_label_abort.h \
5140 +ldp_label_mapping.h ldp_label_rel_with.h ldp_label_request.h \
5141 +ldp_mesg.h ldp_nortel.h ldp_notif.h ldp_outlabel.h ldp_pdu.h \
5142 +ldp_pdu_setup.h ldp_peer.h mpls_refcnt.h ldp_resource.h \
5143 +ldp_session.h ldp_state_machine.h ldp_struct.h ldp_tunnel.h \
5144 +mpls_tree_impl.h mpls_mm_impl.h mpls_mpls_impl.h mpls_trace_impl.h \
5145 +mpls_assert.h mpls_fib_impl.h mpls_ifmgr_impl.h mpls_list.h mpls_lock_impl.h \
5146 +mpls_policy_impl.h mpls_socket_impl.h mpls_timer_impl.h mpls_trace.h \
5147 +mpls_struct.h mpls_compare.h \
5148 +lsr_cfg.h lsr_defaults.h lsr_global.h lsr_if.h lsr_insegment.h \
5149 +lsr_labelmanager.h lsr_outsegment.h lsr_struct.h lsr_xconnect.h lsr_ftn.h
5151 +mplsd_LDADD = ../lib/libzebra.a
5153 +sysconf_DATA = mplsd.conf.sample
5155 +EXTRA_DIST = $(sysconf_DATA)
5157 +install-sysconfDATA: $(sysconf_DATA)
5158 + @$(NORMAL_INSTALL)
5159 + $(mkinstalldirs) $(DESTDIR)$(sysconfdir)
5160 + @list='$(sysconf_DATA)'; for p in $$list; do \
5161 + if test -f $(srcdir)/$$p; then \
5162 + echo " $(INSTALL_SDATA) $(srcdir)/$$p $(DESTDIR)$(sysconfdir)/$$p"; \
5163 + $(INSTALL_SDATA) $(srcdir)/$$p $(DESTDIR)$(sysconfdir)/$$p; \
5164 + else if test -f $$p; then \
5165 + echo " $(INSTALL_SDATA) $$p $(DESTDIR)$(sysconfdir)/$$p"; \
5166 + $(INSTALL_SDATA) $$p $(DESTDIR)$(sysconfdir)/$$p; \
5169 diff --exclude=CVS -uNr zebra/mplsd/mpls.c zebra-ldp/mplsd/mpls.c
5170 --- zebra/mplsd/mpls.c 1969-12-31 18:00:00.000000000 -0600
5171 +++ zebra-ldp/mplsd/mpls.c 2003-02-26 15:47:44.000000000 -0600
5175 +#include "thread.h"
5176 +#include "memory.h"
5177 +#include "prefix.h"
5179 +#include "linklist.h"
5180 +#include "filter.h"
5186 +#include "static.h"
5187 +#include "lsr_cfg.h"
5189 +/* MPLS instance top. */
5190 +struct mpls *mpls_top = NULL;
5192 +struct mpls *mpls_new() {
5193 + lsr_global global;
5194 + struct mpls *new = XMALLOC(MTYPE_MPLS_TOP, sizeof (struct mpls));
5196 + memset(new,0,sizeof(*new));
5198 + new->h = lsr_cfg_open(new);
5199 + global.admin_state = MPLS_ADMIN_ENABLE;
5200 + lsr_cfg_global_set(new->h, &global, LSR_GLOBAL_CFG_ADMIN_STATE);
5202 + new->router_id.family = AF_INET;
5203 + new->router_id.prefixlen = 32;
5205 + new->iflist = iflist;
5206 + new->table = route_table_init();
5211 +struct mpls *mpls_get() {
5216 + mpls_top = mpls_new();
5220 +void mpls_finish(struct mpls *mpls) {
5222 + lsr_global global;
5224 + ldp_finish(mpls->ldp);
5225 + static_finish(mpls->mstatic);
5227 + global.admin_state = MPLS_ADMIN_DISABLE;
5228 + lsr_cfg_global_set(mpls->h, &global, LSR_GLOBAL_CFG_ADMIN_STATE);
5229 + lsr_cfg_close(mpls->h);
5231 + XFREE(MTYPE_MPLS_TOP, mpls);
5235 +/* Update access-list list. */
5236 +void mpls_access_list_update(struct access_list *access) {
5239 +/* Update prefix-list list. */
5240 +void mpls_prefix_list_update(struct prefix_list *plist) {
5246 + access_list_init();
5247 + access_list_add_hook(mpls_access_list_update);
5248 + access_list_delete_hook(mpls_access_list_update);
5251 diff --exclude=CVS -uNr zebra/mplsd/mplsd.conf.sample zebra-ldp/mplsd/mplsd.conf.sample
5252 --- zebra/mplsd/mplsd.conf.sample 1969-12-31 18:00:00.000000000 -0600
5253 +++ zebra-ldp/mplsd/mplsd.conf.sample 2003-02-26 15:47:44.000000000 -0600
5256 +! Zebra configuration saved from vty
5257 +! 2002/03/23 17:07:30
5261 +enable password root
5272 diff --exclude=CVS -uNr zebra/mplsd/mpls.h zebra-ldp/mplsd/mpls.h
5273 --- zebra/mplsd/mpls.h 1969-12-31 18:00:00.000000000 -0600
5274 +++ zebra-ldp/mplsd/mpls.h 2003-02-26 15:47:44.000000000 -0600
5279 +#include "sockunion.h"
5280 +#include "prefix.h"
5281 +#include "zclient.h"
5282 +#include "linklist.h"
5286 +#include "static.h"
5288 +#define MPLS_DEFAULT_CONFIG "mplsd.conf"
5290 +#define MPLS_VTY_PORT 2610
5291 +#define MPLS_VTYSH_PATH "/tmp/.mplsd"
5293 +enum mplsd_instr_types {
5300 + char ifname[INTERFACE_NAMSIZ + 1];
5301 + union sockunion nexthop;
5307 + mpls_cfg_handle h;
5308 + struct route_table *table;
5310 + struct mpls_static *mstatic;
5311 + struct prefix router_id;
5312 + ldp_fib_callback fib_callback;
5316 +struct mpls *mpls_get();
5319 diff --exclude=CVS -uNr zebra/mplsd/mpls_handle_type.h zebra-ldp/mplsd/mpls_handle_type.h
5320 --- zebra/mplsd/mpls_handle_type.h 1969-12-31 18:00:00.000000000 -0600
5321 +++ zebra-ldp/mplsd/mpls_handle_type.h 2003-02-26 23:23:55.000000000 -0600
5323 +#ifndef _LDP_HANDLE_TYPE_H_
5324 +#define _LDP_HANDLE_TYPE_H_
5326 +#define MPLS_USE_LSR 1
5328 +#if (__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0))
5330 +typedef unsigned char uint8_t;
5331 +typedef unsigned short uint16_t;
5332 +typedef unsigned int uint32_t;
5335 +#include <stdint.h>
5345 +#define ptr_verify(x) (x ? MPLS_BOOL_TRUE : MPLS_BOOL_FALSE)
5347 +typedef void *mpls_tree_handle;
5348 +#define mpls_tree_handle_compare(x,y) (x != y)
5349 +#define mpls_tree_handle_verify(x) ptr_verify(x)
5351 +typedef void *mpls_instance_handle;
5352 +#define mpls_instance_handle_compare(x,y) (x != y)
5353 +#define mpls_instance_handle_verify(x) ptr_verify(x)
5355 +typedef struct mpls* mpls_fib_handle;
5356 +#define mpls_fib_handle_compare(x,y) (x == y)
5357 +#define mpls_fib_handle_verify(x) ptr_verify(x)
5359 +typedef int mpls_ifmgr_handle;
5360 +#define mpls_ifmgr_handle_compare(x,y) (x == y)
5361 +#define mpls_ifmgr_handle_verify(x) ptr_verify(x)
5363 +typedef struct interface* mpls_if_handle;
5364 +#define mpls_if_handle_compare(x,y) \
5365 + ((x->ifindex == y->ifindex) ? 0 : (x->ifindex > y->ifindex ? 1 : -1))
5366 +#define mpls_if_handle_verify(m,x) ptr_verify(x)
5368 +typedef int mpls_timer_mgr_handle;
5369 +#define mpls_timer_mgr_handle_compare(x,y) (x != y)
5370 +#define mpls_timer_mgr_handle_verify(x) ptr_verify(x)
5372 +typedef struct mpls_timer* mpls_timer_handle;
5373 +#define mpls_timer_handle_compare(x,y) (x != y)
5374 +#define mpls_timer_handle_verify(m,x) ptr_verify(x)
5376 +typedef int mpls_socket_mgr_handle;
5377 +#define mpls_socket_mgr_handle_compare(x,y) (x != y)
5378 +#define mpls_socket_mgr_handle_verify(x) MPLS_BOOL_TRUE
5380 +typedef struct mpls_socket* mpls_socket_handle;
5381 +#define mpls_socket_handle_compare(x,y) (x->fd != y->fd)
5382 +#define mpls_socket_handle_verify(m,x) ptr_verify(x)
5384 +typedef int mpls_mpls_handle;
5385 +#define mpls_mpls_handle_compare(x,y) (x != y)
5386 +#define mpls_mpls_handle_verify(x) ptr_verify(x)
5388 +typedef int mpls_insegment_handle;
5389 +#define mpls_insegment_handle_compare(x,y) (x != y)
5390 +#define mpls_insegment_handle_verify(m,x) ptr_verify(x)
5392 +typedef int mpls_outsegment_handle;
5393 +#define mpls_outsegment_handle_compare(x,y) (x != y)
5394 +#define mpls_outsegment_handle_verify(m,x) ptr_verify(x)
5396 +typedef int mpls_xconnect_handle;
5397 +#define mpls_xconnect_handle_compare(x,y) (x != y)
5398 +#define mpls_xconnect_handle_verify(m,x) ptr_verify(x)
5400 +typedef int *mpls_lock_handle;
5401 +#define mpls_lock_handle_compare(x,y) (x != y)
5402 +#define mpls_lock_handle_verify(x) ptr_verify(x)
5404 +typedef int mpls_tunnel_handle;
5405 +#define mpls_tunnel_handle_compare(x,y) (x != y)
5407 +typedef int mpls_policy_handle;
5408 +#define mpls_policy_handle_compare(x,y) (x != y)
5410 +typedef int mpls_trace_handle;
5411 +#define mpls_trace_handle_compare(x,y) (x != y)
5413 +typedef char *mpls_lock_key_type;
5414 +typedef int mpls_size_type;
5417 diff --exclude=CVS -uNr zebra/mplsd/mpls_interface.c zebra-ldp/mplsd/mpls_interface.c
5418 --- zebra/mplsd/mpls_interface.c 1969-12-31 18:00:00.000000000 -0600
5419 +++ zebra-ldp/mplsd/mpls_interface.c 2003-02-26 15:47:44.000000000 -0600
5424 +#include "memory.h"
5427 +#include "mpls_interface.h"
5428 +#include "impl_mpls.h"
5430 +struct mpls_interface *mpls_if_new(struct interface *ifp) {
5431 + struct mpls_interface *mi;
5432 + struct mpls *mpls = mpls_get();
5434 + mi = XMALLOC(MTYPE_MPLS_IF, sizeof(struct mpls_interface));
5435 + memset(mi, 0, sizeof(struct mpls_interface));
5437 + /* Set zebra interface pointer. */
5439 + mi->labelspace = -1;
5445 +void mpls_if_free(struct mpls_interface *mi) {
5447 + listnode_delete(mi->mpls->miflist, mi);
5448 + XFREE(MTYPE_MPLS_IF, mi);
5451 +int mpls_if_is_up(struct mpls_interface *mi) {
5452 + return if_is_up(mi->ifp);
5455 +int mpls_if_new_hook(struct interface *ifp) {
5456 + ifp->info = mpls_if_new(ifp);
5460 +int mpls_if_delete_hook(struct interface *ifp) {
5461 + mpls_if_free(ifp->info);
5466 +int mpls_if_up(struct mpls_interface *mi) {
5470 + if (mi->labelspace != -1) {
5471 + do_mpls_labelspace(mi);
5474 + //static_if_up(mi);
5478 +int mpls_if_down(struct mpls_interface *mi) {
5483 + //static_if_down(mi);
5487 +void mpls_if_init() {
5488 + /* Initialize Zebra interface data structure. */
5490 + if_add_hook(IF_NEW_HOOK, mpls_if_new_hook);
5491 + if_add_hook(IF_DELETE_HOOK, mpls_if_delete_hook);
5493 diff --exclude=CVS -uNr zebra/mplsd/mpls_interface.h zebra-ldp/mplsd/mpls_interface.h
5494 --- zebra/mplsd/mpls_interface.h 1969-12-31 18:00:00.000000000 -0600
5495 +++ zebra-ldp/mplsd/mpls_interface.h 2003-02-26 15:47:44.000000000 -0600
5497 +#ifndef MPLS_INTERFACE_H
5498 +#define MPLS_INTERFACE_H
5503 +#include "command.h"
5504 +#include "prefix.h"
5505 +#include "zclient.h"
5508 +#include "ldp_struct.h"
5509 +#include "ldp_interface.h"
5511 +struct mpls_interface {
5512 + struct mpls *mpls;
5514 + struct interface *ifp;
5517 + struct connected *connected;
5519 + struct ldp_interface *ldp;
5520 +// struct static_interface static;
5523 +struct mpls_interface *mpls_if_new();
5524 +void mpls_if_free(struct mpls_interface *);
5525 +int mpls_if_is_up(struct mpls_interface *);
5526 +int mpls_if_up(struct mpls_interface *mi);
5527 +int mpls_if_down(struct mpls_interface *mi);
5528 +void mpls_if_init();
5531 diff --exclude=CVS -uNr zebra/mplsd/mpls_main.c zebra-ldp/mplsd/mpls_main.c
5532 --- zebra/mplsd/mpls_main.c 1969-12-31 18:00:00.000000000 -0600
5533 +++ zebra-ldp/mplsd/mpls_main.c 2003-02-26 15:47:44.000000000 -0600
5537 +#include "version.h"
5538 +#include "getopt.h"
5539 +#include "command.h"
5540 +#include "thread.h"
5541 +#include "filter.h"
5542 +#include "memory.h"
5543 +#include "prefix.h"
5547 +#include "mpls_vty.h"
5548 +#include "mpls_zebra.h"
5549 +#include "mpls_interface.h"
5551 +/* Configuration filename and directory. */
5552 +char config_current[] = MPLS_DEFAULT_CONFIG;
5553 +char config_default[] = SYSCONFDIR MPLS_DEFAULT_CONFIG;
5555 +/* Command line options. */
5556 +struct option longopts[] =
5558 + { "daemon", no_argument, NULL, 'd'},
5559 + { "config_file", required_argument, NULL, 'f'},
5560 + { "log_mode", no_argument, NULL, 'l'},
5561 + { "help", no_argument, NULL, 'h'},
5562 + { "vty_port", required_argument, NULL, 'P'},
5563 + { "vty_addr", required_argument, NULL, 'A'},
5564 + { "version", no_argument, NULL, 'v'},
5568 +/* Master of threads. */
5569 +struct thread_master *master = NULL;
5571 +/* Process ID saved for use by init system */
5572 +char *pid_file = PATH_MPLSD_PID;
5574 +/* Help information display. */
5576 +usage (char *progname, int status)
5579 + fprintf (stderr, "Try `%s --help' for more information.\n", progname);
5582 + printf ("Usage : %s [OPTION...]\n\n\
5583 +Daemon which manages MPLS related configuration.\n\n\
5584 +-d, --daemon Runs in daemon mode\n\
5585 +-f, --config_file Set configuration file name\n\
5586 +-l, --log_mode Set verbose log mode flag\n\
5587 +-h, --help Display this help and exit\n\
5588 +-P, --vty_port Set vty's port number\n\
5589 +-A, --vty_addr Set vty's bind address\n\
5590 +-v, --version Print program version\n\
5592 +Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS);
5598 +/* SIGHUP handler. */
5602 + zlog_info ("SIGHUP received");
5604 + /* Reload of config file. */
5608 +/* SIGINT handler. */
5612 + zlog_info ("Terminating on signal");
5617 +/* SIGUSR1 handler. */
5621 + zlog_rotate (NULL);
5624 +/* Signale wrapper. */
5626 +signal_set (int signo, void (*func)(int))
5629 + struct sigaction sig;
5630 + struct sigaction osig;
5632 + sig.sa_handler = func;
5633 + sigemptyset (&sig.sa_mask);
5636 + sig.sa_flags |= SA_RESTART;
5637 +#endif /* SA_RESTART */
5639 + ret = sigaction (signo, &sig, &osig);
5644 + return (osig.sa_handler);
5647 +/* Initialization of signal handles. */
5651 + signal_set (SIGHUP, sighup);
5652 + signal_set (SIGINT, sigint);
5653 + signal_set (SIGTERM, sigint);
5654 + signal_set (SIGPIPE, SIG_IGN);
5655 + signal_set (SIGUSR1, sigusr1);
5658 +/* Main startup routine. */
5660 +main (int argc, char **argv)
5664 + char *vty_addr = NULL;
5665 + int daemon_mode = 0;
5666 + char *config_file = NULL;
5668 + struct thread thread;
5670 + /* Set umask before anything for security */
5673 + /* preserve my name */
5674 + progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]);
5676 + zlog_default = openzlog (progname, ZLOG_STDOUT, ZLOG_MPLS,
5677 + LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
5683 + opt = getopt_long (argc, argv, "bdklf:hP:rv", longopts, 0);
5696 + /* log_mode = 1; */
5699 + config_file = optarg;
5702 + vty_addr = optarg;
5705 + vty_port = atoi (optarg);
5708 + print_version (progname);
5712 + usage (progname, 0);
5715 + usage (progname, 1);
5720 + /* Make master thread emulator. */
5721 + master = thread_master_create();
5723 + /* Vty related initialize. */
5733 + mpls_vty_show_init();
5734 + mpls_zebra_init();
5738 + /* Configuration file read*/
5739 + vty_read_config(config_file, config_current, config_default);
5742 + if (daemon_mode) {
5746 + /* Output pid of zebra. */
5747 + pid_output(pid_file);
5749 + /* Create VTY socket */
5750 + vty_serv_sock(vty_addr,
5751 + vty_port ? vty_port : MPLS_VTY_PORT, MPLS_VTYSH_PATH);
5753 + /* Print banner. */
5754 + zlog(NULL, LOG_INFO, "MPLSd (%s) starts", ZEBRA_VERSION);
5756 + while(thread_fetch(master, &thread)) {
5757 + thread_call(&thread);
5760 + /* Not reached... */
5763 diff --exclude=CVS -uNr zebra/mplsd/mpls_trace.h zebra-ldp/mplsd/mpls_trace.h
5764 --- zebra/mplsd/mpls_trace.h 1969-12-31 18:00:00.000000000 -0600
5765 +++ zebra-ldp/mplsd/mpls_trace.h 2003-02-26 15:47:44.000000000 -0600
5767 +#ifndef _LDP_TRACE_H_
5768 +#define _LDP_TRACE_H_
5771 +#include "ldp_struct.h"
5773 +extern uint32_t ldp_traceflags;
5774 +extern uint8_t trace_buffer[16834];
5775 +extern int trace_buffer_len;
5779 + 12345678901234567890123456789012345678901234567890123456789012345678901234567890
5781 +#define LDP_TRACE_OUT(handle,args...) { \
5782 + if(trace_buffer_len == 0) { \
5783 + trace_buffer_len += sprintf(trace_buffer,"OUT: " args);\
5785 + trace_buffer_len += sprintf(trace_buffer+trace_buffer_len,args);\
5787 + if(trace_buffer[strlen(trace_buffer)-1] == '\n') { \
5788 + fprintf(stderr,"%s",trace_buffer); \
5789 + trace_buffer_len = 0; \
5792 +#define LDP_TRACE_LOG(handle,class,type,args...) { \
5793 + if(type & ldp_traceflags) { \
5794 + LDP_TRACE_OUT(handle,args); \
5797 +#define LDP_TRACE_PKT(handle,class,type,header,body) { \
5798 + if(type & ldp_traceflags) { \
5803 +#define LDP_DUMP_PKT(handle,class,type,func) { \
5804 + if(type & ldp_traceflags) { \
5808 +#define LDP_PRINT(data,args...) { \
5809 + if(ldp_traceflags & LDP_TRACE_FLAG_DEBUG) { \
5810 + fprintf(stderr, "PRT: " args); \
5813 +#define LDP_ENTER(data,args...) { \
5814 + if(ldp_traceflags & LDP_TRACE_FLAG_DEBUG) { \
5815 + fprintf(stderr, "ENTER: " args); \
5816 + fprintf(stderr, "\n"); \
5819 +#define LDP_EXIT(data,args...) { \
5820 + if(ldp_traceflags & LDP_TRACE_FLAG_DEBUG) { \
5821 + fprintf(stderr, "EXIT: " args); \
5822 + fprintf(stderr, "\n"); \
5827 diff --exclude=CVS -uNr zebra/mplsd/mpls_vty.c zebra-ldp/mplsd/mpls_vty.c
5828 --- zebra/mplsd/mpls_vty.c 1969-12-31 18:00:00.000000000 -0600
5829 +++ zebra-ldp/mplsd/mpls_vty.c 2003-02-26 15:47:44.000000000 -0600
5834 +#include "command.h"
5837 +#include "mpls_interface.h"
5840 +#include "ldp_cfg.h"
5841 +#include "ldp_vty.h"
5842 +#include "ldp_interface.h"
5843 +#include "static_vty.h"
5845 +#include "impl_mpls.h"
5847 +DEFUN (mpls_show_lsr_id, mpls_show_lsr_id_cmd,
5850 + "LSR identifier\n") {
5852 + struct mpls *mpls = mpls_get();
5854 + vty_out(vty, "lsr-id: %s%s", inet_ntoa(mpls->router_id.u.prefix4),
5856 + return CMD_SUCCESS;
5859 +DEFUN(interface_mpls_labelspace,
5860 + interface_mpls_labelspace_cmd,
5861 + "mpls labelspace <1-255>",
5862 + "MPLS interface configuration\n"
5864 + "labelspace number\n") {
5865 + struct interface *ifp = vty->index;
5866 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
5867 + struct mpls *mpls = mpls_get();
5868 + struct mpls_range range;
5870 + if ((range.label_space = atoi(argv[0])) < 0) {
5871 + return CMD_WARNING;
5874 + mi->labelspace = range.label_space;
5875 + do_mpls_labelspace(mi);
5877 + if (mpls->ldp && mi->ldp && mi->ldp->entity.index) {
5878 + ldp_interface_admin_state_start(mi);
5879 + mi->ldp->iff.label_space = mi->labelspace;
5880 + ldp_cfg_if_set(mpls->ldp->h, &mi->ldp->iff, LDP_IF_CFG_LABEL_SPACE);
5881 + ldp_interface_admin_state_finish(mi);
5884 + return CMD_SUCCESS;
5887 +DEFUN(no_interface_mpls_labelspace,
5888 + no_interface_mpls_labelspace_cmd,
5889 + "no mpls labelspace",
5891 + "MPLS interface configuration\n"
5893 + struct interface *ifp = vty->index;
5894 + struct mpls_interface *mi = (struct mpls_interface*)ifp->info;
5895 + struct mpls *mpls = mpls_get();
5897 + mi->labelspace = -1;
5898 + do_mpls_labelspace(mi);
5900 + if (mpls->ldp && mi->ldp && mi->ldp->entity.index) {
5901 + ldp_interface_admin_state_start(mi);
5902 + mi->ldp->iff.label_space = mi->labelspace;
5903 + ldp_cfg_if_set(mpls->ldp->h, &mi->ldp->iff, LDP_IF_CFG_LABEL_SPACE);
5904 + ldp_interface_admin_state_finish(mi);
5906 + return CMD_SUCCESS;
5909 +int mpls_interface_config_write(struct vty *vty) {
5911 + struct interface *ifp;
5912 + struct mpls_interface *mi;
5913 + struct mpls *mpls = mpls_get();
5915 + for (node = listhead(mpls->iflist); node; nextnode(node)) {
5916 + ifp = getdata(node);
5918 + vty_out(vty, "interface %s%s", ifp->name, VTY_NEWLINE);
5921 + vty_out(vty, " description %s%s", ifp->desc, VTY_NEWLINE);
5924 + if ((mi = (struct mpls_interface*)ifp->info)) {
5925 + if (mi->labelspace > -1) {
5926 + vty_out(vty, " mpls labelspace %d%s", mi->labelspace, VTY_NEWLINE);
5928 + vty_out(vty, " no mpls labelspace%s", VTY_NEWLINE);
5930 + ldp_interface_config_write(vty, mi);
5932 + vty_out(vty, "!%s", VTY_NEWLINE);
5937 +void mpls_vty_show_init () {
5939 + install_element(VIEW_NODE, &mpls_show_lsr_id_cmd);
5940 + install_element(ENABLE_NODE, &mpls_show_lsr_id_cmd);
5943 + install_element (VIEW_NODE, &show_ip_route_cmd);
5944 + install_element (VIEW_NODE, &show_ip_route_addr_cmd);
5945 + install_element (VIEW_NODE, &show_ip_route_prefix_cmd);
5946 + install_element (VIEW_NODE, &show_ip_route_prefix_longer_cmd);
5947 + install_element (VIEW_NODE, &show_ip_route_protocol_cmd);
5948 + install_element (VIEW_NODE, &show_ip_route_supernets_cmd);
5949 + install_element (ENABLE_NODE, &show_ip_route_cmd);
5950 + install_element (ENABLE_NODE, &show_ip_route_addr_cmd);
5951 + install_element (ENABLE_NODE, &show_ip_route_prefix_cmd);
5952 + install_element (ENABLE_NODE, &show_ip_route_prefix_longer_cmd);
5953 + install_element (ENABLE_NODE, &show_ip_route_protocol_cmd);
5954 + install_element (ENABLE_NODE, &show_ip_route_supernets_cmd);
5957 + ldp_vty_show_init();
5958 + static_vty_show_init();
5961 +struct cmd_node interface_node = { INTERFACE_NODE, "%s(config-if)# ", 1, };
5963 +void mpls_vty_if_init() {
5965 + install_node(&interface_node, mpls_interface_config_write);
5967 + install_element(CONFIG_NODE, &interface_cmd);
5968 + install_default(INTERFACE_NODE);
5970 + install_element(INTERFACE_NODE,&interface_desc_cmd);
5971 + install_element(INTERFACE_NODE,&no_interface_desc_cmd);
5973 + install_element(INTERFACE_NODE,&interface_mpls_labelspace_cmd);
5974 + install_element(INTERFACE_NODE,&no_interface_mpls_labelspace_cmd);
5976 + ldp_vty_if_init();
5979 +void mpls_vty_init () {
5982 + static_vty_init();
5983 + mpls_vty_if_init();
5986 diff --exclude=CVS -uNr zebra/mplsd/mpls_vty.h zebra-ldp/mplsd/mpls_vty.h
5987 --- zebra/mplsd/mpls_vty.h 1969-12-31 18:00:00.000000000 -0600
5988 +++ zebra-ldp/mplsd/mpls_vty.h 2003-02-26 15:47:44.000000000 -0600
5990 +#ifndef ZEBRA_MPLS_VTY_H
5991 +#define ZEBRA_MPLS_VTY_H
5993 +#define VTY_GET_UINT32(NAME,V,STR) \
5995 + char *endptr = NULL; \
5996 + (V) = strtoul ((STR), &endptr, 10); \
5997 + if (*endptr != '\0' || ((V) == ULONG_MAX && errno == ERANGE)) \
5999 + vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
6000 + return CMD_WARNING; \
6004 +#define VTY_GET_UINT32_RANGE(NAME,V,STR,IMIN,IMAX) \
6006 + VTY_GET_UINT32(NAME,V,STR); \
6007 + if (((V) < IMIN) || ((V) > IMAX)) \
6009 + vty_out (vty, "%% Invalid %s value. Valid range is (%d ... %d)%s", \
6010 + NAME, IMIN, IMAX, VTY_NEWLINE); \
6011 + return CMD_WARNING; \
6015 +#define VTY_GET_IPV4_ADDRESS(NAME,V,STR) \
6018 + retv = inet_aton ((STR), &(V)); \
6021 + vty_out (vty, "%% Invalid %s value%s", NAME, VTY_NEWLINE); \
6022 + return CMD_WARNING; \
6026 +void mpls_vty_init();
6027 +void mpls_vty_show_init();
6030 diff --exclude=CVS -uNr zebra/mplsd/mpls_zebra.c zebra-ldp/mplsd/mpls_zebra.c
6031 --- zebra/mplsd/mpls_zebra.c 1969-12-31 18:00:00.000000000 -0600
6032 +++ zebra-ldp/mplsd/mpls_zebra.c 2003-03-13 21:55:36.000000000 -0600
6036 +#include "command.h"
6037 +#include "prefix.h"
6038 +#include "stream.h"
6040 +#include "memory.h"
6041 +#include "zclient.h"
6045 +#include "mpls_interface.h"
6046 +#include "impl_fib.h"
6047 +#include "impl_ifmgr.h"
6048 +#include "impl_mpls.h"
6050 +/* All information about zebra. */
6051 +struct zclient *zclient = NULL;
6053 +/* For registering threads. */
6054 +extern struct thread_master *master;
6056 +/* Router-id update message from zebra. */
6057 +int mpls_router_id_update_zebra(int command, struct zclient *zclient,
6058 + zebra_size_t length) {
6059 + struct mpls *mpls = mpls_get();
6061 + zebra_router_id_update_read(zclient->ibuf,&mpls->router_id);
6063 + zlog_info("router-id change %s",
6064 + inet_ntoa(mpls->router_id.u.prefix4));
6066 + if (mpls && mpls->ldp) {
6067 + ldp_router_id_update(mpls->ldp, &mpls->router_id);
6072 +/* Inteface addition message from zebra. */
6073 +int mpls_interface_add(int command, struct zclient *zclient,
6074 + zebra_size_t length) {
6075 + struct interface *ifp;
6076 + struct mpls_interface *mi;
6078 + if (!(ifp = zebra_interface_add_read(zclient->ibuf))) {
6082 + mi = (struct mpls_interface*)ifp->info;
6083 + if (mi && mi->ldp) {
6084 + /* Initialize labelspace to kernel */
6085 + /* If the labelspace has been set yet via the CLI */
6086 + /* the result will be that the kernel labelspace will */
6087 + /* be un-set, which doesn't hurt anything */
6088 + do_mpls_labelspace(mi);
6091 + zlog_info("interface add %s index %d flags %ld metric %d mtu %d",
6092 + ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
6097 +int mpls_interface_delete(int command, struct zclient *zclient,
6098 + zebra_size_t length) {
6099 + struct interface *ifp;
6102 + s = zclient->ibuf;
6103 + /* zebra_interface_state_read() updates interface structure in iflist */
6104 + ifp = zebra_interface_state_read(s);
6106 + if (ifp == NULL) {
6110 + if (if_is_up(ifp)) {
6111 + zlog_warn("got delete of %s, but interface is still up",
6115 + zlog_info("interface delete %s index %d flags %ld metric %d mtu %d", ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
6122 +struct interface * zebra_interface_if_lookup(struct stream *s) {
6123 + struct interface *ifp;
6124 + u_char ifname_tmp[INTERFACE_NAMSIZ];
6126 + /* Read interface name. */
6127 + stream_get(ifname_tmp, s, INTERFACE_NAMSIZ);
6129 + /* Lookup this by interface index. */
6130 + ifp = if_lookup_by_name(ifname_tmp);
6132 + /* If such interface does not exist, indicate an error */
6140 +int mpls_interface_state_up(int command, struct zclient *zclient,
6141 + zebra_size_t length) {
6142 + struct interface *ifp;
6143 + struct interface if_tmp;
6145 + ifp = zebra_interface_if_lookup(zclient->ibuf);
6146 + if (ifp == NULL) {
6150 + /* Interface is already up. */
6151 + if (if_is_up (ifp)) {
6152 + /* Temporarily keep ifp values. */
6153 + memcpy (&if_tmp, ifp, sizeof (struct interface));
6155 + zebra_interface_if_set_value (zclient->ibuf, ifp);
6157 + zlog_info ("Interface[%s] state update.", ifp->name);
6162 + zebra_interface_if_set_value(zclient->ibuf, ifp);
6164 + zlog_info ("Interface[%s] state change to up.", ifp->name);
6166 + mpls_if_up(ifp->info);
6171 +int mpls_interface_state_down(int command, struct zclient *zclient,
6172 + zebra_size_t length) {
6173 + struct interface *ifp;
6175 + ifp = zebra_interface_state_read (zclient->ibuf);
6176 + if (ifp == NULL) {
6180 + zlog_info ("Interface[%s] state change to down.", ifp->name);
6182 + mpls_if_down(ifp->info);
6187 +int mpls_interface_address_add(int command, struct zclient *zclient,
6188 + zebra_size_t length) {
6189 + struct mpls *mpls = mpls_get();
6190 + struct connected *c;
6191 + struct interface *ifp;
6194 + c = zebra_interface_address_add_read(zclient->ibuf);
6202 + zlog_info("address add %s to interface %s",inet_ntoa(p->u.prefix4),
6206 + ldp_address_add_callback(mpls, c);
6212 +int mpls_interface_address_delete(int command, struct zclient *zclient,
6213 + zebra_size_t length) {
6214 + struct mpls *mpls = mpls_get();
6215 + struct connected *c;
6216 + struct interface *ifp;
6219 + c = zebra_interface_address_delete_read(zclient->ibuf);
6227 + zlog_info("address delete %s from interface %s",
6228 + inet_ntoa(p->u.prefix4), ifp->name);
6231 + ldp_address_delete_callback(mpls, c);
6234 + connected_free(c);
6239 +static void mpls_read_ipv4(struct zclient *client, u_short length,
6240 + struct prefix_ipv4* p, struct mpls_nexthop* nexthop) {
6249 + memset(nexthop,0,sizeof(nexthop));
6251 + /* Type, flags, message. */
6252 + type = stream_getc(s);
6253 + flags = stream_getc(s);
6254 + message = stream_getc(s);
6256 + if (type == ZEBRA_ROUTE_CONNECT) {
6257 + nexthop->attached = MPLS_BOOL_TRUE;
6260 + /* IPv4 prefix. */
6261 + memset (p, 0, sizeof(struct prefix_ipv4));
6262 + p->family = AF_INET;
6263 + p->prefixlen = stream_getc (s);
6264 + stream_get(&p->prefix, s, PSIZE(p->prefixlen));
6266 + /* Nexthop, ifindex, distance, metric. */
6267 + if (CHECK_FLAG(message, ZAPI_MESSAGE_NEXTHOP)) {
6268 + nexthop_num = stream_getc(s);
6269 + assert(nexthop_num == 1);
6270 + nexthop->ip.u.ipv4 = ntohl(stream_get_ipv4(s));
6271 + if (nexthop->ip.u.ipv4) {
6272 + nexthop->ip.type = MPLS_FAMILY_IPV4;
6273 + nexthop->type |= MPLS_NH_IP;
6277 + if (CHECK_FLAG(message, ZAPI_MESSAGE_IFINDEX)) {
6278 + ifindex_num = stream_getc(s);
6279 + assert(ifindex_num == 1);
6280 + nexthop->if_handle = if_lookup_by_index(stream_getl(s));
6281 + nexthop->type |= MPLS_NH_IF;
6285 + if (CHECK_FLAG(message, ZAPI_MESSAGE_DISTANCE)) {
6286 + nexthop->distance = stream_getc(s);
6290 + if (CHECK_FLAG(message, ZAPI_MESSAGE_METRIC)) {
6291 + nexthop->metric = stream_getl(s);
6295 +int mpls_zebra_read_ipv4(int command, struct zclient *client,
6296 + zebra_size_t length) {
6297 + struct mpls_nexthop nexthop;
6298 + struct prefix_ipv4 p;
6299 + struct mpls *mpls = mpls_get();
6300 + struct in_addr tmp;
6302 + mpls_read_ipv4(client, length, &p, &nexthop);
6304 + if (command == ZEBRA_IPV4_ROUTE_ADD) {
6305 + zlog_info("route add %s/%d", inet_ntoa(p.prefix), p.prefixlen);
6307 + zlog_info("route delete %s/%d", inet_ntoa(p.prefix), p.prefixlen);
6310 + if (nexthop.type & MPLS_NH_IP) {
6311 + tmp.s_addr = htonl(nexthop.ip.u.ipv4);
6312 + zlog_info("\tnexthop %s", inet_ntoa(tmp));
6314 + if (nexthop.type & MPLS_NH_IF) {
6315 + zlog_info("\tifindex %d", nexthop.if_handle->ifindex);
6318 + if (command == ZEBRA_IPV4_ROUTE_ADD) {
6319 + ldp_ipv4_add(mpls, &p, &nexthop);
6321 + ldp_ipv4_delete(mpls, &p, &nexthop);
6326 +void mpls_zebra_init() {
6329 + /* Allocate zebra structure. */
6330 + zclient = zclient_new();
6331 + zclient_init(zclient, ZEBRA_ROUTE_MPLS);
6332 + for (i = 0;i < ZEBRA_ROUTE_MAX;i++) {
6333 + zclient->redist[i] = 1;
6335 + zclient->router_id_update = mpls_router_id_update_zebra;
6336 + zclient->interface_add = mpls_interface_add;
6337 + zclient->interface_delete = mpls_interface_delete;
6338 + zclient->interface_up = mpls_interface_state_up;
6339 + zclient->interface_down = mpls_interface_state_down;
6340 + zclient->interface_address_add = mpls_interface_address_add;
6341 + zclient->interface_address_delete = mpls_interface_address_delete;
6342 + zclient->ipv4_route_add = mpls_zebra_read_ipv4;
6343 + zclient->ipv4_route_delete = mpls_zebra_read_ipv4;
6345 diff --exclude=CVS -uNr zebra/mplsd/mpls_zebra.h zebra-ldp/mplsd/mpls_zebra.h
6346 --- zebra/mplsd/mpls_zebra.h 1969-12-31 18:00:00.000000000 -0600
6347 +++ zebra-ldp/mplsd/mpls_zebra.h 2003-02-26 15:47:44.000000000 -0600
6349 +#ifndef _ZEBRA_MPLS_ZEBRA_H
6350 +#define _ZEBRA_MPLS_ZEBRA_H
6352 +#include "prefix.h"
6354 +void mpls_zebra_init();
6357 diff --exclude=CVS -uNr zebra/mplsd/static.c zebra-ldp/mplsd/static.c
6358 --- zebra/mplsd/static.c 1969-12-31 18:00:00.000000000 -0600
6359 +++ zebra-ldp/mplsd/static.c 2003-02-26 15:47:45.000000000 -0600
6364 +#include "command.h"
6365 +#include "memory.h"
6367 +#include "static.h"
6369 +static struct static_outsegment *static_outsegment_new(struct mpls_static *mstatic) {
6370 + struct static_outsegment *new = XMALLOC(MTYPE_MPLS_STATIC, sizeof(*new));
6371 + memset(new,0,sizeof(*new));
6372 + new->node.data = new;
6373 + new->mstatic = mstatic;
6377 +struct static_outsegment *static_outsegment_get(struct mpls_static *mstatic,
6378 + unsigned int index, char create) {
6379 + struct listnode *tmp;
6380 + struct static_outsegment *out;
6382 + LIST_LOOP(mstatic->outsegment,out,tmp) {
6383 + if (out->index == index) {
6389 + out = static_outsegment_new(mstatic);
6390 + out->index = index;
6391 + LISTNODE_ADD(mstatic->outsegment, &out->node);
6397 +void static_outsegment_finish(struct static_outsegment *out) {
6398 + LISTNODE_DELETE(out->mstatic->outsegment, &out->node);
6399 + XFREE(MTYPE_MPLS_STATIC,out);
6402 +static struct static_insegment *static_insegment_new(struct mpls_static *mstatic) {
6403 + struct static_insegment *new = XMALLOC(MTYPE_MPLS_STATIC, sizeof(*new));
6404 + memset(new,0,sizeof(*new));
6405 + new->node.data = new;
6406 + new->mstatic = mstatic;
6410 +struct static_insegment *static_insegment_get(struct mpls_static *mstatic,
6411 + unsigned int index, char create) {
6412 + struct listnode *tmp;
6413 + struct static_insegment *in;
6415 + LIST_LOOP(mstatic->insegment,in,tmp) {
6416 + if (in->index == index) {
6422 + in = static_insegment_new(mstatic);
6423 + in->index = index;
6424 + LISTNODE_ADD(mstatic->insegment, &in->node);
6430 +void static_insegment_finish(struct static_insegment *in) {
6431 + LISTNODE_DELETE(in->mstatic->insegment, &in->node);
6432 + XFREE(MTYPE_MPLS_STATIC,in);
6435 +static struct mpls_static *static_new(struct mpls *mpls) {
6436 + struct mpls_static *new = XMALLOC(MTYPE_MPLS_STATIC, sizeof(*new));
6438 + memset(new,0,sizeof(*new));
6440 + new->outsegment = list_new();
6441 + new->insegment = list_new();
6446 +struct mpls_static *static_get() {
6447 + struct mpls *mpls = mpls_get();
6448 + if (mpls->mstatic) {
6449 + return mpls->mstatic;
6452 + mpls->mstatic = static_new(mpls);
6453 + return mpls->mstatic;
6456 +void static_finish(struct mpls_static *mstatic) {
6457 + struct mpls *mpls = mstatic->mpls;
6459 + XFREE(MTYPE_MPLS_STATIC,mstatic);
6460 + mpls->mstatic = NULL;
6462 diff --exclude=CVS -uNr zebra/mplsd/static.h zebra-ldp/mplsd/static.h
6463 --- zebra/mplsd/static.h 1969-12-31 18:00:00.000000000 -0600
6464 +++ zebra-ldp/mplsd/static.h 2003-02-26 15:47:45.000000000 -0600
6470 +#include "linklist.h"
6473 +#include "lsr_struct.h"
6475 +struct mpls_static {
6476 + struct mpls *mpls;
6477 + mpls_cfg_handle h;
6478 + struct list *insegment;
6479 + struct list *outsegment;
6482 +struct static_insegment {
6483 + struct listnode node;
6484 + struct mpls_static *mstatic;
6485 + unsigned int index;
6488 + unsigned int out_index;
6491 +struct static_outsegment {
6492 + struct listnode node;
6493 + struct mpls_static *mstatic;
6494 + unsigned int index;
6495 + lsr_outsegment out;
6498 +struct mpls_static *static_get();
6499 +void static_finish(struct mpls_static *mstatic);
6500 +struct static_outsegment *static_outsegment_get(struct mpls_static *mstatic,
6501 + unsigned int index, char create);
6502 +void static_outsegment_finish(struct static_outsegment *out);
6503 +struct static_insegment *static_insegment_get(struct mpls_static *mstatic,
6504 + unsigned int index, char create);
6505 +void static_insegment_finish(struct static_insegment *in);
6508 diff --exclude=CVS -uNr zebra/mplsd/static_tunnel.c zebra-ldp/mplsd/static_tunnel.c
6509 --- zebra/mplsd/static_tunnel.c 1969-12-31 18:00:00.000000000 -0600
6510 +++ zebra-ldp/mplsd/static_tunnel.c 2003-02-26 15:47:45.000000000 -0600
6516 +#include "command.h"
6517 +#include "memory.h"
6518 +#include "out-segment.h"
6520 +#include "tunnel.h"
6521 +#include "interface.h"
6522 +#include "utility.h"
6523 +#include <linux/mpls.h>
6525 +struct list *mplsd_tunnel_list;
6527 +struct mplsd_tunnel *mplsd_tunnel_lookup_by_name(char *name) {
6529 + struct mplsd_tunnel *ifp;
6531 + for (node = listhead(mplsd_tunnel_list); node; nextnode(node)) {
6532 + ifp = getdata(node);
6533 + if (strncmp(name, ifp->iff.name, sizeof(ifp->iff.name)) == 0) {
6540 +struct mplsd_tunnel *mplsd_tunnel_create(char *name, int mode) {
6541 + struct mplsd_tunnel *ifp;
6545 + ifp = XMALLOC(MTYPE_MPLS_STATIC, sizeof(struct mplsd_tunnel));
6546 + if(!ifp) return NULL;
6547 + memset(ifp, 0, sizeof(struct mplsd_tunnel));
6549 + listnode_add(mplsd_tunnel_list, ifp);
6551 + strncpy(ifr.ifr_name,name,IFNAMSIZ);
6553 + result = mplsd_ioctl(SIOCMPLSTUNNELADD, (caddr_t)&ifr);
6555 + result = mplsd_ioctl(SIOCGIFINDEX, (caddr_t)&ifr);
6556 + strncpy(ifp->iff.name, name, INTERFACE_NAMSIZ);
6557 + ifp->iff.ifindex = ifr.ifr_ifindex;
6561 +void mplsd_tunnel_delete(struct mplsd_tunnel *ifp, int mode) {
6563 + listnode_delete(mplsd_tunnel_list, ifp);
6569 + strncpy(ifr.ifr_name,ifp->iff.name,IFNAMSIZ);
6570 + result = mplsd_ioctl(SIOCMPLSTUNNELDEL, (caddr_t)&ifr);
6573 + XFREE(MTYPE_MPLS_STATIC, ifp);
6576 +DEFUN (mplsd_tunnel,
6579 + "Create a pseudo tunnel\n"
6580 + "Tunnel's name\n") {
6581 + struct mplsd_interface_wait *wait;
6582 + struct interface *ifp;
6583 + struct mplsd_tunnel *tun;
6586 + if(sscanf(argv[0],"mpls%d",&num) != 1) {
6587 + vty_out (vty, "Tunnel names must be in the form 'mpls%%d'%s", VTY_NEWLINE);
6588 + return CMD_WARNING;
6591 + if (!(tun = mplsd_tunnel_lookup_by_name(argv[0]))) {
6592 + tun = mplsd_tunnel_create(argv[0], 1);
6594 + if (!(wait = mplsd_interface_wait_new())) {
6595 + vty_out(vty, "Unable to register for interface%s", VTY_NEWLINE);
6596 + return CMD_ERR_INCOMPLETE;
6599 + wait->data[0] = tun;
6600 + strncpy(wait->ifname, argv[0], INTERFACE_NAMSIZ);
6603 + if (!(ifp = if_lookup_by_name(argv[0]))) {
6605 + wait->callback = mplsd_tunnel_callback_add;
6606 + mplsd_interface_add_wait_add(wait);
6610 + wait->callback = mplsd_tunnel_callback_delete;
6611 + mplsd_interface_add_wait_del(wait);
6617 + vty->node = MPLS_IF_NODE;
6619 + return CMD_SUCCESS;
6622 +DEFUN (no_mplsd_tunnel,
6623 + no_mplsd_tunnel_cmd,
6624 + "no tunnel IFNAME",
6625 + "Delete a pseudo tunnel's configuration\n"
6626 + "Tunnel's name\n") {
6627 + struct mplsd_tunnel *tun;
6629 + tun = mplsd_tunnel_lookup_by_name(argv[0]);
6631 + vty_out (vty, "Tunnel %s does not exist%s", argv[0], VTY_NEWLINE);
6632 + return CMD_WARNING;
6636 + mplsd_interface_remove_wait_add(tun->wait);
6637 + mplsd_interface_remove_wait_del(tun->wait);
6640 + /* Delete tunnel */
6641 + mplsd_tunnel_delete(tun, 1);
6643 + return CMD_SUCCESS;
6646 +extern struct mplsd_static_info *mplsd_static_info;
6648 +DEFUN (mplsd_tunnel_out_segment,
6649 + mplsd_tunnel_out_segment_cmd,
6650 + "out-segment INDEX",
6651 + "Assign an out-segment to this tunnel\n"
6652 + "MPLS out-segment index\n") {
6654 + struct mplsd_out_segment *out_old;
6655 + struct mplsd_out_segment *out;
6656 + struct interface *tun;
6657 + struct mpls_label ml;
6662 + if (!(out = mplsd_out_segment_lookup_by_index(mplsd_static_info,
6663 + atoi(argv[0])))) {
6664 + vty_out(vty, "Unable to find out-segment %s%s", argv[0], VTY_NEWLINE);
6665 + return CMD_WARNING;
6668 + out_old = (struct mplsd_out_segment*)tun->info;
6670 + mos2ml(out_old,&ml);
6671 + memcpy(&ifr.ifr_data,&ml,sizeof(struct mpls_label));
6672 + mplsd_ioctl(SIOCMPLSTUNNELDELOUT,(caddr_t)&ifr);
6676 + memcpy(&ifr.ifr_data,&ml,sizeof(struct mpls_label));
6677 + if (mplsd_ioctl(SIOCMPLSTUNNELADDOUT,(caddr_t)&ifr)) {
6678 + vty_out(vty, "Unable to set out-segment %s on tunnel %s%s", argv[0],
6679 + tun->name, VTY_NEWLINE);
6680 + return CMD_WARNING;
6683 + return CMD_SUCCESS;
6686 +DEFUN (no_mplsd_tunnel_out_segment,
6687 + no_mplsd_tunnel_out_segment_cmd,
6689 + "Delete the out-segment associated with this tunnel\n"
6690 + "MPLS out-segment index\n") {
6692 + struct interface *tun;
6697 + struct mplsd_out_segment *out = tun->info;
6698 + struct mpls_label ml;
6702 + memcpy(&ifr.ifr_data,&ml,sizeof(struct mpls_label));
6703 + mplsd_ioctl(SIOCMPLSTUNNELDELOUT,(caddr_t)&ifr);
6706 + return CMD_SUCCESS;
6709 +static void mplsd_dump_tunnel_vty(struct vty *vty, struct mplsd_tunnel *ifp) {
6710 + vty_out (vty, "Tunnel %s%s", ifp->iff.name, VTY_NEWLINE);
6711 + if (ifp->iff.desc) {
6712 + vty_out (vty, " Description: %s%s", ifp->iff.desc, VTY_NEWLINE);
6714 + if (ifp->iff.ifindex <= 0) {
6715 + vty_out(vty, " index %d pseudo tunnel%s", ifp->iff.ifindex, VTY_NEWLINE);
6717 + vty_out (vty, "%s", VTY_NEWLINE);
6720 +DEFUN (mplsd_show_tunnel, mplsd_show_tunnel_cmd,
6721 + "show tunnel [IFNAME]",
6723 + "MPLS Tunnel status and configuration\n"
6724 + "Inteface name\n") {
6726 + struct mplsd_tunnel *ifp;
6729 + ifp = mplsd_tunnel_lookup_by_name(argv[0]);
6730 + if (ifp == NULL) {
6731 + vty_out(vty, "%% Can't find tunnel %s%s", argv[0], VTY_NEWLINE);
6732 + return CMD_WARNING;
6734 + mplsd_dump_tunnel_vty(vty, ifp);
6735 + return CMD_SUCCESS;
6738 + for (node = listhead(mplsd_tunnel_list); node; nextnode(node)) {
6739 + mplsd_dump_tunnel_vty(vty, getdata(node));
6742 + return CMD_SUCCESS;
6745 +static int mplsd_tunnel_config_write(struct vty *vty) {
6747 + struct interface *ifp;
6749 + for (node = listhead(mplsd_tunnel_list); node; nextnode(node)) {
6750 + ifp = getdata(node);
6751 + vty_out (vty, "tunnel %s%s", ifp->name, VTY_NEWLINE);
6754 + vty_out (vty, "!%s", VTY_NEWLINE);
6758 +static struct cmd_node mplsd_tunnel_node = {MPLS_IF_NODE, "%s(config-tun)# ", 1};
6760 +void mplsd_tunnel_init () {
6761 + mplsd_tunnel_list = list_new();
6763 + install_node(&mplsd_tunnel_node, mplsd_tunnel_config_write);
6764 + install_default(MPLS_IF_NODE);
6766 + install_element(VIEW_NODE, &mplsd_show_tunnel_cmd);
6767 + install_element(ENABLE_NODE, &mplsd_show_tunnel_cmd);
6769 + install_element(CONFIG_NODE, &mplsd_tunnel_cmd);
6770 + install_element(CONFIG_NODE, &no_mplsd_tunnel_cmd);
6772 diff --exclude=CVS -uNr zebra/mplsd/static_tunnel.h zebra-ldp/mplsd/static_tunnel.h
6773 --- zebra/mplsd/static_tunnel.h 1969-12-31 18:00:00.000000000 -0600
6774 +++ zebra-ldp/mplsd/static_tunnel.h 2003-02-26 15:47:45.000000000 -0600
6776 +#ifndef MPLS_TUNNEL_H
6777 +#define MPLS_TUNNEL_H
6781 +struct mplsd_tunnel {
6782 + struct interface iff;
6783 + struct mplsd_interface_wait *wait;
6784 + struct mplsd_out_segment *out;
6787 +extern void mplsd_tunnel_init();
6788 +extern struct mplsd_tunnel *mplsd_tunnel_lookup_by_name(char *name);
6789 +extern struct mplsd_tunnel *mplsd_tunnel_create(char *name, int mode);
6790 +extern void mplsd_tunnel_delete(struct mplsd_tunnel *ifp, int mode);
6793 diff --exclude=CVS -uNr zebra/mplsd/static_vty.c zebra-ldp/mplsd/static_vty.c
6794 --- zebra/mplsd/static_vty.c 1969-12-31 18:00:00.000000000 -0600
6795 +++ zebra-ldp/mplsd/static_vty.c 2003-02-26 15:47:45.000000000 -0600
6800 +#include "command.h"
6803 +#include "mpls_vty.h"
6804 +#include "static.h"
6806 +#include "lsr_cfg.h"
6808 +char *owner_name[4] = { "LDP", "CR-LDP", "STATIC", "RSVP" };
6810 +DEFUN (mpls_static,
6813 + "MPLS configuration\n"
6814 + "Static MPLS configuration\n") {
6816 + vty->node = MPLS_STATIC_NODE;
6817 + vty->index = static_get();
6819 + return CMD_SUCCESS;
6822 +DEFUN (no_mpls_static,
6823 + no_mpls_static_cmd,
6826 + "MPLS configuration\n"
6827 + "Static MPLS configuration\n") {
6828 + struct mpls *mpls = mpls_get();
6830 + if (!mpls->mstatic) {
6831 + vty_out (vty, "There isn't an active static MPLS instance.%s",
6833 + return CMD_WARNING;
6836 + static_finish(mpls->mstatic);
6837 + return CMD_SUCCESS;
6840 +static int do_mpls_static_insegment(struct static_insegment *in,
6841 + unsigned int label, unsigned int labelspace) {
6842 + in->in.info.label.type = MPLS_LABEL_TYPE_GENERIC;
6843 + in->in.info.label.u.gen = label;
6844 + in->in.info.labelspace = labelspace;
6845 + in->in.info.owner = MPLS_OWNER_STATIC;
6846 + in->in.info.family = MPLS_FAMILY_IPV4;
6847 + in->in.info.npop = 1;
6848 + return lsr_cfg_insegment_set(in->mstatic->mpls->h,&in->in,LSR_CFG_ADD|
6849 + LSR_INSEGMENT_CFG_NPOP|LSR_INSEGMENT_CFG_FAMILY|
6850 + LSR_INSEGMENT_CFG_LABELSPACE|LSR_INSEGMENT_CFG_LABEL|
6851 + LSR_INSEGMENT_CFG_OWNER);
6854 +static int do_mpls_static_outsegment(struct static_outsegment *out,
6855 + unsigned int label, mpls_nexthop *nh) {
6856 + out->out.info.label.type = MPLS_LABEL_TYPE_GENERIC;
6857 + out->out.info.label.u.gen = label;
6858 + out->out.info.owner = MPLS_OWNER_STATIC;
6859 + out->out.info.push_label = MPLS_BOOL_TRUE;
6860 + memcpy(&out->out.info.nexthop, nh, sizeof(mpls_nexthop));
6862 + return lsr_cfg_outsegment_set(out->mstatic->mpls->h,&out->out, LSR_CFG_ADD|
6863 + LSR_OUTSEGMENT_CFG_PUSH_LABEL|LSR_OUTSEGMENT_CFG_OWNER|
6864 + LSR_OUTSEGMENT_CFG_LABEL|LSR_OUTSEGMENT_CFG_NEXTHOP);
6867 +static int do_mpls_static_xconnect(struct static_insegment *in,
6868 + struct static_outsegment *out) {
6869 + in->xc.insegment_index = in->in.index;
6870 + in->xc.outsegment_index = out->out.index;
6871 + in->xc.info.owner = MPLS_OWNER_STATIC;
6872 + in->xc.info.lspid = 1;
6873 + return lsr_cfg_xconnect_set2(in->mstatic->mpls->h, &in->xc, LSR_CFG_ADD|
6874 + LSR_XCONNECT_CFG_OUTSEGMENT|LSR_XCONNECT_CFG_INSEGMENT|
6875 + LSR_XCONNECT_CFG_LSPID|LSR_XCONNECT_CFG_OWNER);
6878 +DEFUN (mpls_static_in_segment,
6879 + mpls_static_in_segment_cmd,
6880 + "in-segment INDEX generic LABEL LABELSPACE",
6881 + "Create an MPLS in-segment\n"
6882 + "Insegment index\n"
6883 + "Generic label family\n"
6884 + "Generic label value\n"
6886 + struct mpls_static *mstatic = (struct mpls_static*)vty->index;
6887 + struct static_insegment *in;
6888 + unsigned int index;
6889 + unsigned int label;
6890 + unsigned int labelspace;
6892 + VTY_GET_UINT32("INDEX",index,argv[0]);
6893 + VTY_GET_UINT32_RANGE("LABEL",label,argv[1],16,0xFFFFF);
6894 + VTY_GET_UINT32_RANGE("LABELSPACE",labelspace,argv[2],0,255);
6896 + if ((in = static_insegment_get(mstatic, index, 0))) {
6897 + vty_out (vty, "There is an insegment with index %d already.%s", index,
6899 + return CMD_WARNING;
6902 + in = static_insegment_get(mstatic, index, 1);
6903 + do_mpls_static_insegment(in, label, labelspace);
6904 + return CMD_SUCCESS;
6907 +DEFUN (mpls_static_in_segment_xc,
6908 + mpls_static_in_segment_xc_cmd,
6909 + "in-segment INDEX generic LABEL LABELSPACE cross-connect OUTINDEX",
6910 + "Create an MPLS in-segment\n"
6911 + "Insegment index\n"
6912 + "Generic label family\n"
6913 + "Generic label value\n"
6916 + "Outsegment Index\n") {
6917 + struct mpls_static *mstatic = (struct mpls_static*)vty->index;
6918 + struct static_insegment *in;
6919 + struct static_outsegment *out;
6920 + unsigned int index;
6921 + unsigned int label;
6922 + unsigned int labelspace;
6923 + unsigned int out_index;
6925 + VTY_GET_UINT32("INDEX",index,argv[0]);
6926 + VTY_GET_UINT32_RANGE("LABEL",label,argv[1],16,0xFFFFF);
6927 + VTY_GET_UINT32_RANGE("LABELSPACE",labelspace,argv[2],0,255);
6928 + VTY_GET_UINT32("OUTINDEX",out_index,argv[3]);
6930 + if (!(out = static_outsegment_get(mstatic, out_index, 0))) {
6931 + vty_out (vty, "There isn't an outsegment with index %d.%s", out_index,
6933 + return CMD_WARNING;
6936 + in = static_insegment_get(mstatic, index, 1);
6937 + if (in->in.index) {
6938 + if (in->in.info.label.type != MPLS_LABEL_TYPE_GENERIC ||
6939 + in->in.info.label.u.gen != label ||
6940 + in->in.info.labelspace != labelspace ||
6941 + in->in.info.owner != MPLS_OWNER_STATIC) {
6942 + vty_out (vty, "There is an insegment with index %d, label %d,"
6943 + "and labelspace %d already.%s", index, label, labelspace,
6945 + return CMD_WARNING;
6948 + do_mpls_static_insegment(in, label, labelspace);
6951 + if (in->out_index) {
6952 + vty_out (vty, "Insegment %d is already cross-connect to "
6953 + "outsegment %d.%s", index, in->out_index, VTY_NEWLINE);
6954 + return CMD_WARNING;
6956 + in->out_index = out_index;
6957 + do_mpls_static_xconnect(in, out);
6959 + return CMD_SUCCESS;
6962 +DEFUN (mpls_static_in_segment_xc2,
6963 + mpls_static_in_segment_xc2_cmd,
6964 + "in-segment INDEX cross-connect OUTINDEX",
6965 + "Create an MPLS in-segment\n"
6966 + "Insegment index\n"
6968 + "Outsegment Index\n") {
6969 + struct mpls_static *mstatic = (struct mpls_static*)vty->index;
6970 + struct static_insegment *in;
6971 + struct static_outsegment *out;
6972 + unsigned int index;
6973 + unsigned int out_index;
6975 + VTY_GET_UINT32("INDEX",index,argv[0]);
6976 + VTY_GET_UINT32("OUTINDEX",out_index,argv[1]);
6978 + if (!(in = static_insegment_get(mstatic, index, 0))) {
6979 + vty_out (vty, "There isn't an insegment with index %d.%s", index,
6981 + return CMD_WARNING;
6984 + if (!(out = static_outsegment_get(mstatic, out_index, 0))) {
6985 + vty_out (vty, "There isn't an outsegment with index %d.%s", out_index,
6987 + return CMD_WARNING;
6990 + do_mpls_static_xconnect(in, out);
6992 + return CMD_SUCCESS;
6995 +DEFUN (no_mpls_static_in_segment,
6996 + no_mpls_static_in_segment_cmd,
6997 + "no in-segment INDEX",
6999 + "Delete an MPLS in-segment\n"
7000 + "Index of In-segment\n") {
7001 + struct mpls_static *mstatic = (struct mpls_static*)vty->index;
7002 + struct static_insegment *in;
7005 + VTY_GET_UINT32("INDEX",index,argv[0]);
7007 + if (!(in = static_insegment_get(mstatic, index, 0))) {
7008 + vty_out (vty, "There isn't an insegment with the index %d.%s", index,
7010 + return CMD_WARNING;
7012 + lsr_cfg_insegment_set(in->mstatic->mpls->h,&in->in,LSR_CFG_DEL);
7013 + static_insegment_finish(in);
7014 + return CMD_SUCCESS;
7017 +DEFUN (no_mpls_static_in_segment_xc,
7018 + no_mpls_static_in_segment_xc_cmd,
7019 + "no in-segment INDEX cross-connect",
7021 + "Delete an MPLS in-segment\n"
7022 + "Index of In-segment\n"
7023 + "Cross Connect\n") {
7024 + struct mpls_static *mstatic = (struct mpls_static*)vty->index;
7025 + struct static_insegment *in;
7028 + VTY_GET_UINT32("INDEX",index,argv[0]);
7030 + if (!(in = static_insegment_get(mstatic, index, 0))) {
7031 + vty_out (vty, "There isn't an insegment with the index %d.%s", index,
7033 + return CMD_WARNING;
7035 + if (!in->out_index) {
7036 + vty_out (vty, "Insegment %d is not cross-conencted to anything.%s",
7037 + index, VTY_NEWLINE);
7038 + return CMD_WARNING;
7040 + lsr_cfg_xconnect_set(in->mstatic->mpls->h,&in->xc,LSR_CFG_DEL);
7041 + in->out_index = 0;
7042 + return CMD_SUCCESS;
7045 +DEFUN (mpls_static_out_segment_nh_ipaddr,
7046 + mpls_static_out_segment_nh_ipaddr_cmd,
7047 + "out-segment INDEX generic LABEL next-hop IPADDR",
7048 + "Create an MPLS out-segment\n"
7049 + "Index for the out-segment\n"
7050 + "Generic label family\n"
7051 + "Generic label value\n"
7054 + struct mpls_static *mstatic = (struct mpls_static*)vty->index;
7055 + struct static_outsegment *out;
7056 + struct interface *iff;
7057 + unsigned int index;
7058 + unsigned int label;
7059 + struct in_addr ip;
7062 + VTY_GET_UINT32("INDEX",index,argv[0]);
7063 + VTY_GET_UINT32("LABEL",label,argv[1]);
7064 + VTY_GET_IPV4_ADDRESS("NEXTHOP",ip,argv[2]);
7066 + if ((out = static_outsegment_get(mstatic, index, 0))) {
7067 + vty_out (vty, "There is an insegment with index %d already.%s", index,
7069 + return CMD_WARNING;
7072 + out = static_outsegment_get(mstatic, index, 1);
7073 + iff = if_lookup_address(ip);
7074 + nh.type = MPLS_NH_IP|MPLS_NH_IF;
7075 + nh.if_handle = iff;
7076 + nh.ip.u.ipv4 = ntohl(ip.s_addr);
7078 + do_mpls_static_outsegment(out, label, &nh);
7080 + return CMD_SUCCESS;
7083 +DEFUN (mpls_static_out_segment_nh_intf,
7084 + mpls_static_out_segment_nh_intf_cmd,
7085 + "out-segment INDEX generic LABEL interface IFNAME",
7086 + "Create an MPLS out-segment\n"
7087 + "Index for the out-segment\n"
7088 + "Generic label family\n"
7089 + "Generic label value\n"
7092 + struct mpls_static *mstatic = (struct mpls_static*)vty->index;
7093 + struct static_outsegment *out;
7094 + struct interface *iff;
7095 + unsigned int index;
7096 + unsigned int label;
7099 + VTY_GET_UINT32("INDEX",index,argv[0]);
7100 + VTY_GET_UINT32("LABEL",label,argv[1]);
7102 + if ((out = static_outsegment_get(mstatic, index, 0))) {
7103 + vty_out (vty, "There is an insegment with index %d already.%s", index,
7105 + return CMD_WARNING;
7108 + out = static_outsegment_get(mstatic, index, 1);
7109 + iff = if_lookup_by_name(argv[2]);
7110 + nh.type = MPLS_NH_IF;
7111 + nh.if_handle = iff;
7113 + do_mpls_static_outsegment(out, label, &nh);
7115 + return CMD_SUCCESS;
7118 +DEFUN (no_mpls_static_out_segment,
7119 + no_mpls_static_out_segment_cmd,
7120 + "no out-segment INDEX",
7122 + "Delete an MPLS out-segment\n"
7123 + "Index of the out-segment\n") {
7124 + struct mpls_static *mstatic = (struct mpls_static*)vty->index;
7125 + struct static_outsegment *out;
7126 + unsigned int index;
7128 + VTY_GET_UINT32("INDEX",index,argv[0]);
7130 + if (!(out = static_outsegment_get(mstatic, index, 0))) {
7131 + vty_out (vty, "There isn't an outsegment with the index %d.%s", index,
7133 + return CMD_WARNING;
7136 + lsr_cfg_outsegment_set(out->mstatic->mpls->h,&out->out,LSR_CFG_DEL);
7137 + static_outsegment_finish(out);
7138 + return CMD_SUCCESS;
7141 +DEFUN (mpls_show_mpls_fwd, mpls_show_mpls_fwd_cmd,
7142 + "show mpls forwarding",
7144 + "MPLS related commands\n"
7145 + "MPLS forwarding table\n") {
7146 + struct mpls *mpls = mpls_get();
7147 + struct lsr_outsegment out;
7148 + struct lsr_insegment in;
7149 + struct lsr_xconnect xc;
7150 + struct in_addr ip;
7151 + struct interface *iff;
7155 + vty_out (vty, "There isn't an active MPLS instance.%s",
7157 + return CMD_WARNING;
7160 + vty_out(vty, "Insegments:%s",VTY_NEWLINE);
7164 + while (lsr_cfg_insegment_getnext(mpls->h,&in,0xFFFFFFFF)==MPLS_SUCCESS) {
7166 + vty_out(vty, " Lbl Spc Label Owner%s", VTY_NEWLINE);
7168 + vty_out(vty, " %-3d %7d %-6s%s", in.info.labelspace,
7169 + in.info.label.u.gen, owner_name[in.info.owner], VTY_NEWLINE);
7173 + vty_out(vty, "%s", VTY_NEWLINE);
7175 + vty_out(vty, "Total %d%s",count, VTY_NEWLINE);
7176 + vty_out(vty, "%s", VTY_NEWLINE);
7178 + vty_out(vty, "Outsegments:%s",VTY_NEWLINE);
7181 + while (lsr_cfg_outsegment_getnext(mpls->h,&out,0xFFFFFFFF)==MPLS_SUCCESS) {
7183 + vty_out(vty, " Interface Label Next Hop Owner%s",
7186 + if (out.info.nexthop.type & MPLS_NH_IP) {
7187 + ip.s_addr = htonl(out.info.nexthop.ip.u.ipv4);
7191 + if (out.info.nexthop.type & MPLS_NH_IF) {
7192 + iff = out.info.nexthop.if_handle;
7196 + vty_out(vty, " %-16s %7d %-15s %-6s%s",iff->name,
7197 + out.info.label.u.gen, inet_ntoa(ip), owner_name[out.info.owner],
7202 + vty_out(vty, "%s", VTY_NEWLINE);
7204 + vty_out(vty, "Total %d%s",count, VTY_NEWLINE);
7205 + vty_out(vty, "%s", VTY_NEWLINE);
7207 + vty_out(vty, "Cross Connects:%s",VTY_NEWLINE);
7210 + while (lsr_cfg_xconnect_getnext(mpls->h,&xc,0xFFFFFFFF) == MPLS_SUCCESS) {
7212 + vty_out(vty, " Lbl Spc In Label Out Label Interface "
7213 + "Next Hop Owner%s", VTY_NEWLINE);
7216 + in.index = xc.insegment_index;
7217 + lsr_cfg_insegment_get(mpls->h,&in,0xFFFFFFFF);
7219 + out.index = xc.outsegment_index;
7220 + lsr_cfg_outsegment_get(mpls->h,&out,0xFFFFFFFF);
7221 + if (out.info.nexthop.type & MPLS_NH_IP) {
7222 + ip.s_addr = htonl(out.info.nexthop.ip.u.ipv4);
7226 + if (out.info.nexthop.type & MPLS_NH_IF) {
7227 + iff = out.info.nexthop.if_handle;
7232 + vty_out(vty, " %-3d %7d %7d %-16s %-15s %-6s%s",
7233 + in.info.labelspace, in.info.label.u.gen, out.info.label.u.gen,
7234 + iff->name, inet_ntoa(ip), owner_name[in.info.owner], VTY_NEWLINE);
7238 + vty_out(vty, "%s", VTY_NEWLINE);
7240 + vty_out(vty, "Total %d%s",count, VTY_NEWLINE);
7241 + vty_out(vty, "%s", VTY_NEWLINE);
7243 + return CMD_SUCCESS;
7246 +DEFUN (mpls_show_mpls_ftn, mpls_show_mpls_ftn_cmd,
7249 + "MPLS related commands\n"
7250 + "MPLS FTN bindings\n") {
7251 + struct mpls *mpls = mpls_get();
7252 + lsr_outsegment out;
7254 + struct interface *iff;
7255 + struct in_addr ip;
7259 + vty_out(vty, "FTNs:%s",VTY_NEWLINE);
7261 + while (lsr_cfg_ftn_getnext(mpls->h,&ftn,0xFFFFFFFF) == MPLS_SUCCESS) {
7263 + vty_out(vty, " FEC Out Label Interface "
7264 + "Next Hop Owner%s", VTY_NEWLINE);
7267 + out.index = ftn.outsegment_index;
7268 + lsr_cfg_outsegment_get(mpls->h,&out,0xFFFFFFFF);
7270 + vty_out(vty, " ");
7271 + switch(ftn.fec.type) {
7272 + case MPLS_FEC_PREFIX:
7273 + ip.s_addr = htonl(ftn.fec.u.prefix.network.u.ipv4);
7274 + sprintf(buf, "%s/%d", inet_ntoa(ip),ftn.fec.u.prefix.length);
7275 + vty_out(vty, "%-18s", buf);
7277 + case MPLS_FEC_HOST:
7278 + ip.s_addr = htonl(ftn.fec.u.host.u.ipv4);
7279 + vty_out(vty, "%-18s", inet_ntoa(ip));
7281 + case MPLS_FEC_L2CC:
7283 + vty_out(vty, "%-18s", "(unknown)");
7285 + vty_out(vty, " ");
7287 + if (out.info.nexthop.type & MPLS_NH_IP) {
7288 + ip.s_addr = htonl(out.info.nexthop.ip.u.ipv4);
7292 + if (out.info.nexthop.type & MPLS_NH_IF) {
7293 + iff = out.info.nexthop.if_handle;
7297 + vty_out(vty, "%7d %-15s %-15s %-6s%s", out.info.label.u.gen,
7298 + iff->name, inet_ntoa(ip), owner_name[out.info.owner], VTY_NEWLINE);
7304 + vty_out(vty, "%s", VTY_NEWLINE);
7306 + vty_out(vty, "Total %d%s",count, VTY_NEWLINE);
7307 + vty_out(vty, "%s", VTY_NEWLINE);
7308 + return CMD_SUCCESS;
7311 +static int mpls_static_config_write (struct vty *vty) {
7312 + struct mpls *mpls = mpls_get();
7313 + struct mpls_static *mstatic = mpls->mstatic;
7314 + struct static_outsegment *out;
7315 + struct static_insegment *in;
7316 + struct listnode *tmp;
7322 + vty_out(vty, "mpls static%s", VTY_NEWLINE);
7324 + LIST_LOOP(mstatic->outsegment, out, tmp) {
7325 + vty_out(vty, " out-segment %d generic %d", out->index,
7326 + out->out.info.label.u.gen);
7327 + if (out->out.info.nexthop.type & MPLS_NH_IF) {
7328 + vty_out(vty, " interface %s",
7329 + out->out.info.nexthop.if_handle->name);
7331 + if (out->out.info.nexthop.type & MPLS_NH_IP) {
7332 + struct in_addr ip;
7333 + ip.s_addr = htonl(out->out.info.nexthop.ip.u.ipv4);
7334 + vty_out(vty, " next-hop %s", inet_ntoa(ip));
7336 + vty_out(vty,"%s", VTY_NEWLINE);
7339 + LIST_LOOP(mstatic->insegment, in, tmp) {
7340 + vty_out(vty, " in-segment %d generic %d %d", in->index,
7341 + in->in.info.label.u.gen, in->in.info.labelspace);
7342 + if (in->out_index) {
7343 + vty_out(vty, " cross-connect %d", in->out_index);
7345 + vty_out(vty, "%s", VTY_NEWLINE);
7347 + vty_out(vty,"!%s", VTY_NEWLINE);
7351 +static struct cmd_node static_node = {MPLS_STATIC_NODE,"%s(config-mpls)# ",1};
7353 +void static_vty_show_init() {
7354 + install_element (VIEW_NODE, &mpls_show_mpls_fwd_cmd);
7355 + install_element (ENABLE_NODE, &mpls_show_mpls_fwd_cmd);
7357 + install_element (VIEW_NODE, &mpls_show_mpls_ftn_cmd);
7358 + install_element (ENABLE_NODE, &mpls_show_mpls_ftn_cmd);
7361 +void static_vty_init () {
7363 + install_node (&static_node, mpls_static_config_write);
7364 + install_default (MPLS_STATIC_NODE);
7366 + install_element (CONFIG_NODE, &mpls_static_cmd);
7367 + install_element (CONFIG_NODE, &no_mpls_static_cmd);
7369 + install_element(MPLS_STATIC_NODE, &mpls_static_in_segment_cmd);
7370 + install_element(MPLS_STATIC_NODE, &mpls_static_in_segment_xc_cmd);
7371 + install_element(MPLS_STATIC_NODE, &no_mpls_static_in_segment_cmd);
7372 + install_element(MPLS_STATIC_NODE, &no_mpls_static_in_segment_xc_cmd);
7374 + install_element(MPLS_STATIC_NODE, &mpls_static_out_segment_nh_ipaddr_cmd);
7375 + install_element(MPLS_STATIC_NODE, &mpls_static_out_segment_nh_intf_cmd);
7376 + install_element(MPLS_STATIC_NODE, &no_mpls_static_out_segment_cmd);
7378 diff --exclude=CVS -uNr zebra/mplsd/static_vty.h zebra-ldp/mplsd/static_vty.h
7379 --- zebra/mplsd/static_vty.h 1969-12-31 18:00:00.000000000 -0600
7380 +++ zebra-ldp/mplsd/static_vty.h 2003-02-26 15:47:45.000000000 -0600
7382 +#ifndef STATIC_VTY_H
7383 +#define STATIC_VTY_H
7385 +void static_vty_init();
7386 +void static_vty_show_init();
7389 diff --exclude=CVS -uNr zebra/ospfd/ospfd.c zebra-ldp/ospfd/ospfd.c
7390 --- zebra/ospfd/ospfd.c 2003-03-14 08:45:16.000000000 -0600
7391 +++ zebra-ldp/ospfd/ospfd.c 2003-02-26 15:48:30.000000000 -0600
7393 struct ospf *ospf_top;
7395 extern struct zclient *zclient;
7396 +extern struct in_addr router_id_zebra;
7399 void ospf_remove_vls_through_area (struct ospf_area *);
7401 void ospf_area_free (struct ospf_area *);
7402 void ospf_network_run (struct ospf *, struct prefix *, struct ospf_area *);
7404 -/* Get Router ID from ospf interface list. */
7406 -ospf_router_id_get (list if_list)
7409 - struct in_addr router_id;
7411 - memset (&router_id, 0, sizeof (struct in_addr));
7413 - for (node = listhead (if_list); node; nextnode (node))
7415 - struct ospf_interface *oi = getdata (node);
7417 - if (!if_is_up (oi->ifp) ||
7418 - OSPF_IF_PARAM (oi, passive_interface) == OSPF_IF_PASSIVE)
7421 - /* Ignore virtual link interface. */
7422 - if (oi->type != OSPF_IFTYPE_VIRTUALLINK &&
7423 - oi->type != OSPF_IFTYPE_LOOPBACK)
7424 - if (IPV4_ADDR_CMP (&router_id, &oi->address->u.prefix4) < 0)
7425 - router_id = oi->address->u.prefix4;
7431 #define OSPF_EXTERNAL_LSA_ORIGINATE_DELAY 1
7435 if (ospf_top->router_id_static.s_addr != 0)
7436 router_id = ospf_top->router_id_static;
7438 - router_id = ospf_router_id_get (ospf_top->oiflist);
7439 + router_id = router_id_zebra;
7441 ospf_top->router_id = router_id;
7443 diff --exclude=CVS -uNr zebra/ospfd/ospf_lsdb.c zebra-ldp/ospfd/ospf_lsdb.c
7444 --- zebra/ospfd/ospf_lsdb.c 2003-03-14 08:45:05.000000000 -0600
7445 +++ zebra-ldp/ospfd/ospf_lsdb.c 2003-02-26 15:48:04.000000000 -0600
7450 -foreach_lsa (struct route_table *table, void *p_arg, int int_arg,
7451 - int (*callback) (struct ospf_lsa *, void *, int))
7452 +foreach_lsa (struct route_table *table, void *p_arg, int int_arg,
7453 + int (*callback) (struct ospf_lsa *, void *, int))
7455 struct route_node *rn;
7456 struct ospf_lsa *lsa;
7457 @@ -293,6 +293,21 @@
7458 for (rn = route_top (table); rn; rn = route_next (rn))
7459 if ((lsa = rn->info) != NULL)
7460 if (callback (lsa, p_arg, int_arg))
7467 +foreach_lsa_sum (struct route_table *table, void *p_arg, int *sum, int int_arg,
7468 + int (*callback) (struct ospf_lsa *, void *, int*, int))
7470 + struct route_node *rn;
7471 + struct ospf_lsa *lsa;
7473 + for (rn = route_top (table); rn; rn = route_next (rn))
7474 + if ((lsa = rn->info) != NULL)
7475 + if (callback (lsa, p_arg, sum, int_arg))
7479 diff --exclude=CVS -uNr zebra/ospfd/ospf_lsdb.h zebra-ldp/ospfd/ospf_lsdb.h
7480 --- zebra/ospfd/ospf_lsdb.h 2003-03-14 08:45:05.000000000 -0600
7481 +++ zebra-ldp/ospfd/ospf_lsdb.h 2003-02-26 15:48:06.000000000 -0600
7483 unsigned long ospf_lsdb_isempty (struct ospf_lsdb *);
7484 struct ospf_lsa *foreach_lsa (struct route_table *, void *, int,
7485 int (*callback) (struct ospf_lsa *, void *, int));
7486 +struct ospf_lsa *foreach_lsa_sum (struct route_table *, void *, int *, int,
7487 + int (*callback) (struct ospf_lsa *, void *, int *, int));
7489 #endif /* _ZEBRA_OSPF_LSDB_H */
7490 diff --exclude=CVS -uNr zebra/ospfd/ospf_vty.c zebra-ldp/ospfd/ospf_vty.c
7491 --- zebra/ospfd/ospf_vty.c 2003-03-14 08:45:14.000000000 -0600
7492 +++ zebra-ldp/ospfd/ospf_vty.c 2003-02-26 22:39:57.000000000 -0600
7493 @@ -3046,7 +3046,7 @@
7495 /* Show functions */
7497 -show_lsa_summary (struct ospf_lsa *lsa, void *v, int self)
7498 +show_lsa_summary (struct ospf_lsa *lsa, void *v, int *sum, int self)
7500 struct vty *vty = (struct vty *) v;
7501 struct router_lsa *rl;
7502 @@ -3059,6 +3059,7 @@
7503 if (self == 0 || IS_LSA_SELF (lsa))
7505 /* LSA common part show. */
7506 + (*sum) += ntohs (lsa->data->checksum);
7507 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
7508 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
7509 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
7510 @@ -3592,6 +3593,7 @@
7512 show_ip_ospf_database_summary (struct vty *vty, int self)
7518 @@ -3619,9 +3621,10 @@
7519 VTY_NEWLINE, VTY_NEWLINE);
7520 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
7522 - foreach_lsa (AREA_LSDB (area, type), vty, self, show_lsa_summary);
7524 - vty_out (vty, "%s", VTY_NEWLINE);
7526 + foreach_lsa_sum (AREA_LSDB (area, type), vty, &sum, self, show_lsa_summary);
7527 + vty_out (vty, "%s Sum of CkSum: 0x%08x%s%s",
7528 + VTY_NEWLINE, sum, VTY_NEWLINE, VTY_NEWLINE);
7532 @@ -3646,8 +3649,11 @@
7533 VTY_NEWLINE, VTY_NEWLINE);
7534 vty_out (vty, "%s%s", show_database_header[type],
7536 - foreach_lsa (AS_LSDB (ospf_top, type), vty, self, show_lsa_summary);
7537 - vty_out (vty, "%s", VTY_NEWLINE);
7540 + foreach_lsa_sum (AS_LSDB (ospf_top, type), vty, &sum, self, show_lsa_summary);
7541 + vty_out (vty, "%s Sum of CkSum: 0x%08x%s%s",
7542 + VTY_NEWLINE, sum, VTY_NEWLINE, VTY_NEWLINE);
7546 diff --exclude=CVS -uNr zebra/ospfd/ospf_zebra.c zebra-ldp/ospfd/ospf_zebra.c
7547 --- zebra/ospfd/ospf_zebra.c 2003-03-14 08:45:15.000000000 -0600
7548 +++ zebra-ldp/ospfd/ospf_zebra.c 2003-02-26 22:40:03.000000000 -0600
7551 /* For registering threads. */
7552 extern struct thread_master *master;
7553 +struct in_addr router_id_zebra;
7555 +/* Router-id update message from zebra. */
7557 +ospf_router_id_update_zebra (int command, struct zclient *zclient,
7558 + zebra_size_t length)
7560 + struct prefix router_id;
7561 + zebra_router_id_update_read(zclient->ibuf,&router_id);
7563 + router_id_zebra = router_id.u.prefix4;
7565 + if (ospf_top && ospf_top->t_router_id_update == NULL)
7566 + ospf_top->t_router_id_update = thread_add_timer (master,
7567 + ospf_router_id_update_timer, ospf_top, OSPF_ROUTER_ID_UPDATE_DELAY);
7571 /* Inteface addition message from zebra. */
7573 @@ -147,19 +164,6 @@
7578 -zebra_interface_if_set_value (struct stream *s, struct interface *ifp)
7580 - /* Read interface's index. */
7581 - ifp->ifindex = stream_getl (s);
7583 - /* Read interface's value. */
7584 - ifp->flags = stream_getl (s);
7585 - ifp->metric = stream_getl (s);
7586 - ifp->mtu = stream_getl (s);
7587 - ifp->bandwidth = stream_getl (s);
7591 ospf_interface_state_up (int command, struct zclient *zclient,
7592 zebra_size_t length)
7593 @@ -1166,6 +1170,7 @@
7594 /* Allocate zebra structure. */
7595 zclient = zclient_new ();
7596 zclient_init (zclient, ZEBRA_ROUTE_OSPF);
7597 + zclient->router_id_update = ospf_router_id_update_zebra;
7598 zclient->interface_add = ospf_interface_add;
7599 zclient->interface_delete = ospf_interface_delete;
7600 zclient->interface_up = ospf_interface_state_up;
7601 diff --exclude=CVS -uNr zebra/zebra/main.c zebra-ldp/zebra/main.c
7602 --- zebra/zebra/main.c 2003-03-14 08:45:32.000000000 -0600
7603 +++ zebra-ldp/zebra/main.c 2003-02-26 22:42:44.000000000 -0600
7605 #include "zebra/rib.h"
7606 #include "zebra/zserv.h"
7607 #include "zebra/debug.h"
7608 -#include "zebra/rib.h"
7609 +#include "zebra/router-id.h"
7611 /* Master of threads. */
7612 struct thread_master *master;
7616 zebra_debug_init ();
7619 access_list_init ();
7621 diff --exclude=CVS -uNr zebra/zebra/Makefile.am zebra-ldp/zebra/Makefile.am
7622 --- zebra/zebra/Makefile.am 2003-03-14 08:45:30.000000000 -0600
7623 +++ zebra-ldp/zebra/Makefile.am 2003-02-26 22:42:29.000000000 -0600
7627 zserv.c main.c interface.c connected.c ioctl.c zebra_rib.c \
7628 - redistribute.c debug.c rtadv.c zebra_snmp.c zebra_vty.c
7629 + redistribute.c debug.c rtadv.c zebra_snmp.c zebra_vty.c router-id.c
7632 connected.h ioctl.h rib.h rt.h zserv.h redistribute.h debug.h rtadv.h \
7633 - interface.h ipforward.h
7634 + interface.h ipforward.h router-id.h
7636 zebra_LDADD = ../lib/libzebra.a $(otherobj) $(LIB_IPV6)
7638 diff --exclude=CVS -uNr zebra/zebra/redistribute.c zebra-ldp/zebra/redistribute.c
7639 --- zebra/zebra/redistribute.c 2003-03-14 08:45:33.000000000 -0600
7640 +++ zebra-ldp/zebra/redistribute.c 2003-02-26 22:42:50.000000000 -0600
7642 #include "zebra/zserv.h"
7643 #include "zebra/redistribute.h"
7644 #include "zebra/debug.h"
7645 +#include "zebra/router-id.h"
7648 zebra_check_addr (struct prefix *p)
7650 p->prefixlen, ifc->ifp->name);
7653 + router_id_add_address(ifc);
7655 for (node = listhead (client_list); node; nextnode (node))
7656 if ((client = getdata (node)) != NULL)
7657 if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
7659 p->prefixlen, ifc->ifp->name);
7662 + router_id_del_address(ifc);
7664 for (node = listhead (client_list); node; nextnode (node))
7665 if ((client = getdata (node)) != NULL)
7666 if (client->ifinfo && CHECK_FLAG (ifc->conf, ZEBRA_IFC_REAL))
7667 diff --exclude=CVS -uNr zebra/zebra/rib.h zebra-ldp/zebra/rib.h
7668 --- zebra/zebra/rib.h 2003-03-14 08:45:33.000000000 -0600
7669 +++ zebra-ldp/zebra/rib.h 2003-02-26 22:44:34.000000000 -0600
7671 unsigned int ifindex;
7675 + unsigned int mplsindex;
7677 /* Nexthop address or interface name. */
7681 /* Recursive lookup nexthop. */
7683 unsigned int rifindex;
7684 + unsigned int rmplsindex;
7687 struct in_addr ipv4;
7688 @@ -215,6 +219,11 @@
7692 +#include "prefix.h"
7695 +void rib_process (struct route_node *rn, struct rib *del);
7698 static_add_ipv4 (struct prefix *p, struct in_addr *gate, char *ifname,
7699 u_char distance, u_int32_t vrf_id);
7700 diff --exclude=CVS -uNr zebra/zebra/router-id.c zebra-ldp/zebra/router-id.c
7701 --- zebra/zebra/router-id.c 1969-12-31 18:00:00.000000000 -0600
7702 +++ zebra-ldp/zebra/router-id.c 2003-02-26 15:49:07.000000000 -0600
7708 +#include "sockunion.h"
7709 +#include "prefix.h"
7710 +#include "stream.h"
7711 +#include "command.h"
7712 +#include "memory.h"
7714 +#include "connected.h"
7715 +#include "network.h"
7720 +#include "zebra/zserv.h"
7722 +static struct list rid_all_sorted_list;
7723 +static struct list rid_lo_sorted_list;
7724 +static struct prefix rid_user_assigned;
7725 +extern struct list *client_list;
7727 +static struct connected *router_id_find_node(struct list *l,
7728 + struct connected *ifc) {
7729 + struct listnode *node;
7730 + struct connected *c;
7732 + for (node = l->head; node; node = node->next) {
7733 + c = (struct connected*)getdata(node);
7734 + if (prefix_same(ifc->address,c->address)) {
7741 +static int router_id_bad_address(struct connected *ifc) {
7744 + n.u.prefix4.s_addr = htonl(INADDR_LOOPBACK);
7746 + n.family = AF_INET;
7748 + if (prefix_match(&n,ifc->address)) {
7754 +void router_id_get(struct prefix *p) {
7755 + struct listnode *node;
7756 + struct connected *c;
7758 + p->u.prefix4.s_addr = 0;
7759 + p->family = AF_INET;
7760 + p->prefixlen = 32;
7762 + if (rid_user_assigned.u.prefix4.s_addr) {
7763 + p->u.prefix4.s_addr = rid_user_assigned.u.prefix4.s_addr;
7764 + } else if (!list_isempty(&rid_lo_sorted_list)) {
7765 + node = listtail(&rid_lo_sorted_list);
7766 + c = getdata(node);
7767 + p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
7768 + } else if (!list_isempty(&rid_all_sorted_list)) {
7769 + node = listtail(&rid_all_sorted_list);
7770 + c = getdata(node);
7771 + p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
7775 +static void router_id_set(struct prefix *p) {
7777 + struct listnode *node;
7778 + struct zserv *client;
7780 + rid_user_assigned.u.prefix4.s_addr = p->u.prefix4.s_addr;
7782 + router_id_get(&p2);
7783 + for (node = listhead(client_list); node; nextnode(node))
7784 + if ((client = getdata(node)) != NULL)
7785 + zsend_router_id_update(client,&p2);
7788 +void router_id_add_address(struct connected *ifc) {
7789 + struct list *l = NULL;
7790 + struct listnode *node;
7791 + struct prefix before;
7792 + struct prefix after;
7793 + struct zserv *client;
7795 + if (router_id_bad_address(ifc)) {
7799 + router_id_get(&before);
7801 + if (!strncmp(ifc->ifp->name,"lo",2) || !strncmp(ifc->ifp->name,"dummy",5)) {
7802 + l = &rid_lo_sorted_list;
7804 + l = &rid_all_sorted_list;
7806 + if (!router_id_find_node(l,ifc)) {
7807 + listnode_add(l,ifc);
7810 + router_id_get(&after);
7812 + if (prefix_same(&before, &after)) {
7816 + for (node = listhead(client_list); node; nextnode(node))
7817 + if ((client = getdata(node)) != NULL)
7818 + zsend_router_id_update(client,&after);
7821 +void router_id_del_address(struct connected *ifc) {
7822 + struct connected *c;
7824 + struct prefix after;
7825 + struct prefix before;
7826 + struct listnode *node;
7827 + struct zserv *client;
7829 + if (router_id_bad_address(ifc)) {
7833 + router_id_get(&before);
7835 + if (!strncmp(ifc->ifp->name,"lo",2) || !strncmp(ifc->ifp->name,"dummy",5)) {
7836 + l = &rid_lo_sorted_list;
7838 + l = &rid_all_sorted_list;
7841 + if ((c = router_id_find_node(l,ifc))) {
7842 + listnode_delete(l,c);
7845 + router_id_get(&after);
7847 + if (prefix_same(&before, &after)) {
7851 + for (node = listhead(client_list); node; nextnode(node))
7852 + if ((client = getdata(node)) != NULL)
7853 + zsend_router_id_update(client,&after);
7856 +void router_id_write(struct vty *vty) {
7857 + if (rid_user_assigned.u.prefix4.s_addr) {
7858 + vty_out(vty, "router-id %s%s", inet_ntoa(rid_user_assigned.u.prefix4),
7865 + "router-id A.B.C.D",
7866 + "Manually set the router-id\n"
7867 + "IP address to use for router-id\n")
7869 + struct prefix rid;
7871 + rid.u.prefix4.s_addr = inet_addr(argv[0]);
7872 + if (!rid.u.prefix4.s_addr) {
7873 + return CMD_WARNING;
7875 + rid.prefixlen = 32;
7876 + rid.family = AF_INET;
7878 + router_id_set(&rid);
7880 + return CMD_SUCCESS;
7883 +DEFUN (no_router_id,
7887 + "Remove the manually configured router-id\n")
7889 + struct prefix rid;
7891 + rid.u.prefix4.s_addr = 0;
7892 + rid.prefixlen = 0;
7893 + rid.family = AF_INET;
7895 + router_id_set(&rid);
7897 + return CMD_SUCCESS;
7900 +DEFUN (show_router_id,
7901 + show_router_id_cmd,
7904 + "current router ID\n")
7906 + struct prefix rid;
7907 + router_id_get(&rid);
7909 + vty_out(vty, "router-id: %s%s", inet_ntoa(rid.u.prefix4),VTY_NEWLINE);
7910 + return CMD_SUCCESS;
7913 +int router_id_cmp(void *a, void *b) {
7914 + unsigned int A, B;
7916 + A = ((struct connected*)a)->address->u.prefix4.s_addr;
7917 + B = ((struct connected*)b)->address->u.prefix4.s_addr;
7921 + } else if (A < B) {
7927 +void router_id_init(void) {
7928 + install_element(VIEW_NODE, &show_router_id_cmd);
7929 + install_element(ENABLE_NODE, &show_router_id_cmd);
7930 + install_element(CONFIG_NODE, &router_id_cmd);
7931 + install_element(CONFIG_NODE, &no_router_id_cmd);
7933 + memset(&rid_all_sorted_list,0,sizeof(rid_all_sorted_list));
7934 + memset(&rid_lo_sorted_list,0,sizeof(rid_lo_sorted_list));
7935 + memset(&rid_user_assigned,0,sizeof(rid_user_assigned));
7937 + rid_all_sorted_list.cmp = router_id_cmp;
7938 + rid_lo_sorted_list.cmp = router_id_cmp;
7940 + rid_user_assigned.family = AF_INET;
7941 + rid_user_assigned.prefixlen = 32;
7943 diff --exclude=CVS -uNr zebra/zebra/router-id.h zebra-ldp/zebra/router-id.h
7944 --- zebra/zebra/router-id.h 1969-12-31 18:00:00.000000000 -0600
7945 +++ zebra-ldp/zebra/router-id.h 2003-02-26 15:49:07.000000000 -0600
7947 +#ifndef _ROUTER_ID_H_
7948 +#define _ROUTER_ID_H_
7952 +#include "memory.h"
7953 +#include "prefix.h"
7954 +#include "zclient.h"
7957 +extern void router_id_add_address(struct connected *);
7958 +extern void router_id_del_address(struct connected *);
7959 +extern void router_id_init(void);
7960 +extern void router_id_write(struct vty *);
7961 +extern void router_id_get(struct prefix *);
7963 +extern void zread_router_id_add(struct zserv *, u_short);
7964 +extern void zread_router_id_delete(struct zserv *, u_short);
7967 diff --exclude=CVS -uNr zebra/zebra/rt_netlink.c zebra-ldp/zebra/rt_netlink.c
7968 --- zebra/zebra/rt_netlink.c 2003-03-14 08:45:36.000000000 -0600
7969 +++ zebra-ldp/zebra/rt_netlink.c 2003-02-26 22:43:11.000000000 -0600
7972 char anyaddr[16] = {0};
7974 + unsigned int mplsindex;
7978 @@ -662,10 +663,14 @@
7988 + mplsindex = *(unsigned int *) RTA_DATA (tb[RTA_LSP]);
7991 index = *(int *) RTA_DATA (tb[RTA_OIF]);
7993 @@ -1208,6 +1213,10 @@
7994 || nexthop->rtype == NEXTHOP_TYPE_IPV6_IFNAME)
7995 addattr32 (&req.n, sizeof req, RTA_OIF,
7998 + if (nexthop->rmplsindex)
7999 + addattr32 (&req.n, sizeof req, RTA_LSP,
8000 + nexthop->rmplsindex);
8004 @@ -1228,6 +1237,11 @@
8005 || nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX
8006 || nexthop->type == NEXTHOP_TYPE_IPV6_IFNAME)
8007 addattr32 (&req.n, sizeof req, RTA_OIF, nexthop->ifindex);
8009 + if (nexthop->mplsindex) {
8010 +fprintf(stderr,"Adding RTA_LSP = 0x%x\n",nexthop->mplsindex);
8011 + addattr32 (&req.n, sizeof req, RTA_LSP, nexthop->mplsindex);
8015 if (cmd == RTM_NEWROUTE)
8016 @@ -1290,6 +1304,9 @@
8017 rtnh->rtnh_ifindex = nexthop->rifindex;
8019 rtnh->rtnh_ifindex = 0;
8021 + if (nexthop->rmplsindex)
8022 + rtnh->rtnh_lsp = nexthop->rmplsindex;
8026 @@ -1316,6 +1333,11 @@
8027 rtnh->rtnh_ifindex = nexthop->ifindex;
8029 rtnh->rtnh_ifindex = 0;
8031 + if (nexthop->mplsindex) {
8032 +fprintf(stderr,"Setting rtnh_lsp = 0x%x\n",nexthop->mplsindex);
8033 + rtnh->rtnh_lsp = nexthop->mplsindex;
8036 rtnh = RTNH_NEXT(rtnh);
8038 diff --exclude=CVS -uNr zebra/zebra/zebra_rib.c zebra-ldp/zebra/zebra_rib.c
8039 --- zebra/zebra/zebra_rib.c 2003-03-14 08:45:37.000000000 -0600
8040 +++ zebra-ldp/zebra/zebra_rib.c 2003-03-13 21:33:30.000000000 -0600
8043 SET_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE);
8044 nexthop->rtype = newhop->type;
8045 + nexthop->rmplsindex = newhop->mplsindex;
8046 if (newhop->type == NEXTHOP_TYPE_IPV4 ||
8047 newhop->type == NEXTHOP_TYPE_IPV4_IFINDEX)
8048 nexthop->rgate.ipv4 = newhop->gate.ipv4;
8051 SET_FLAG (nexthop->flags, NEXTHOP_FLAG_RECURSIVE);
8052 nexthop->rtype = newhop->type;
8053 + nexthop->rmplsindex = newhop->mplsindex;
8054 if (newhop->type == NEXTHOP_TYPE_IPV6
8055 || newhop->type == NEXTHOP_TYPE_IPV6_IFINDEX
8056 || newhop->type == NEXTHOP_TYPE_IPV6_IFNAME)
8058 rib->nexthop_active_num += nexthop_active_check (rn, rib, nexthop, set);
8059 if (active != CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
8060 SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED);
8062 + if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_MPLS_CHANGED))
8063 + SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED);
8065 return rib->nexthop_active_num;
8069 if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
8071 - redistribute_delete (&rn->p, rib);
8072 + if (!CHECK_FLAG (rib->flags, ZEBRA_FLAG_MPLS_CHANGED))
8073 + redistribute_delete (&rn->p, rib);
8075 if (! RIB_SYSTEM_ROUTE (rib))
8076 rib_uninstall_kernel (rn, rib);
8077 UNSET_FLAG (rib->flags, ZEBRA_FLAG_SELECTED);
8080 if (CHECK_FLAG (select->flags, ZEBRA_FLAG_CHANGED))
8082 - redistribute_delete (&rn->p, select);
8083 + if (!CHECK_FLAG (select->flags, ZEBRA_FLAG_MPLS_CHANGED))
8084 + redistribute_delete (&rn->p, select);
8086 if (! RIB_SYSTEM_ROUTE (select))
8087 rib_uninstall_kernel (rn, select);
8089 @@ -896,7 +905,11 @@
8091 if (! RIB_SYSTEM_ROUTE (select))
8092 rib_install_kernel (rn, select);
8093 - redistribute_add (&rn->p, select);
8095 + if (!CHECK_FLAG (select->flags, ZEBRA_FLAG_MPLS_CHANGED))
8096 + redistribute_add (&rn->p, select);
8098 + UNSET_FLAG (select->flags, ZEBRA_FLAG_MPLS_CHANGED);
8102 diff --exclude=CVS -uNr zebra/zebra/zebra_vty.c zebra-ldp/zebra/zebra_vty.c
8103 --- zebra/zebra/zebra_vty.c 2003-03-14 08:45:38.000000000 -0600
8104 +++ zebra-ldp/zebra/zebra_vty.c 2003-02-26 23:12:42.000000000 -0600
8105 @@ -345,6 +345,10 @@
8110 + if (nexthop->mplsindex)
8111 + vty_out (vty, " MPLS 0x%x", nexthop->mplsindex);
8113 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
8114 vty_out (vty, " inactive");
8116 @@ -356,16 +360,21 @@
8118 case NEXTHOP_TYPE_IPV4:
8119 case NEXTHOP_TYPE_IPV4_IFINDEX:
8120 - vty_out (vty, " via %s)", inet_ntoa (nexthop->rgate.ipv4));
8121 + vty_out (vty, " via %s", inet_ntoa (nexthop->rgate.ipv4));
8123 case NEXTHOP_TYPE_IFINDEX:
8124 case NEXTHOP_TYPE_IFNAME:
8125 - vty_out (vty, " is directly connected, %s)",
8126 + vty_out (vty, " is directly connected, %s",
8127 ifindex2ifname (nexthop->rifindex));
8133 + if (nexthop->rmplsindex)
8134 + vty_out (vty, " MPLS 0x%x", nexthop->rmplsindex);
8136 + vty_out (vty, ")");
8138 vty_out (vty, "%s", VTY_NEWLINE);
8140 @@ -427,6 +436,10 @@
8145 + if (nexthop->mplsindex)
8146 + vty_out (vty, " MPLS 0x%x", nexthop->mplsindex);
8148 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
8149 vty_out (vty, " inactive");
8151 @@ -438,16 +451,21 @@
8153 case NEXTHOP_TYPE_IPV4:
8154 case NEXTHOP_TYPE_IPV4_IFINDEX:
8155 - vty_out (vty, " via %s)", inet_ntoa (nexthop->rgate.ipv4));
8156 + vty_out (vty, " via %s", inet_ntoa (nexthop->rgate.ipv4));
8158 case NEXTHOP_TYPE_IFINDEX:
8159 case NEXTHOP_TYPE_IFNAME:
8160 - vty_out (vty, " is directly connected, %s)",
8161 + vty_out (vty, " is directly connected, %s",
8162 ifindex2ifname (nexthop->rifindex));
8168 + if (nexthop->rmplsindex)
8169 + vty_out (vty, " MPLS 0x%x", nexthop->rmplsindex);
8171 + vty_out (vty, ")");
8174 if (rib->type == ZEBRA_ROUTE_RIP
8175 @@ -1072,6 +1090,10 @@
8180 + if (nexthop->mplsindex)
8181 + vty_out (vty, " MPLS 0x%x", nexthop->mplsindex);
8183 if (! CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
8184 vty_out (vty, " inactive");
8186 @@ -1084,7 +1106,7 @@
8187 case NEXTHOP_TYPE_IPV6:
8188 case NEXTHOP_TYPE_IPV6_IFINDEX:
8189 case NEXTHOP_TYPE_IPV6_IFNAME:
8190 - vty_out (vty, " via %s)",
8191 + vty_out (vty, " via %s",
8192 inet_ntop (AF_INET6, &nexthop->rgate.ipv6,
8194 if (nexthop->rifindex)
8195 @@ -1092,12 +1114,17 @@
8197 case NEXTHOP_TYPE_IFINDEX:
8198 case NEXTHOP_TYPE_IFNAME:
8199 - vty_out (vty, " is directly connected, %s)",
8200 + vty_out (vty, " is directly connected, %s",
8201 ifindex2ifname (nexthop->rifindex));
8207 + if (nexthop->rmplsindex)
8208 + vty_out (vty, " MPLS 0x%x", nexthop->rmplsindex);
8210 + vty_out (vty, ")");
8212 vty_out (vty, "%s", VTY_NEWLINE);
8214 diff --exclude=CVS -uNr zebra/zebra/zserv.c zebra-ldp/zebra/zserv.c
8215 --- zebra/zebra/zserv.c 2003-03-14 08:45:39.000000000 -0600
8216 +++ zebra-ldp/zebra/zserv.c 2003-03-13 21:54:55.000000000 -0600
8218 #include "zclient.h"
8220 #include "zebra/zserv.h"
8221 +#include "zebra/router-id.h"
8222 #include "zebra/redistribute.h"
8223 #include "zebra/debug.h"
8224 #include "zebra/ipforward.h"
8226 "ZEBRA_IPV4_NEXTHOP_LOOKUP",
8227 "ZEBRA_IPV6_NEXTHOP_LOOKUP",
8228 "ZEBRA_IPV4_IMPORT_LOOKUP",
8229 - "ZEBRA_IPV6_IMPORT_LOOKUP"
8230 + "ZEBRA_IPV6_IMPORT_LOOKUP",
8231 + "ZEBRA_ROUTER_ID_ADD",
8232 + "ZEBRA_ROUTER_ID_DELETE",
8233 + "ZEBRA_ROUTER_ID_UPDATE",
8234 + "ZEBRA_IPV4_SET_MPLSINDEX"
8237 struct zebra_message_queue
8238 @@ -983,6 +988,38 @@
8242 +/* Router-id is updated. Send ZEBRA_ROUTER_ID_ADD to client. */
8244 +zsend_router_id_update (struct zserv *client, struct prefix *p)
8249 + /* Check this client need interface information. */
8250 + if (!client->ridinfo)
8256 + /* Place holder for size. */
8257 + stream_putw (s, 0);
8259 + /* Message type. */
8260 + stream_putc (s, ZEBRA_ROUTER_ID_UPDATE);
8262 + /* Prefix information. */
8263 + stream_putc (s, p->family);
8264 + blen = prefix_blen (p);
8265 + stream_put (s, &p->u.prefix, blen);
8266 + stream_putc (s, p->prefixlen);
8268 + /* Write packet size. */
8269 + stream_putw_at (s, 0, stream_get_endp (s));
8271 + return writen (client->sock, s->data, stream_get_endp (s));
8274 /* Register zebra server interface information. Send current all
8275 interface and address information. */
8277 @@ -1022,6 +1059,71 @@
8282 +zread_ipv4_set_mplsindex (struct zserv *client, u_short length)
8284 + struct prefix_ipv4 p;
8285 + struct in_addr gate;
8287 + unsigned int mplsindex;
8288 + unsigned int ifindex;
8289 + struct route_node *rn;
8291 + struct nexthop *nexthop;
8292 + struct route_table *table;
8294 + /* Get input stream. */
8297 + /* IPv4 prefix. */
8298 + memset (&p, 0, sizeof (struct prefix_ipv4));
8299 + p.family = AF_INET;
8300 + p.prefixlen = stream_getc (s);
8301 + stream_get (&p.prefix, s, PSIZE (p.prefixlen));
8303 + /* Nexthop info */
8304 + gate.s_addr = stream_get_ipv4 (s);
8305 + ifindex = stream_getl (s);
8307 + /* the MPLS index */
8308 + mplsindex = stream_getl (s);
8310 + apply_mask_ipv4 (&p);
8312 + /* Lookup table. */
8313 + table = vrf_table (AFI_IP, SAFI_UNICAST, 0);
8317 + rn = route_node_get (table, (struct prefix *)&p);
8321 + for (rib = rn->info; rib; rib = rib->next)
8323 + if (!CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED))
8328 + for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
8330 + if (!CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
8334 + if (nexthop->ifindex == ifindex
8335 + && nexthop->gate.ipv4.s_addr == gate.s_addr)
8337 + SET_FLAG (rib->flags, ZEBRA_FLAG_MPLS_CHANGED);
8338 + nexthop->mplsindex = mplsindex;
8343 + rib_process (rn, NULL);
8346 /* This function support multiple nexthop. */
8348 zread_ipv4_add (struct zserv *client, u_short length)
8349 @@ -1113,7 +1215,7 @@
8351 u_char nexthop_type;
8358 @@ -1207,7 +1309,7 @@
8359 struct in6_addr nexthop;
8360 unsigned long ifindex;
8361 struct prefix_ipv6 p;
8366 memset (&nexthop, 0, sizeof (struct in6_addr));
8367 @@ -1271,7 +1373,7 @@
8368 struct in6_addr nexthop;
8369 unsigned long ifindex;
8370 struct prefix_ipv6 p;
8375 memset (&nexthop, 0, sizeof (struct in6_addr));
8376 @@ -1379,6 +1481,27 @@
8378 #endif /* HAVE_IPV6 */
8380 +/* Register zebra server router-id information. Send current router-id */
8382 +zread_router_id_add (struct zserv *client, u_short length)
8386 + /* Router-id information is needed. */
8387 + client->ridinfo = 1;
8389 + router_id_get (&p);
8391 + zsend_router_id_update (client,&p);
8394 +/* Unregister zebra server router-id information. */
8396 +zread_router_id_delete (struct zserv *client, u_short length)
8398 + client->ridinfo = 0;
8401 /* Close zebra client. */
8403 zebra_client_close (struct zserv *client)
8404 @@ -1490,6 +1613,15 @@
8408 + case ZEBRA_IPV4_SET_MPLSINDEX:
8409 + zread_ipv4_set_mplsindex (client, length);
8411 + case ZEBRA_ROUTER_ID_ADD:
8412 + zread_router_id_add (client, length);
8414 + case ZEBRA_ROUTER_ID_DELETE:
8415 + zread_router_id_delete (client, length);
8417 case ZEBRA_INTERFACE_ADD:
8418 zread_interface_add (client, length);
8420 diff --exclude=CVS -uNr zebra/zebra/zserv.h zebra-ldp/zebra/zserv.h
8421 --- zebra/zebra/zserv.h 2003-03-14 08:45:39.000000000 -0600
8422 +++ zebra-ldp/zebra/zserv.h 2003-02-26 15:49:12.000000000 -0600
8425 /* Interface information. */
8428 + /* Router-id information. */
8432 /* Count prefix size from mask length */
8435 #endif /* HAVE_IPV6 */
8438 +zsend_router_id_update(struct zserv *, struct prefix *);
8441 extern pid_t old_pid;