diff options
-rw-r--r-- | usr.sbin/ospf6d/database.c | 14 | ||||
-rw-r--r-- | usr.sbin/ospf6d/hello.c | 11 | ||||
-rw-r--r-- | usr.sbin/ospf6d/lsack.c | 13 | ||||
-rw-r--r-- | usr.sbin/ospf6d/lsreq.c | 14 | ||||
-rw-r--r-- | usr.sbin/ospf6d/lsupdate.c | 10 | ||||
-rw-r--r-- | usr.sbin/ospf6d/ospfe.h | 4 | ||||
-rw-r--r-- | usr.sbin/ospf6d/packet.c | 31 |
7 files changed, 38 insertions, 59 deletions
diff --git a/usr.sbin/ospf6d/database.c b/usr.sbin/ospf6d/database.c index 955bc469b40..6eeb4d467ca 100644 --- a/usr.sbin/ospf6d/database.c +++ b/usr.sbin/ospf6d/database.c @@ -1,4 +1,4 @@ -/* $OpenBSD: database.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */ +/* $OpenBSD: database.c,v 1.2 2007/10/10 14:09:25 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -40,7 +40,7 @@ void db_sum_list_next(struct nbr *); int send_db_description(struct nbr *nbr) { - struct sockaddr_in6 dst; + struct in6_addr dst; struct db_dscrp_hdr dd_hdr; struct lsa_entry *le, *nle; struct buf *buf; @@ -113,17 +113,13 @@ send_db_description(struct nbr *nbr) fatalx("send_db_description: unknown neighbor state"); } - /* set destination */ - dst.sin6_family = AF_INET6; - dst.sin6_len = sizeof(struct sockaddr_in6); - switch (nbr->iface->type) { case IF_TYPE_POINTOPOINT: - inet_pton(AF_INET6, AllSPFRouters, &dst.sin6_addr); + inet_pton(AF_INET6, AllSPFRouters, &dst); dd_hdr.iface_mtu = htons(nbr->iface->mtu); break; case IF_TYPE_BROADCAST: - dst.sin6_addr = nbr->addr; + dst = nbr->addr; dd_hdr.iface_mtu = htons(nbr->iface->mtu); break; case IF_TYPE_NBMA: @@ -131,7 +127,7 @@ send_db_description(struct nbr *nbr) /* XXX not supported */ break; case IF_TYPE_VIRTUALLINK: - dst.sin6_addr = nbr->iface->dst; + dst = nbr->iface->dst; dd_hdr.iface_mtu = 0; break; default: diff --git a/usr.sbin/ospf6d/hello.c b/usr.sbin/ospf6d/hello.c index 43ba7410c18..26e93bd596a 100644 --- a/usr.sbin/ospf6d/hello.c +++ b/usr.sbin/ospf6d/hello.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hello.c,v 1.3 2007/10/10 13:36:01 claudio Exp $ */ +/* $OpenBSD: hello.c,v 1.4 2007/10/10 14:09:25 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -38,19 +38,16 @@ extern struct ospfd_conf *oeconf; int send_hello(struct iface *iface) { - struct sockaddr_in6 dst; + struct in6_addr dst; struct hello_hdr hello; struct nbr *nbr; struct buf *buf; int ret; - dst.sin6_family = AF_INET6; - dst.sin6_len = sizeof(struct sockaddr_in6); - switch (iface->type) { case IF_TYPE_POINTOPOINT: case IF_TYPE_BROADCAST: - inet_pton(AF_INET6, AllSPFRouters, &dst.sin6_addr); + inet_pton(AF_INET6, AllSPFRouters, &dst); break; case IF_TYPE_NBMA: case IF_TYPE_POINTOMULTIPOINT: @@ -58,7 +55,7 @@ send_hello(struct iface *iface) if_type_name(iface->type), iface->name); return (-1); case IF_TYPE_VIRTUALLINK: - dst.sin6_addr = iface->dst; + dst = iface->dst; break; default: fatalx("send_hello: unknown interface type"); diff --git a/usr.sbin/ospf6d/lsack.c b/usr.sbin/ospf6d/lsack.c index 945d34467b5..781dfcfeac6 100644 --- a/usr.sbin/ospf6d/lsack.c +++ b/usr.sbin/ospf6d/lsack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lsack.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */ +/* $OpenBSD: lsack.c,v 1.2 2007/10/10 14:09:25 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org> @@ -37,18 +37,13 @@ void start_ls_ack_tx_timer_now(struct iface *); int send_ls_ack(struct iface *iface, struct in6_addr addr, void *data, size_t len) { - struct sockaddr_in6 dst; - struct buf *buf; - int ret; + struct buf *buf; + int ret; /* XXX READ_BUF_SIZE */ if ((buf = buf_dynamic(PKG_DEF_SIZE, READ_BUF_SIZE)) == NULL) fatal("send_ls_ack"); - dst.sin6_family = AF_INET6; - dst.sin6_len = sizeof(struct sockaddr_in6); - dst.sin6_addr = addr; /* XXX */ - /* OSPF header */ if (gen_ospf_hdr(buf, iface, PACKET_TYPE_LS_ACK)) goto fail; @@ -61,7 +56,7 @@ send_ls_ack(struct iface *iface, struct in6_addr addr, void *data, size_t len) if (upd_ospf_hdr(buf, iface)) goto fail; - ret = send_packet(iface, buf->buf, buf->wpos, &dst); + ret = send_packet(iface, buf->buf, buf->wpos, &addr); buf_free(buf); return (ret); diff --git a/usr.sbin/ospf6d/lsreq.c b/usr.sbin/ospf6d/lsreq.c index 76c92129b65..40ea4d25511 100644 --- a/usr.sbin/ospf6d/lsreq.c +++ b/usr.sbin/ospf6d/lsreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lsreq.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */ +/* $OpenBSD: lsreq.c,v 1.2 2007/10/10 14:09:25 claudio Exp $ */ /* * Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org> @@ -33,7 +33,7 @@ extern struct imsgbuf *ibuf_rde; int send_ls_req(struct nbr *nbr) { - struct sockaddr_in6 dst; + struct in6_addr dst; struct ls_req_hdr ls_req_hdr; struct lsa_entry *le, *nle; struct buf *buf; @@ -42,21 +42,15 @@ send_ls_req(struct nbr *nbr) if ((buf = buf_open(nbr->iface->mtu - sizeof(struct ip))) == NULL) fatal("send_ls_req"); - /* set destination */ - dst.sin6_family = AF_INET6; - dst.sin6_len = sizeof(struct sockaddr_in6); - switch (nbr->iface->type) { case IF_TYPE_POINTOPOINT: -//XXX inet_aton(AllSPFRouters, &dst.sin_addr); - inet_pton(AF_INET6, AllSPFRouters, &dst.sin6_addr); + inet_pton(AF_INET6, AllSPFRouters, &dst); break; case IF_TYPE_BROADCAST: case IF_TYPE_NBMA: case IF_TYPE_POINTOMULTIPOINT: case IF_TYPE_VIRTUALLINK: -//XXX dst.sin_addr.s_addr = nbr->addr.s_addr; - dst.sin6_addr = nbr->addr; + dst = nbr->addr; break; default: fatalx("send_ls_req: unknown interface type"); diff --git a/usr.sbin/ospf6d/lsupdate.c b/usr.sbin/ospf6d/lsupdate.c index 9dcca18409a..a0bf916e74c 100644 --- a/usr.sbin/ospf6d/lsupdate.c +++ b/usr.sbin/ospf6d/lsupdate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lsupdate.c,v 1.1 2007/10/08 10:44:50 norby Exp $ */ +/* $OpenBSD: lsupdate.c,v 1.2 2007/10/10 14:09:25 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -200,7 +200,6 @@ int send_ls_update(struct buf *buf, struct iface *iface, struct in6_addr addr, u_int32_t nlsa) { - struct sockaddr_in6 dst; int ret; nlsa = htonl(nlsa); @@ -210,12 +209,7 @@ send_ls_update(struct buf *buf, struct iface *iface, struct in6_addr addr, if (upd_ospf_hdr(buf, iface)) goto fail; - /* set destination */ - dst.sin6_family = AF_INET6; - dst.sin6_len = sizeof(struct sockaddr_in6); - dst.sin6_addr = addr; - - ret = send_packet(iface, buf->buf, buf->wpos, &dst); + ret = send_packet(iface, buf->buf, buf->wpos, &addr); buf_free(buf); return (ret); diff --git a/usr.sbin/ospf6d/ospfe.h b/usr.sbin/ospf6d/ospfe.h index 903d982f17c..5b8ba269187 100644 --- a/usr.sbin/ospf6d/ospfe.h +++ b/usr.sbin/ospf6d/ospfe.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.h,v 1.3 2007/10/09 06:26:47 claudio Exp $ */ +/* $OpenBSD: ospfe.h,v 1.4 2007/10/10 14:09:25 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -225,7 +225,7 @@ struct lsa_hdr *lsa_hdr_new(void); /* packet.c */ int gen_ospf_hdr(struct buf *, struct iface *, u_int8_t); int upd_ospf_hdr(struct buf *, struct iface *); -int send_packet(struct iface *, void *, size_t, struct sockaddr_in6 *); +int send_packet(struct iface *, void *, size_t, struct in6_addr *); void recv_packet(int, short, void *); char *pkt_ptr; /* packet buffer */ diff --git a/usr.sbin/ospf6d/packet.c b/usr.sbin/ospf6d/packet.c index a872050f665..da471d98a70 100644 --- a/usr.sbin/ospf6d/packet.c +++ b/usr.sbin/ospf6d/packet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: packet.c,v 1.2 2007/10/09 06:26:47 claudio Exp $ */ +/* $OpenBSD: packet.c,v 1.3 2007/10/10 14:09:25 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -80,21 +80,23 @@ upd_ospf_hdr(struct buf *buf, struct iface *iface) /* send and receive packets */ int send_packet(struct iface *iface, void *pkt, size_t len, - struct sockaddr_in6 *dst) + struct in6_addr *dst) { - struct msghdr msg; - struct iovec iov[1]; + struct sockaddr_in6 sa6; + /* setup buffer */ - bzero(&msg, sizeof(msg)); - iov[0].iov_base = pkt; - iov[0].iov_len = len; - msg.msg_name = dst; - msg.msg_namelen = sizeof(*dst); - msg.msg_iov = iov; - msg.msg_iovlen = 1; + bzero(&sa6, sizeof(sa6)); + + sa6.sin6_family = AF_INET6; + sa6.sin6_len = sizeof(sa6); + sa6.sin6_addr = *dst; + + /* don't we all love link local scope and all the needed hacks for it */ + if (IN6_IS_ADDR_LINKLOCAL(dst) || IN6_IS_ADDR_MC_LINKLOCAL(dst)) + sa6.sin6_scope_id = iface->ifindex; /* set outgoing interface for multicast traffic */ - if (IN6_IS_ADDR_MULTICAST(&dst->sin6_addr)) + if (IN6_IS_ADDR_MULTICAST(dst)) if (if_set_mcast(iface) == -1) { log_warn("send_packet: error setting multicast " "interface, %s", iface->name); @@ -102,8 +104,9 @@ send_packet(struct iface *iface, void *pkt, size_t len, } log_debug("send_packet: iface %d addr %s dest %s", iface->ifindex, - log_in6addr(&iface->addr), log_in6addr(&dst->sin6_addr)); - if (sendmsg(iface->fd, &msg, MSG_DONTROUTE) == -1) { + log_in6addr(&iface->addr), log_sockaddr((void *)&sa6)); + if (sendto(iface->fd, pkt, len, MSG_DONTROUTE, (struct sockaddr *)&sa6, + sizeof(sa6)) == -1) { log_warn("send_packet: error sending packet on interface %s", iface->name); return (-1); |