]> git.ipfire.org Git - thirdparty/dhcp.git/blob - common/fddi.c
bb466fce44f77382dc764ecf39a0edb648957993
[thirdparty/dhcp.git] / common / fddi.c
1 /* fddi.c
2
3 Packet assembly code, originally contributed by Archie Cobbs. */
4
5 /*
6 * Copyright (c) 2004 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 * http://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 * ``http://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 #ifndef lint
36 static char copyright[] =
37 "$Id: fddi.c,v 1.4 2005/03/17 20:14:58 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
38 #endif /* not lint */
39
40 #include "dhcpd.h"
41
42 #if defined (DEC_FDDI)
43 #include <netinet/if_fddi.h>
44 #include <net/if_llc.h>
45
46 #if defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING)
47 #include "includes/netinet/if_ether.h"
48 #endif /* PACKET_ASSEMBLY || PACKET_DECODING */
49
50 #if defined (PACKET_ASSEMBLY)
51 /* Assemble an hardware header... */
52
53 void assemble_fddi_header (interface, buf, bufix, to)
54 struct interface_info *interface;
55 unsigned char *buf;
56 unsigned *bufix;
57 struct hardware *to;
58 {
59 struct fddi_header fh;
60 struct llc lh;
61
62 if (to && to -> hlen == 7)
63 memcpy (fh.fddi_dhost, &to -> hbuf [1],
64 sizeof (fh.fddi_dhost));
65 memcpy (fh.fddi_shost,
66 &interface -> hw_address.hbuf [1], sizeof (fh.fddi_shost));
67 fh.fddi_fc = FDDIFC_LLC_ASYNC;
68 memcpy (&buf [*bufix], &fh, sizeof fh);
69 *bufix += sizeof fh;
70
71 lh.llc_dsap = LLC_SNAP_LSAP;
72 lh.llc_ssap = LLC_SNAP_LSAP;
73 lh.llc_un.type_snap.control = LLC_UI;
74 lh.llc_un.type_snap.ether_type = htons (ETHERTYPE_IP);
75 memcpy (&buf [*bufix], &lh, LLC_SNAP_LEN);
76 *bufix += LLC_SNAP_LEN;
77 }
78 #endif /* PACKET_ASSEMBLY */
79
80 #ifdef PACKET_DECODING
81 /* Decode a hardware header... */
82
83 ssize_t decode_fddi_header (interface, buf, bufix, from)
84 struct interface_info *interface;
85 unsigned char *buf;
86 unsigned bufix;
87 struct hardware *from;
88 {
89 struct fddi_header fh;
90 struct llc lh;
91
92 from -> hbuf [0] = HTYPE_FDDI;
93 memcpy (&from -> hbuf [1], fh.fddi_shost, sizeof fh.fddi_shost);
94 return FDDI_HEADER_SIZE + LLC_SNAP_LEN;
95 }
96 #endif /* PACKET_DECODING */
97 #endif /* DEC_FDDI */