Annotation of embedaddon/libnet/src/libnet_build_link.c, revision 1.1.1.3
1.1 misho 1: /*
1.1.1.2 misho 2: * $Id: libnet_build_link.c,v 1.10 2004/04/13 17:32:28 mike Exp $
1.1 misho 3: *
4: * libnet
5: * libnet_build_link.c - link-layer packet assembler
6: *
7: * Copyright (c) 2003 Roberto Larcher <roberto.larcher@libero.it>
8: * Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
9: * All rights reserved.
10: *
11: * Redistribution and use in source and binary forms, with or without
12: * modification, are permitted provided that the following conditions
13: * are met:
14: * 1. Redistributions of source code must retain the above copyright
15: * notice, this list of conditions and the following disclaimer.
16: * 2. Redistributions in binary form must reproduce the above copyright
17: * notice, this list of conditions and the following disclaimer in the
18: * documentation and/or other materials provided with the distribution.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: * SUCH DAMAGE.
31: *
32: */
33:
1.1.1.3 ! misho 34: #include "common.h"
1.1 misho 35:
36: libnet_ptag_t
1.1.1.2 misho 37: libnet_build_link(const uint8_t *dst, const uint8_t *src, const uint8_t *oui, uint16_t type,
38: const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
1.1 misho 39:
40: {
1.1.1.2 misho 41: uint8_t org[3] = {0x00, 0x00, 0x00};
1.1 misho 42: switch (l->link_type)
43: {
44: /* add FDDI */
45: case DLT_EN10MB:
1.1.1.2 misho 46: return libnet_build_ethernet(dst, src, type, payload, payload_s, l,
47: ptag);
1.1 misho 48: case DLT_IEEE802:
1.1.1.2 misho 49: return libnet_build_token_ring(LIBNET_TOKEN_RING_FRAME,
1.1 misho 50: LIBNET_TOKEN_RING_LLC_FRAME, dst, src, LIBNET_SAP_SNAP,
51: LIBNET_SAP_SNAP, 0x03, org, type, payload, payload_s,
1.1.1.2 misho 52: l, ptag);
1.1 misho 53: }
54: snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
1.1.1.3 ! misho 55: "%s(): linktype %d not supported", __func__, l->link_type);
1.1.1.2 misho 56: return -1;
1.1 misho 57: }
58:
59: libnet_ptag_t
1.1.1.2 misho 60: libnet_autobuild_link(const uint8_t *dst, const uint8_t *oui, uint16_t type, libnet_t *l)
1.1 misho 61: {
1.1.1.2 misho 62: uint8_t org[3] = {0x00, 0x00, 0x00};
1.1 misho 63: switch (l->link_type)
64: {
65: /* add FDDI */
66: case DLT_EN10MB:
67: return (libnet_autobuild_ethernet(dst, type, l));
68: case DLT_IEEE802:
69: return (libnet_autobuild_token_ring(LIBNET_TOKEN_RING_FRAME,
70: LIBNET_TOKEN_RING_LLC_FRAME, dst, LIBNET_SAP_SNAP,
71: LIBNET_SAP_SNAP, 0x03, org, TOKEN_RING_TYPE_IP, l));
72: }
73: snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
1.1.1.3 ! misho 74: "%s(): linktype %d not supported", __func__, l->link_type);
1.1 misho 75: return (-1);
76: }
77:
1.1.1.3 ! misho 78: /**
! 79: * Local Variables:
! 80: * indent-tabs-mode: nil
! 81: * c-file-style: "stroustrup"
! 82: * End:
! 83: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>