1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License").  You may not use this file except in compliance with the
9 * License.  Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23#ifndef _NETINET_IF_FIREWIRE_H_
24#define _NETINET_IF_FIREWIRE_H_
25#include <net/ethernet.h>
26#include <netinet/in.h>
27#include <net/if_arp.h>
28
29#define FIREWIREMCAST_V4_LEN		4
30#define FIREWIREMCAST_V6_LEN		1
31
32const u_char ipv4multicast[FIREWIREMCAST_V4_LEN]	= {0x01, 0x00, 0x5e, 0x00};
33const u_char ipv6multicast[FIREWIREMCAST_V6_LEN]	= {0xFF};
34const u_char fwbroadcastaddr[FIREWIRE_ADDR_LEN]		= {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
35
36/*
37 * Macro to map an IP multicast address to an FIREWIRE multicast address.
38 * The high-order 25 bits of the FIREWIRE address are statically assigned,
39 * and the low-order 23 bits are taken from the low end of the IP address.
40 */
41#define FIREWIRE_MAP_IP_MULTICAST(ipaddr, enaddr) \
42	/* struct in_addr *ipaddr; */ \
43	/* u_char enaddr[FIREWIRE_ADDR_LEN];	   */ \
44{ \
45	(enaddr)[0] = ipv4multicast[0]; \
46	(enaddr)[1] = ipv4multicast[1]; \
47	(enaddr)[2] = ipv4multicast[2]; \
48	(enaddr)[3] = ipv4multicast[3]; \
49	(enaddr)[4] = ((u_char *)ipaddr)[0]; \
50	(enaddr)[5] = ((u_char *)ipaddr)[1] & 0x7f; \
51	(enaddr)[6] = ((u_char *)ipaddr)[2]; \
52	(enaddr)[7] = ((u_char *)ipaddr)[3]; \
53}
54
55/*
56 * Macro to map an IPv6 multicast address to an FIREWIRE multicast address.
57 * The high-order 16 bits of the FIREWIRE address are statically assigned,
58 * and the low-order 48 bits are taken from the low end of the IPv6 address.
59 */
60#define FIREWIRE_MAP_IPV6_MULTICAST(ip6addr, enaddr)	\
61/* struct	in6_addr *ip6addr; */						\
62/* u_char	enaddr[FIREWIRE_ADDR_LEN]; */				\
63{                                                       \
64	(enaddr)[0] = ((u_char *)ip6addr)[0];									\
65	(enaddr)[1] = ((u_char *)ip6addr)[1];									\
66	(enaddr)[2] = ((u_char *)ip6addr)[10];				\
67	(enaddr)[3] = ((u_char *)ip6addr)[11];				\
68	(enaddr)[4] = ((u_char *)ip6addr)[12];				\
69	(enaddr)[5] = ((u_char *)ip6addr)[13];				\
70	(enaddr)[6] = ((u_char *)ip6addr)[14];				\
71	(enaddr)[7] = ((u_char *)ip6addr)[15];				\
72}
73
74#endif
75