1/* 2 * Copyright (c) 2000-2014 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 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 11 * file. 12 * 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. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#ifndef _S_IPCONFIGD_TYPES_H 25#define _S_IPCONFIGD_TYPES_H 26 27#include <mach/boolean.h> 28#include <netinet/in.h> 29#include "DHCPv6.h" 30#include "DHCPv6Options.h" 31#include "timer.h" 32#include "dhcp_options.h" 33 34#define IPV4_METHOD_BIT 0x100 35#define IPV6_METHOD_BIT 0x200 36 37typedef enum { 38 ipconfig_method_none_e = 0x0, 39 40 /* IPv4 */ 41 ipconfig_method_none_v4_e = 0x100, 42 ipconfig_method_manual_e = 0x101, 43 ipconfig_method_bootp_e = 0x102, 44 ipconfig_method_dhcp_e = 0x103, 45 ipconfig_method_inform_e = 0x104, 46 ipconfig_method_linklocal_e = 0x105, 47 ipconfig_method_failover_e = 0x106, 48 49 /* IPv6 */ 50 ipconfig_method_none_v6_e = 0x200, 51 ipconfig_method_manual_v6_e = 0x201, 52 ipconfig_method_automatic_v6_e = 0x202, 53 ipconfig_method_rtadv_e = 0x203, 54 ipconfig_method_stf_e = 0x204, 55 ipconfig_method_linklocal_v6_e = 0x205, 56} ipconfig_method_t; 57 58const char * 59ipconfig_method_string(ipconfig_method_t m); 60 61static __inline__ boolean_t 62ipconfig_method_is_dhcp_or_bootp(ipconfig_method_t method) 63{ 64 if (method == ipconfig_method_dhcp_e 65 || method == ipconfig_method_bootp_e) { 66 return (TRUE); 67 } 68 return (FALSE); 69} 70 71static __inline__ boolean_t 72ipconfig_method_is_manual(ipconfig_method_t method) 73{ 74 if (method == ipconfig_method_manual_e 75 || method == ipconfig_method_failover_e 76 || method == ipconfig_method_inform_e) { 77 return (TRUE); 78 } 79 return (FALSE); 80} 81 82static __inline__ boolean_t 83ipconfig_method_is_v4(ipconfig_method_t method) 84{ 85 return ((method & IPV4_METHOD_BIT) != 0); 86} 87 88static __inline__ boolean_t 89ipconfig_method_is_v6(ipconfig_method_t method) 90{ 91 return ((method & IPV6_METHOD_BIT) != 0); 92} 93 94typedef struct { 95 struct in_addr addr; 96 struct in_addr mask; 97 struct in_addr router; 98 boolean_t ignore_link_status; 99 int32_t failover_timeout; 100} ipconfig_method_data_manual_t; 101 102typedef struct { 103 int client_id_len; 104 uint8_t client_id[1]; 105} ipconfig_method_data_dhcp_t; 106 107#define LINKLOCAL_ALLOCATE TRUE 108#define LINKLOCAL_NO_ALLOCATE FALSE 109typedef struct { 110 boolean_t allocate; 111} ipconfig_method_data_linklocal_t; 112 113typedef struct { 114 struct in6_addr addr; 115 int prefix_length; 116} ipconfig_method_data_manual_v6_t; 117 118typedef enum { 119 address_type_none_e, 120 address_type_ipv4_e, 121 address_type_ipv6_e, 122 address_type_dns_e 123} address_type_t; 124 125typedef struct { 126 address_type_t relay_addr_type; 127 union { 128 struct in_addr v4; 129 struct in6_addr v6; 130 char dns[1]; 131 } relay_addr; 132} ipconfig_method_data_stf_t; 133 134/* 135 * Type: ipconfig_method_data_t 136 * Purpose: 137 * Used internally by IPConfiguration to communicate the config to 138 * the various methods. 139 */ 140typedef union { 141 ipconfig_method_data_manual_t manual; 142 ipconfig_method_data_dhcp_t dhcp; 143 ipconfig_method_data_linklocal_t linklocal; 144 ipconfig_method_data_manual_v6_t manual_v6; 145 ipconfig_method_data_stf_t stf; 146} ipconfig_method_data_t; 147 148/* 149 * Types to hold DHCP/auto-configuration information 150 */ 151typedef struct { 152 const uint8_t * pkt; 153 int pkt_size; 154 dhcpol_t * options; 155 absolute_time_t lease_start; 156 absolute_time_t lease_expiration; 157} dhcp_info_t; 158 159typedef struct { 160 DHCPv6PacketRef pkt; 161 int pkt_len; 162 DHCPv6OptionListRef options; 163 struct in6_addr addr; 164 const struct in6_addr * dns_servers; 165 int dns_servers_count; 166} dhcpv6_info_t; 167 168typedef struct { 169 boolean_t requested; 170 boolean_t supported; 171} active_during_sleep_t; 172 173#endif /* _S_IPCONFIGD_TYPES_H */ 174