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