common/fddi.c

Go to the documentation of this file.
00001 /* fddi.c
00002 
00003    Packet assembly code, originally contributed by Archie Cobbs. */
00004 
00005 /*
00006  * Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
00007  * Copyright (c) 1996-2003 by Internet Software Consortium
00008  *
00009  * Permission to use, copy, modify, and distribute this software for any
00010  * purpose with or without fee is hereby granted, provided that the above
00011  * copyright notice and this permission notice appear in all copies.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
00014  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00015  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
00016  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00017  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00018  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
00019  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00020  *
00021  *   Internet Systems Consortium, Inc.
00022  *   950 Charter Street
00023  *   Redwood City, CA 94063
00024  *   <info@isc.org>
00025  *   https://www.isc.org/
00026  *
00027  */
00028 
00029 #include "dhcpd.h"
00030 
00031 #if defined (DEC_FDDI)
00032 #include <netinet/if_fddi.h>
00033 #include <net/if_llc.h>
00034 
00035 #if defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING)
00036 #include "includes/netinet/if_ether.h"
00037 #endif /* PACKET_ASSEMBLY || PACKET_DECODING */
00038 
00039 #if defined (PACKET_ASSEMBLY)
00040 /* Assemble an hardware header... */
00041 
00042 void assemble_fddi_header (interface, buf, bufix, to)
00043         struct interface_info *interface;
00044         unsigned char *buf;
00045         unsigned *bufix;
00046         struct hardware *to;
00047 {
00048         struct fddi_header   fh;
00049         struct llc     lh;
00050 
00051         if (to && to -> hlen == 7)
00052                 memcpy (fh.fddi_dhost, &to -> hbuf [1],
00053                         sizeof (fh.fddi_dhost));
00054         memcpy (fh.fddi_shost,
00055                 &interface -> hw_address.hbuf [1], sizeof (fh.fddi_shost));
00056         fh.fddi_fc = FDDIFC_LLC_ASYNC;
00057         memcpy (&buf [*bufix], &fh, sizeof fh);
00058         *bufix += sizeof fh;
00059 
00060         lh.llc_dsap = LLC_SNAP_LSAP;
00061         lh.llc_ssap = LLC_SNAP_LSAP;
00062         lh.llc_un.type_snap.control = LLC_UI;
00063         lh.llc_un.type_snap.ether_type = htons (ETHERTYPE_IP);
00064         memcpy (&buf [*bufix], &lh, LLC_SNAP_LEN);
00065         *bufix += LLC_SNAP_LEN;
00066 }
00067 #endif /* PACKET_ASSEMBLY */
00068 
00069 #ifdef PACKET_DECODING
00070 /* Decode a hardware header... */
00071 
00072 ssize_t decode_fddi_header (interface, buf, bufix, from)
00073      struct interface_info *interface;
00074      unsigned char *buf;
00075      unsigned bufix;
00076      struct hardware *from;
00077 {
00078         struct fddi_header   fh;
00079         struct llc     lh;
00080         
00081         from -> hbuf [0] = HTYPE_FDDI;
00082         memcpy (&from -> hbuf [1], fh.fddi_shost, sizeof fh.fddi_shost);
00083         return FDDI_HEADER_SIZE + LLC_SNAP_LEN;
00084 }
00085 #endif /* PACKET_DECODING */
00086 #endif /* DEC_FDDI */

Generated on 5 Apr 2014 for ISC DHCP by  doxygen 1.6.1