4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2015 Joyent, Inc. All rights reserved.
30 #include <sys/socket_impl.h>
31 #include <net/if_arp.h>
35 * With which we do the reverse of what it libpcap does....
37 #define PACKET_OUTGOING LINUX_SLL_OUTGOING
38 #define PACKET_HOST LINUX_SLL_HOST
39 #define PACKET_BROADCAST LINUX_SLL_BROADCAST
40 #define PACKET_MULTICAST LINUX_SLL_MULTICAST
41 #define PACKET_OTHERHOST LINUX_SLL_OTHERHOST
43 #define PACKET_STATISTICS_SHORT 1
44 #define PACKET_ADD_MEMBERSHIP 2
45 #define PACKET_DROP_MEMBERSHIP 3
46 #define PACKET_AUXDATA 4
47 #define PACKET_STATISTICS 5
54 uint8_t mr_address
[8];
57 #define PACKET_MR_MULTICAST 1
58 #define PACKET_MR_PROMISC 2
59 #define PACKET_MR_ALLMULTI 3
61 typedef enum tpkt_status_e
{
66 TP_STATUS_CSUMNOTREADY
69 struct tpacket_auxdata
{ /* tp_macoff/tp_netoff ?? */
70 tpkt_status_t tp_status
;
78 struct tpacket_hdr
{ /* tp_macoff/tp_netoff ?? */
88 struct tpacket2_hdr
{ /* tp_macoff/tp_netoff ?? */
89 tpkt_status_t tp_status
;
99 struct tpacket_stats
{
104 struct tpacket_stats_short
{
109 struct sock_filter
{ /* Fields named from bpf_insn */
118 struct sock_filter
*filter
;
122 * Linux ARPHRD_ symbols needed...
124 * The numbers above 50000 are because their real value is unknown from
125 * libpcap's source, so a number has been chosen that is unlikely to be
126 * confused with the real one on Linux. Those that are already found in
127 * Solaris inside <net/if_arp.h> may have a different value to that found
128 * in Linux but it should be used instead as the Solaris value originates
129 * from the IANA whereas the Linux values seem to ignore it.
131 /* ARPHRD_AX25 see <net/if_arp.h> */
132 /* ARPHRD_CHAOS see <net/if_arp.h> */
133 #define ARPHRD_CSLIP 50005
134 #define ARPHRD_CSLIP6 50006
135 #define ARPHRD_DLCI 15
136 /* ARPHRD_EETHER see <net/if_arp.h> */
137 /* ARPHRD_ETHER see <net/if_arp.h> */
138 #define ARPHRD_FCAL 785
139 #define ARPHRD_FCFABRIC 787
140 #define ARPHRD_FCPL 786
141 #define ARPHRD_FCPP 784
142 #define ARPHRD_FRAD 770
143 #define ARPHRD_FDDI 774
144 /* ARPHRD_IEEE802 see <net/if_arp.h> */
145 #define ARPHRD_IEEE802_TR 800
146 #define ARPHRD_IEEE80211 801
147 #define ARPHRD_IEEE80211_PRISM 802
148 #define ARPHRD_IEEE80211_RADIOTAP 803
149 #define ARPHRD_IRDA 783
150 #define ARPHRD_LAPD 8445
151 #define ARPHRD_LOCALTLK 50010
152 #define ARPHRD_LOOPBACK 50011
153 /* ARPHRD_METRICOM see <net/if_arp.h> */
154 #define ARPHRD_PRONET 50013
155 #define ARPHRD_PPP 50014
156 #define ARPHRD_RAWHDLC 518
157 #define ARPHRD_SIT 776
158 #define ARPHRD_SLIP6 50015
159 #define ARPHRD_SLIP 50016
160 /* ARPHRD_TUNNEL see <net/if_arp.h> */
163 #define ETH_P_802_2 0xaa /* LSAP_SAP */
164 #define ETH_P_803_3 0
165 #define ETH_P_IP 0x800
166 #define ETH_P_ARP 0x806
167 #define ETH_P_IPV6 0x86dd
171 * PFP socket structure.
173 typedef struct pfpsock
{
174 struct bpf_program ps_bpf
;
175 krwlock_t ps_bpflock
;
176 sock_upper_handle_t ps_upper
;
177 sock_upcalls_t
*ps_upcalls
;
179 mac_client_handle_t ps_mch
;
180 mac_promisc_handle_t ps_phd
;
185 mac_client_promisc_type_t ps_promisc
;
186 boolean_t ps_auxdata
;
187 struct tpacket_stats ps_stats
;
188 struct sockaddr_ll ps_sock
;
189 datalink_id_t ps_linkid
;
191 boolean_t ps_flow_ctrld
;
192 ulong_t ps_flow_ctrl_drops
;
193 timespec_t ps_timestamp
;
197 typedef struct pfp_kstats_s
{
198 kstat_named_t kp_recv_mac_hdr_fail
;
199 kstat_named_t kp_recv_bad_proto
;
200 kstat_named_t kp_recv_alloc_fail
;
201 kstat_named_t kp_recv_ok
;
202 kstat_named_t kp_recv_fail
;
203 kstat_named_t kp_recv_filtered
;
204 kstat_named_t kp_recv_flow_cntrld
;
205 kstat_named_t kp_send_unbound
;
206 kstat_named_t kp_send_failed
;
207 kstat_named_t kp_send_too_big
;
208 kstat_named_t kp_send_alloc_fail
;
209 kstat_named_t kp_send_uiomove_fail
;
210 kstat_named_t kp_send_no_memory
;
211 kstat_named_t kp_send_open_fail
;
212 kstat_named_t kp_send_wrong_family
;
213 kstat_named_t kp_send_short_msg
;
214 kstat_named_t kp_send_ok
;
218 #endif /* _PACKET_H */