Contiki-NG
ip64-special-ports.h
1 /*
2  * Copyright (c) 2012, Thingsquare, http://www.thingsquare.com/.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28  * OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  */
31 #ifndef IP64_SPECIAL_PORTS_H
32 #define IP64_SPECIAL_PORTS_H
33 
34 /* The IP64 special ports module allows specific ports on the IP64
35  translator to be mapped to specific address in the IPv6
36  network. The module provides three function prototypes that must be
37  implemented by the user.
38 
39  The IP64 special ports module must be enabled by
40 
41 #define IP64_SPECIAL_PORTS_CONF_ENABLE 1
42 
43  Otherwise, the functions are replaced by empty default definitions
44  in the ip64-special-ports.c module.
45 
46  Port numbers are always in network byte order. */
47 
48 
49 /* Translate the special port to an IPv6 address for inbound
50  packets. */
51 int ip64_special_ports_translate_incoming(uint16_t incoming_port,
52  uip_ip6addr_t *newaddr,
53  uint16_t *newport);
54 int ip64_special_ports_translate_outgoing(uint16_t incoming_port,
55  const uip_ip6addr_t *ip6addr,
56  uint16_t *newport);
57 /* Check if an incoming (destination) port is special. */
58 int ip64_special_ports_incoming_is_special(uint16_t port);
59 
60 /* Check if an outgoing (source) port is special. */
61 int ip64_special_ports_outgoing_is_special(uint16_t port);
62 
63 
64 #endif /* IP64_SPECIAL_PORTS_H */