1 /* $OpenBSD: ask_nbrs2.c,v 1.6 2023/06/26 10:08:56 claudio Exp $ */ 2 3 /* 4 * Copyright (c) 2006 Esben Norby <norby@openbsd.org> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #include <sys/types.h> 20 #include <sys/socket.h> 21 #include <netinet/in.h> 22 #include <netinet/ip.h> 23 #include <arpa/inet.h> 24 25 #include <stdlib.h> 26 27 #include "igmp.h" 28 #include "dvmrpd.h" 29 #include "dvmrp.h" 30 #include "log.h" 31 #include "dvmrpe.h" 32 33 /* DVMRP ask neighbors2 packet handling */ 34 int 35 send_ask_nbrs2(struct iface *iface, struct in_addr addr, void *data, int len) 36 { 37 struct sockaddr_in dst; 38 struct ibuf *buf; 39 int ret = 0; 40 41 log_debug("send_ask_nbrs2: interface %s addr %s", 42 iface->name, inet_ntoa(addr)); 43 44 if (iface->passive) 45 return (0); 46 47 if ((buf = ibuf_open(iface->mtu - sizeof(struct ip))) == NULL) 48 fatal("send_ask_nbrs2"); 49 50 /* DVMRP header */ 51 if (gen_dvmrp_hdr(buf, iface, DVMRP_CODE_GRAFT_ACK)) 52 goto fail; 53 54 dst.sin_family = AF_INET; 55 dst.sin_len = sizeof(struct sockaddr_in); 56 dst.sin_addr.s_addr = addr.s_addr; 57 58 ret = send_packet(iface, buf, &dst); 59 ibuf_free(buf); 60 return (ret); 61 fail: 62 log_warn("send_ask_nbrs2"); 63 ibuf_free(buf); 64 return (-1); 65 } 66 67 void 68 recv_ask_nbrs2(struct nbr *nbr, char *buf, u_int16_t len) 69 { 70 log_debug("recv_ask_nbrs2: neighbor ID %s", inet_ntoa(nbr->id)); 71 72 return; 73 } 74