GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.sbin/dvmrpd/graft.c Lines: 0 21 0.0 %
Date: 2017-11-07 Branches: 0 6 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: graft.c,v 1.5 2015/12/07 19:17:18 mmcc Exp $ */
2
3
/*
4
 * Copyright (c) 2005, 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 graft packet handling */
34
int
35
send_graft(struct iface *iface, struct in_addr addr, void *data, int len)
36
{
37
	struct sockaddr_in	 dst;
38
	struct ibuf		*buf;
39
	struct dvmrp_hdr	*dvmrp_hdr;
40
	int			 ret = 0;
41
42
	log_debug("send_graft: interface %s addr %s",
43
	    iface->name, inet_ntoa(addr));
44
45
	if (iface->passive)
46
		return (0);
47
48
	if ((buf = ibuf_open(iface->mtu - sizeof(struct ip))) == NULL)
49
		fatal("send_graft");
50
51
	/* DVMRP header */
52
	if (gen_dvmrp_hdr(buf, iface, DVMRP_CODE_GRAFT))
53
		goto fail;
54
55
	dst.sin_family = AF_INET;
56
	dst.sin_len = sizeof(struct sockaddr_in);
57
	dst.sin_addr.s_addr = addr.s_addr;
58
59
	/* update chksum */
60
	dvmrp_hdr = ibuf_seek(buf, 0, sizeof(*dvmrp_hdr));
61
	dvmrp_hdr->chksum = in_cksum(buf->buf, buf->wpos);
62
63
	ret = send_packet(iface, buf->buf, buf->wpos, &dst);
64
	ibuf_free(buf);
65
	return (ret);
66
fail:
67
	log_warn("send_graft");
68
	ibuf_free(buf);
69
	return (-1);
70
}
71
72
void
73
recv_graft(struct nbr *nbr, char *buf, u_int16_t len)
74
{
75
	log_debug("recv_graft: neighbor ID %s", inet_ntoa(nbr->id));
76
77
	return;
78
}