]>
git.saurik.com Git - apple/xnu.git/blob - bsd/net/packet_mangler.h
2 * Copyright (c) 2014 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef __PACKET_MANGLER_H__
25 #define __PACKET_MANGLER_H__
27 #include <sys/param.h>
28 #include <sys/types.h>
29 #include <sys/socket.h>
30 #include <sys/syslog.h>
31 #include <netinet/in.h>
34 #ifdef BSD_KERNEL_PRIVATE
36 #include <sys/socketvar.h>
37 #endif /* BSD_KERNEL_PRIVATE */
50 * Kernel control name for an instance of a packet mangler.
51 * Use CTLIOCGINFO to find out the corresponding kernel control id
52 * to be set in the sc_id field of sockaddr_ctl for connect(2)
53 * Note: the sc_unit is ephemeral
55 #define PACKET_MANGLER_CONTROL_NAME "com.apple.packet-mangler"
57 #define PKT_MNGLR_OPT_PROTO_ACT_MASK 1
58 #define PKT_MNGLR_OPT_IP_ACT_MASK 2
59 #define PKT_MNGLR_OPT_LOCAL_IP 3
60 #define PKT_MNGLR_OPT_REMOTE_IP 4
61 #define PKT_MNGLR_OPT_LOCAL_PORT 5
62 #define PKT_MNGLR_OPT_REMOTE_PORT 6
63 #define PKT_MNGLR_OPT_DIRECTION 7
64 #define PKT_MNGLR_OPT_PROTOCOL 8
65 #define PKT_MNGLR_OPT_ACTIVATE 0xFFFFFFFF
67 /* Packet mangler action masks */
68 /* Packet Mangler TCP action mask */
69 #define PKT_MNGLR_TCP_ACT_NOP_MPTCP 0x00000001
70 #define PKT_MNGLR_TCP_ACT_SWAP_L_PORT 0x00000002
71 #define PKT_MNGLR_TCP_ACT_SWAP_R_PORT 0x00000004
72 #define PKT_MNGLR_TCP_ACT_DSS_DROP 0x00000008
73 #define PKT_MNGLR_TCP_ACT_CHK_EXTENDED 0x80000000
75 /* Packet Mangler IP action mask */
76 #define PKT_MNGLR_IP_ACT_FLT_L_IP 0x00000001
77 #define PKT_MNGLR_IP_ACT_FLT_R_IP 0x00000002
78 #define PKT_MNGLR_IP_ACT_SWAP_L_IP 0x00000004
79 #define PKT_MNGLR_IP_ACT_SWAP_R_IP 0x00000008
80 #define PKT_MNGLR_IP_ACT_DROP_PACKET 0x00000010
81 #define PKT_MNGLR_IP_ACT_CHK_EXTENDED 0x80000000
84 * How many filter may be active simultaneously
86 #define PKT_MNGLR_MAX_FILTER_COUNT 1
88 #define PKT_MNGLR_VERSION_CURRENT 1
92 #ifdef BSD_KERNEL_PRIVATE
94 extern int pkt_mnglr_log_level
;
96 #define PKT_MNGLR_LOG(level, fmt, ...) \
98 if (pkt_mnglr_log_level >= level) \
99 printf("%s:%d " fmt "\n",\
100 __FUNCTION__, __LINE__, ##__VA_ARGS__); \
104 extern void pkt_mnglr_init(void);
108 #endif /* BSD_KERNEL_PRIVATE */
110 #endif /* __PACKET_MANGLER_H__ */