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