Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / dhcp / common / fddi.c
blobe2a1766ebbc2a3705643800eddff87733a13a4a5
1 /* fddi.c
3 Packet assembly code, originally contributed by Archie Cobbs. */
5 /*
6 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
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.
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.
21 * Internet Systems Consortium, Inc.
22 * 950 Charter Street
23 * Redwood City, CA 94063
24 * <info@isc.org>
25 * http://www.isc.org/
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''.
35 #ifndef lint
36 static char copyright[] =
37 "$Id: fddi.c,v 1.5 2005/08/11 17:13:21 drochner Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
38 #endif /* not lint */
40 #include "dhcpd.h"
42 #if defined (DEC_FDDI) || defined (NETBSD_FDDI)
43 #if defined (DEC_FDDI)
44 #include <netinet/if_fddi.h>
45 #include <net/if_llc.h>
46 #endif /* DEC_FDDI */
48 #if defined (NETBSD_FDDI)
49 #include <net/if_fddi.h>
50 #include <net/if_llc.h>
51 #define LLC_SNAP_LEN LLC_SNAPFRAMELEN
52 #endif /* NETBSD_FDDI */
54 #if defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING)
55 #include "includes/netinet/if_ether.h"
56 #endif /* PACKET_ASSEMBLY || PACKET_DECODING */
58 #if defined (PACKET_ASSEMBLY)
59 /* Assemble an hardware header... */
61 void assemble_fddi_header (struct interface_info *interface,
62 unsigned char *buf, unsigned *bufix, struct hardware *to)
64 struct fddi_header fh;
65 struct llc lh;
67 if (to && to -> hlen == 7)
68 memcpy (fh.fddi_dhost, &to -> hbuf [1],
69 sizeof (fh.fddi_dhost));
70 memcpy (fh.fddi_shost,
71 &interface -> hw_address.hbuf [1], sizeof (fh.fddi_shost));
72 fh.fddi_fc = FDDIFC_LLC_ASYNC;
73 memcpy (&buf [*bufix], &fh, sizeof fh);
74 *bufix += sizeof fh;
76 memset (&lh, 0, sizeof lh);
77 lh.llc_dsap = LLC_SNAP_LSAP;
78 lh.llc_ssap = LLC_SNAP_LSAP;
79 lh.llc_un.type_snap.control = LLC_UI;
80 lh.llc_un.type_snap.ether_type = htons (ETHERTYPE_IP);
81 memcpy (&buf [*bufix], &lh, LLC_SNAP_LEN);
82 *bufix += LLC_SNAP_LEN;
84 #endif /* PACKET_ASSEMBLY */
86 #ifdef PACKET_DECODING
87 /* Decode a hardware header... */
89 ssize_t decode_fddi_header (struct interface_info *interface,
90 unsigned char *buf, unsigned bufix, struct hardware *from)
92 struct fddi_header fh;
94 memcpy(&fh, buf + bufix, FDDI_HEADER_SIZE);
96 from -> hbuf [0] = HTYPE_FDDI;
97 from -> hlen = (sizeof fh.fddi_shost) + 1;
98 memcpy (&from -> hbuf [1], fh.fddi_shost, sizeof fh.fddi_shost);
99 return FDDI_HEADER_SIZE + LLC_SNAP_LEN;
101 #endif /* PACKET_DECODING */
102 #endif /* DEC_FDDI || NETBSD_FDDI */