1*83ee113eSDavid van Moolenbroek /* $NetBSD: fddi.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $ */
2*83ee113eSDavid van Moolenbroek /* fddi.c
3*83ee113eSDavid van Moolenbroek
4*83ee113eSDavid van Moolenbroek Packet assembly code, originally contributed by Archie Cobbs. */
5*83ee113eSDavid van Moolenbroek
6*83ee113eSDavid van Moolenbroek /*
7*83ee113eSDavid van Moolenbroek * Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
8*83ee113eSDavid van Moolenbroek * Copyright (c) 1996-2003 by Internet Software Consortium
9*83ee113eSDavid van Moolenbroek *
10*83ee113eSDavid van Moolenbroek * Permission to use, copy, modify, and distribute this software for any
11*83ee113eSDavid van Moolenbroek * purpose with or without fee is hereby granted, provided that the above
12*83ee113eSDavid van Moolenbroek * copyright notice and this permission notice appear in all copies.
13*83ee113eSDavid van Moolenbroek *
14*83ee113eSDavid van Moolenbroek * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15*83ee113eSDavid van Moolenbroek * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16*83ee113eSDavid van Moolenbroek * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17*83ee113eSDavid van Moolenbroek * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18*83ee113eSDavid van Moolenbroek * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19*83ee113eSDavid van Moolenbroek * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20*83ee113eSDavid van Moolenbroek * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21*83ee113eSDavid van Moolenbroek *
22*83ee113eSDavid van Moolenbroek * Internet Systems Consortium, Inc.
23*83ee113eSDavid van Moolenbroek * 950 Charter Street
24*83ee113eSDavid van Moolenbroek * Redwood City, CA 94063
25*83ee113eSDavid van Moolenbroek * <info@isc.org>
26*83ee113eSDavid van Moolenbroek * https://www.isc.org/
27*83ee113eSDavid van Moolenbroek *
28*83ee113eSDavid van Moolenbroek */
29*83ee113eSDavid van Moolenbroek
30*83ee113eSDavid van Moolenbroek #include <sys/cdefs.h>
31*83ee113eSDavid van Moolenbroek __RCSID("$NetBSD: fddi.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $");
32*83ee113eSDavid van Moolenbroek
33*83ee113eSDavid van Moolenbroek #include "dhcpd.h"
34*83ee113eSDavid van Moolenbroek
35*83ee113eSDavid van Moolenbroek #if defined (DEC_FDDI)
36*83ee113eSDavid van Moolenbroek #include <netinet/if_fddi.h>
37*83ee113eSDavid van Moolenbroek #include <net/if_llc.h>
38*83ee113eSDavid van Moolenbroek
39*83ee113eSDavid van Moolenbroek #if defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING)
40*83ee113eSDavid van Moolenbroek #include "includes/netinet/if_ether.h"
41*83ee113eSDavid van Moolenbroek #endif /* PACKET_ASSEMBLY || PACKET_DECODING */
42*83ee113eSDavid van Moolenbroek
43*83ee113eSDavid van Moolenbroek #if defined (PACKET_ASSEMBLY)
44*83ee113eSDavid van Moolenbroek /* Assemble an hardware header... */
45*83ee113eSDavid van Moolenbroek
assemble_fddi_header(interface,buf,bufix,to)46*83ee113eSDavid van Moolenbroek void assemble_fddi_header (interface, buf, bufix, to)
47*83ee113eSDavid van Moolenbroek struct interface_info *interface;
48*83ee113eSDavid van Moolenbroek unsigned char *buf;
49*83ee113eSDavid van Moolenbroek unsigned *bufix;
50*83ee113eSDavid van Moolenbroek struct hardware *to;
51*83ee113eSDavid van Moolenbroek {
52*83ee113eSDavid van Moolenbroek struct fddi_header fh;
53*83ee113eSDavid van Moolenbroek struct llc lh;
54*83ee113eSDavid van Moolenbroek
55*83ee113eSDavid van Moolenbroek if (to && to -> hlen == 7)
56*83ee113eSDavid van Moolenbroek memcpy (fh.fddi_dhost, &to -> hbuf [1],
57*83ee113eSDavid van Moolenbroek sizeof (fh.fddi_dhost));
58*83ee113eSDavid van Moolenbroek memcpy (fh.fddi_shost,
59*83ee113eSDavid van Moolenbroek &interface -> hw_address.hbuf [1], sizeof (fh.fddi_shost));
60*83ee113eSDavid van Moolenbroek fh.fddi_fc = FDDIFC_LLC_ASYNC;
61*83ee113eSDavid van Moolenbroek memcpy (&buf [*bufix], &fh, sizeof fh);
62*83ee113eSDavid van Moolenbroek *bufix += sizeof fh;
63*83ee113eSDavid van Moolenbroek
64*83ee113eSDavid van Moolenbroek lh.llc_dsap = LLC_SNAP_LSAP;
65*83ee113eSDavid van Moolenbroek lh.llc_ssap = LLC_SNAP_LSAP;
66*83ee113eSDavid van Moolenbroek lh.llc_un.type_snap.control = LLC_UI;
67*83ee113eSDavid van Moolenbroek lh.llc_un.type_snap.ether_type = htons (ETHERTYPE_IP);
68*83ee113eSDavid van Moolenbroek memcpy (&buf [*bufix], &lh, LLC_SNAP_LEN);
69*83ee113eSDavid van Moolenbroek *bufix += LLC_SNAP_LEN;
70*83ee113eSDavid van Moolenbroek }
71*83ee113eSDavid van Moolenbroek #endif /* PACKET_ASSEMBLY */
72*83ee113eSDavid van Moolenbroek
73*83ee113eSDavid van Moolenbroek #ifdef PACKET_DECODING
74*83ee113eSDavid van Moolenbroek /* Decode a hardware header... */
75*83ee113eSDavid van Moolenbroek
decode_fddi_header(interface,buf,bufix,from)76*83ee113eSDavid van Moolenbroek ssize_t decode_fddi_header (interface, buf, bufix, from)
77*83ee113eSDavid van Moolenbroek struct interface_info *interface;
78*83ee113eSDavid van Moolenbroek unsigned char *buf;
79*83ee113eSDavid van Moolenbroek unsigned bufix;
80*83ee113eSDavid van Moolenbroek struct hardware *from;
81*83ee113eSDavid van Moolenbroek {
82*83ee113eSDavid van Moolenbroek struct fddi_header fh;
83*83ee113eSDavid van Moolenbroek struct llc lh;
84*83ee113eSDavid van Moolenbroek
85*83ee113eSDavid van Moolenbroek from -> hbuf [0] = HTYPE_FDDI;
86*83ee113eSDavid van Moolenbroek memcpy (&from -> hbuf [1], fh.fddi_shost, sizeof fh.fddi_shost);
87*83ee113eSDavid van Moolenbroek return FDDI_HEADER_SIZE + LLC_SNAP_LEN;
88*83ee113eSDavid van Moolenbroek }
89*83ee113eSDavid van Moolenbroek #endif /* PACKET_DECODING */
90*83ee113eSDavid van Moolenbroek #endif /* DEC_FDDI */
91