]>
Commit | Line | Data |
---|---|---|
52b7d2ce A |
1 | /* |
2 | * Copyright (C) 2004 SuSE Linux AG, Nuernberg, Germany. | |
3 | * Contributed by: Michal Ludvig <mludvig@suse.cz>, SUSE Labs | |
4 | * All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. Neither the name of the project nor the names of its contributors | |
15 | * may be used to endorse or promote products derived from this software | |
16 | * without specific prior written permission. | |
17 | * | |
18 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND | |
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE | |
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
28 | * SUCH DAMAGE. | |
29 | */ | |
30 | ||
31 | #ifndef _NATTRAVERSAL_H | |
32 | #define _NATTRAVERSAL_H | |
33 | ||
34 | #include "vendorid.h" | |
35 | ||
36 | #ifdef __APPLE__ | |
37 | #define UDP_ENCAP_ESPINUDP 2 /* to make it compile - we don't use this */ | |
38 | #endif | |
39 | ||
40 | #define NAT_ANNOUNCED (1L<<0) | |
41 | #define NAT_DETECTED_ME (1L<<1) | |
42 | #define NAT_DETECTED_PEER (1L<<2) | |
43 | #define NAT_PORTS_CHANGED (1L<<3) | |
44 | #define NAT_KA_QUEUED (1L<<4) | |
45 | #define NAT_ADD_NON_ESP_MARKER (1L<<5) | |
46 | ||
47 | #define NATT_AVAILABLE(ph1) ((iph1)->natt_flags & NAT_ANNOUNCED) | |
48 | ||
49 | #define NAT_DETECTED (NAT_DETECTED_ME | NAT_DETECTED_PEER) | |
50 | ||
51 | #define NON_ESP_MARKER_LEN sizeof(u_int32_t) | |
52 | #define NON_ESP_MARKER_USE(iph1) ((iph1)->natt_flags & NAT_ADD_NON_ESP_MARKER) | |
53 | ||
54 | /* These are the values from parsing "remote {}" | |
55 | block of the config file. */ | |
56 | #define NATT_OFF FALSE /* = 0 */ | |
57 | #define NATT_ON TRUE /* = 1 */ | |
58 | #define NATT_FORCE 2 | |
59 | ||
60 | struct ph1natt_options { | |
61 | int version; | |
62 | u_int16_t float_port; | |
63 | u_int16_t mode_udp_tunnel; | |
64 | u_int16_t mode_udp_transport; | |
65 | u_int16_t encaps_type; /* ESPINUDP / ESPINUDP_NON_IKE */ | |
66 | u_int16_t mode_udp_diff; | |
67 | u_int16_t payload_nat_d; | |
68 | u_int16_t payload_nat_oa; | |
69 | }; | |
70 | ||
71 | struct ph2natt { | |
72 | u_int8_t type; | |
73 | u_int16_t sport; | |
74 | u_int16_t dport; | |
75 | struct sockaddr *oa; | |
76 | u_int16_t frag; | |
77 | }; | |
78 | ||
79 | int natt_vendorid (int vid); | |
80 | vchar_t *natt_hash_addr (struct ph1handle *iph1, struct sockaddr *addr); | |
81 | int natt_compare_addr_hash (struct ph1handle *iph1, vchar_t *natd_received, int natd_seq); | |
82 | int natt_udp_encap (int encmode); | |
83 | int natt_fill_options (struct ph1natt_options *opts, int version); | |
84 | void natt_float_ports (struct ph1handle *iph1); | |
85 | void natt_handle_vendorid (struct ph1handle *iph1, int vid_numeric); | |
86 | #ifdef NOT_NOW | |
87 | int create_natoa_payloads(struct ph2handle *iph2, vchar_t **, vchar_t **); | |
88 | #endif | |
89 | ||
90 | struct payload_list * | |
91 | isakmp_plist_append_natt_vids (struct payload_list *plist, vchar_t *vid_natt[MAX_NATT_VID_COUNT]); | |
92 | ||
93 | #ifndef __APPLE__ | |
94 | /* NAT keepalive functions */ | |
95 | void natt_keepalive_init (void); | |
96 | int natt_keepalive_add (struct sockaddr *src, struct sockaddr *dst); | |
97 | int natt_keepalive_add_ph1 (struct ph1handle *iph1); | |
98 | void natt_keepalive_remove (struct sockaddr *src, struct sockaddr *dst); | |
99 | #endif | |
100 | ||
101 | /* Walk through all rmconfigs and tell if NAT-T is enabled in at least one. */ | |
102 | int natt_enabled_in_rmconf (void); | |
103 | ||
104 | #endif /* _NATTRAVERSAL_H */ |