1 /* $NetBSD: fddi.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $ */
4 Packet assembly code, originally contributed by Archie Cobbs. */
7 * Copyright (c) 2004,2007,2009,2014 by Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 1996-2003 by Internet Software Consortium
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Internet Systems Consortium, Inc.
24 * Redwood City, CA 94063
26 * https://www.isc.org/
30 #include <sys/cdefs.h>
31 __RCSID("$NetBSD: fddi.c,v 1.1.1.2 2014/07/12 11:57:44 spz Exp $");
35 #if defined (DEC_FDDI)
36 #include <netinet/if_fddi.h>
37 #include <net/if_llc.h>
39 #if defined (PACKET_ASSEMBLY) || defined (PACKET_DECODING)
40 #include "includes/netinet/if_ether.h"
41 #endif /* PACKET_ASSEMBLY || PACKET_DECODING */
43 #if defined (PACKET_ASSEMBLY)
44 /* Assemble an hardware header... */
46 void assemble_fddi_header (interface
, buf
, bufix
, to
)
47 struct interface_info
*interface
;
52 struct fddi_header fh
;
55 if (to
&& to
-> hlen
== 7)
56 memcpy (fh
.fddi_dhost
, &to
-> hbuf
[1],
57 sizeof (fh
.fddi_dhost
));
58 memcpy (fh
.fddi_shost
,
59 &interface
-> hw_address
.hbuf
[1], sizeof (fh
.fddi_shost
));
60 fh
.fddi_fc
= FDDIFC_LLC_ASYNC
;
61 memcpy (&buf
[*bufix
], &fh
, sizeof fh
);
64 lh
.llc_dsap
= LLC_SNAP_LSAP
;
65 lh
.llc_ssap
= LLC_SNAP_LSAP
;
66 lh
.llc_un
.type_snap
.control
= LLC_UI
;
67 lh
.llc_un
.type_snap
.ether_type
= htons (ETHERTYPE_IP
);
68 memcpy (&buf
[*bufix
], &lh
, LLC_SNAP_LEN
);
69 *bufix
+= LLC_SNAP_LEN
;
71 #endif /* PACKET_ASSEMBLY */
73 #ifdef PACKET_DECODING
74 /* Decode a hardware header... */
76 ssize_t
decode_fddi_header (interface
, buf
, bufix
, from
)
77 struct interface_info
*interface
;
80 struct hardware
*from
;
82 struct fddi_header fh
;
85 from
-> hbuf
[0] = HTYPE_FDDI
;
86 memcpy (&from
-> hbuf
[1], fh
.fddi_shost
, sizeof fh
.fddi_shost
);
87 return FDDI_HEADER_SIZE
+ LLC_SNAP_LEN
;
89 #endif /* PACKET_DECODING */