/** @file
* A header file for nat.c
*
* @author (version 1.0) Abhinav Pathak
* @author (version 1.1) Lauri Silvennoinen
* @version 1.1
* @date 27.10.2006
* @note Related drafts:
*
* @note Distributed under GNU/GPL.
* @note All Doxygen comments have been added in version 1.1.
*/
#ifndef __NAT_H__
#define __NAT_H__
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "user.h"
#include "debug.h"
#include "state.h"
/** Maximum length of a UDP packet. */
#define HIP_MAX_LENGTH_UDP_PACKET 2000
/** Time interval between consecutive NAT Keep-Alive packets in seconds.
@note According to [draft-schmitt-hip-nat-traversal-02], the default
keep-alive interval for control channels must be 20 seconds. However, for
debugging purposes a smaller value is used here.
@todo Change this value. */
#define HIP_NAT_KEEP_ALIVE_INTERVAL 3
/** Number of retransmissions to try if hip_send_udp() fails. */
#define HIP_NAT_NUM_RETRANSMISSION 2
/** Amount of time to sleep between transmission and retransmissions. */
#define HIP_NAT_SLEEP_TIME 2
/** Port number for NAT traversal of hip control packets. */
#define HIP_NAT_UDP_PORT 50500
/** For setting socket to listen for beet-udp packets. */
#define HIP_UDP_ENCAP 100
/** UDP encapsulation type. */
#define HIP_UDP_ENCAP_ESPINUDP 2
/** UDP encapsulation type. */
#define HIP_UDP_ENCAP_ESPINUDP_NONIKE 1
/** Boolean which indicates if random port simulation is on.
- 0: port randomizing is off.
- 1: port randomizing is on.
@note Not used currently.
@note This is needed only for simulation purposes and can be removed from
released versions of HIPL.*/
#define HIP_UDP_PORT_RANDOMIZING 0
/** Boolean to indicate if a NATed network is simulated.
- 0: NATed network is not simulated, real life NATs exist in the network.
- 1: NATed network is simulated, real life NATs do not exist in the
network, but UDP encapsulation is still used.
@note This has no effect if HIP_UDP_PORT_RANDOMIZING is off
@note Not used currently.
@note This is needed only for simulation purposes and can be removed from
released versions of HIPL.*/
#define HIP_SIMULATE_NATS 0
/** Minimum port number a NAT can randomize.
Has to be float as it is used in rand().
@note This is needed only for simulation purposes and can be removed from
released versions of HIPL.*/
#define HIP_UDP_PORT_RAND_MIN 49152.0
/** Maximum port number a NAT can randomize.
Has to be float as it is used in rand().
@note This is needed only for simulation purposes and can be removed from
released versions of HIPL.*/
#define HIP_UDP_PORT_RAND_MAX 65535.0
/** File descriptor of socket used for hip control packet NAT traversal on
UDP/IPv4. Defined in hipd.c */
extern int hip_nat_sock_udp;
/** Specifies the NAT status of the daemon. This value indicates if the current
machine is behind a NAT. Defined in hipd.c */
extern int hip_nat_status;
int hip_nat_on();
int hip_nat_off();
int hip_nat_off_for_ha(hip_ha_t *, void *);
int hip_nat_on_for_ha(hip_ha_t *, void *);
void hip_nat_randomize_nat_ports();
int hip_nat_refresh_port();
int hip_nat_send_keep_alive(hip_ha_t *, void *);
#endif /* __NAT_H__ */