diff options
Diffstat (limited to 'usr.sbin/ospfd')
-rw-r--r-- | usr.sbin/ospfd/config.c | 3 | ||||
-rw-r--r-- | usr.sbin/ospfd/interface.c | 37 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospfd/packet.c | 8 |
4 files changed, 38 insertions, 13 deletions
diff --git a/usr.sbin/ospfd/config.c b/usr.sbin/ospfd/config.c index 0b9e17b7d6b..a24a65f6eda 100644 --- a/usr.sbin/ospfd/config.c +++ b/usr.sbin/ospfd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.2 2005/01/28 17:53:33 norby Exp $ */ +/* $OpenBSD: config.c,v 1.3 2005/02/16 15:23:33 norby Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -88,6 +88,7 @@ show_interface(struct iface *iface) log_debug(" state: %s", if_state_name(iface->state)); log_debug(" address: %s", inet_ntoa(iface->addr)); log_debug(" mask: %s", inet_ntoa(iface->mask)); + log_debug(" dst: %s", inet_ntoa(iface->dst)); log_debug(" area: %s", inet_ntoa(iface->area->id)); log_debug(" hello interval: %d", iface->hello_interval); log_debug(" dead interval: %d", iface->dead_interval); diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c index b57d6bf49f9..0e2c29c7358 100644 --- a/usr.sbin/ospfd/interface.c +++ b/usr.sbin/ospfd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.8 2005/02/09 20:40:23 claudio Exp $ */ +/* $OpenBSD: interface.c,v 1.9 2005/02/16 15:23:33 norby Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -92,9 +92,9 @@ const char * const if_auth_names[] = { int if_fsm(struct iface *iface, enum iface_event event) { - int old_state; - int new_state = 0; - int i, ret = 0; + int old_state; + int new_state = 0; + int i, ret = 0; old_state = iface->state; @@ -202,6 +202,14 @@ if_new(char *name, unsigned int idx) sain = (struct sockaddr_in *) &ifr->ifr_addr; iface->mask = sain->sin_addr; + /* get p2p dst address */ + if (iface->type == IF_TYPE_POINTOPOINT) { + if (ioctl(s, SIOCGIFDSTADDR, (caddr_t)ifr) < 0) + errx(1, "if_new: cannot get dst addr"); + sain = (struct sockaddr_in *) &ifr->ifr_addr; + iface->dst = sain->sin_addr; + } + /* get mtu */ if (ioctl(s, SIOCGIFMTU, (caddr_t)ifr) < 0) errx(1, "if_new: cannot get mtu"); @@ -267,6 +275,7 @@ if_init(struct ospfd_conf *xconf) LIST_FOREACH(iface, &area->iface_list, entry) { switch (iface->type) { case IF_TYPE_POINTOPOINT: + iface->fd = xconf->ospf_socket; break; case IF_TYPE_BROADCAST: /* all bcast interfaces use the same socket */ @@ -373,6 +382,17 @@ if_act_start(struct iface *iface) switch (iface->type) { case IF_TYPE_POINTOPOINT: + inet_aton(AllSPFRouters, &addr); + if (if_join_group(iface, &addr)) { + log_warnx("if_act_start: error joining group %s, " + "interface %s", inet_ntoa(addr), iface->name); + return (-1); + } + iface->state = IF_STA_POINTTOPOINT; + if (if_start_hello_timer(iface)) + log_warnx("if_act_start: cannot schedule hello " + "timer, interface %s", iface->name); + break; case IF_TYPE_POINTOMULTIPOINT: case IF_TYPE_VIRTUALLINK: case IF_TYPE_NBMA: @@ -556,9 +576,6 @@ if_act_reset(struct iface *iface) switch (iface->type) { case IF_TYPE_POINTOPOINT: - log_debug("if_act_reset: type %s not supported, interface %s", - if_type_name(iface->type), iface->name); - return (-1); case IF_TYPE_BROADCAST: inet_aton(AllSPFRouters, &addr); if (if_leave_group(iface, &addr)) { @@ -736,6 +753,7 @@ if_join_group(struct iface *iface, struct in_addr *addr) struct ip_mreq mreq; switch (iface->type) { + case IF_TYPE_POINTOPOINT: case IF_TYPE_BROADCAST: mreq.imr_multiaddr.s_addr = addr->s_addr; mreq.imr_interface.s_addr = iface->addr.s_addr; @@ -747,7 +765,6 @@ if_join_group(struct iface *iface, struct in_addr *addr) return (-1); } break; - case IF_TYPE_POINTOPOINT: case IF_TYPE_POINTOMULTIPOINT: case IF_TYPE_VIRTUALLINK: case IF_TYPE_NBMA: @@ -767,6 +784,7 @@ if_leave_group(struct iface *iface, struct in_addr *addr) struct ip_mreq mreq; switch (iface->type) { + case IF_TYPE_POINTOPOINT: case IF_TYPE_BROADCAST: mreq.imr_multiaddr.s_addr = addr->s_addr; mreq.imr_interface.s_addr = iface->addr.s_addr; @@ -778,7 +796,6 @@ if_leave_group(struct iface *iface, struct in_addr *addr) return (-1); } break; - case IF_TYPE_POINTOPOINT: case IF_TYPE_POINTOMULTIPOINT: case IF_TYPE_VIRTUALLINK: case IF_TYPE_NBMA: @@ -796,6 +813,7 @@ int if_set_mcast(struct iface *iface) { switch (iface->type) { + case IF_TYPE_POINTOPOINT: case IF_TYPE_BROADCAST: if (setsockopt(iface->fd, IPPROTO_IP, IP_MULTICAST_IF, (char *)&iface->addr.s_addr, @@ -805,7 +823,6 @@ if_set_mcast(struct iface *iface) return (-1); } break; - case IF_TYPE_POINTOPOINT: case IF_TYPE_POINTOMULTIPOINT: case IF_TYPE_VIRTUALLINK: case IF_TYPE_NBMA: diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index f47a5cf22ac..6f6837dc028 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.8 2005/02/10 14:05:48 claudio Exp $ */ +/* $OpenBSD: ospfd.h,v 1.9 2005/02/16 15:23:33 norby Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -233,6 +233,7 @@ struct iface { char name[IF_NAMESIZE]; struct in_addr addr; + struct in_addr dst; struct in_addr mask; struct in_addr rtr_id; char *auth_key; diff --git a/usr.sbin/ospfd/packet.c b/usr.sbin/ospfd/packet.c index c192bf36740..30b3be1a165 100644 --- a/usr.sbin/ospfd/packet.c +++ b/usr.sbin/ospfd/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.4 2005/02/07 05:51:00 david Exp $ */ +/* $OpenBSD: packet.c,v 1.5 2005/02/16 15:23:33 norby Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -277,6 +277,12 @@ find_iface(struct ospfd_conf *xconf, struct in_addr src) /* returned interface needs to be active */ LIST_FOREACH(area, &xconf->area_list, entry) { LIST_FOREACH(iface, &area->iface_list, entry) { + if (iface->fd > 0 && + (iface->type == IF_TYPE_POINTOPOINT) && + (iface->dst.s_addr == src.s_addr) && + !iface->passive) + return (iface); + if (iface->fd > 0 && (iface->addr.s_addr & iface->mask.s_addr) == (src.s_addr & iface->mask.s_addr) && !iface->passive) |