WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJNATH Reference

NAT Classification/Detection Tool. More...

Data Structures

struct  pj_stun_nat_detect_result
 

Typedefs

typedef void pj_stun_nat_detect_cb(void *user_data, const pj_stun_nat_detect_result *res)
 

Enumerations

enum  pj_stun_nat_type {
  PJ_STUN_NAT_TYPE_UNKNOWN ,
  PJ_STUN_NAT_TYPE_ERR_UNKNOWN ,
  PJ_STUN_NAT_TYPE_OPEN ,
  PJ_STUN_NAT_TYPE_BLOCKED ,
  PJ_STUN_NAT_TYPE_SYMMETRIC_UDP ,
  PJ_STUN_NAT_TYPE_FULL_CONE ,
  PJ_STUN_NAT_TYPE_SYMMETRIC ,
  PJ_STUN_NAT_TYPE_RESTRICTED ,
  PJ_STUN_NAT_TYPE_PORT_RESTRICTED
}
 

Functions

const char * pj_stun_get_nat_name (pj_stun_nat_type type)
 
pj_status_t pj_stun_detect_nat_type (const pj_sockaddr_in *server, pj_stun_config *stun_cfg, void *user_data, pj_stun_nat_detect_cb *cb)
 
pj_status_t pj_stun_detect_nat_type2 (const pj_sockaddr *server, pj_stun_config *stun_cfg, void *user_data, pj_stun_nat_detect_cb *cb)
 

Detailed Description

This module provides one function to perform NAT classification and detection. NAT type detection is performed by calling pj_stun_detect_nat_type() function.

Typedef Documentation

◆ pj_stun_nat_detect_cb

typedef void pj_stun_nat_detect_cb(void *user_data, const pj_stun_nat_detect_result *res)

Type of callback to be called when the NAT detection function has completed.

Enumeration Type Documentation

◆ pj_stun_nat_type

This enumeration describes the NAT types, as specified by RFC 3489 Section 5, NAT Variations.

Enumerator
PJ_STUN_NAT_TYPE_UNKNOWN 

NAT type is unknown because the detection has not been performed.

PJ_STUN_NAT_TYPE_ERR_UNKNOWN 

NAT type is unknown because there is failure in the detection process, possibly because server does not support RFC 3489.

PJ_STUN_NAT_TYPE_OPEN 

This specifies that the client has open access to Internet (or at least, its behind a firewall that behaves like a full-cone NAT, but without the translation)

PJ_STUN_NAT_TYPE_BLOCKED 

This specifies that communication with server has failed, probably because UDP packets are blocked.

PJ_STUN_NAT_TYPE_SYMMETRIC_UDP 

Firewall that allows UDP out, and responses have to come back to the source of the request (like a symmetric NAT, but no translation.

PJ_STUN_NAT_TYPE_FULL_CONE 

A full cone NAT is one where all requests from the same internal IP address and port are mapped to the same external IP address and port. Furthermore, any external host can send a packet to the internal host, by sending a packet to the mapped external address.

PJ_STUN_NAT_TYPE_SYMMETRIC 

A symmetric NAT is one where all requests from the same internal IP address and port, to a specific destination IP address and port, are mapped to the same external IP address and port. If the same host sends a packet with the same source address and port, but to a different destination, a different mapping is used. Furthermore, only the external host that receives a packet can send a UDP packet back to the internal host.

PJ_STUN_NAT_TYPE_RESTRICTED 

A restricted cone NAT is one where all requests from the same internal IP address and port are mapped to the same external IP address and port. Unlike a full cone NAT, an external host (with IP address X) can send a packet to the internal host only if the internal host had previously sent a packet to IP address X.

PJ_STUN_NAT_TYPE_PORT_RESTRICTED 

A port restricted cone NAT is like a restricted cone NAT, but the restriction includes port numbers. Specifically, an external host can send a packet, with source IP address X and source port P, to the internal host only if the internal host had previously sent a packet to IP address X and port P.

Function Documentation

◆ pj_stun_detect_nat_type()

pj_status_t pj_stun_detect_nat_type ( const pj_sockaddr_in server,
pj_stun_config stun_cfg,
void *  user_data,
pj_stun_nat_detect_cb cb 
)

Perform NAT classification function according to the procedures specified in RFC 3489. Once this function returns successfully, the procedure will run in the "background" and will complete asynchronously. Application can register a callback to be notified when such detection has completed.

See also pj_stun_detect_nat_type2() which supports IPv6.

Parameters
serverSTUN server address.
stun_cfgA structure containing various STUN configurations, such as the ioqueue and timer heap instance used to receive network I/O and timer events.
user_dataApplication data, which will be returned back in the callback.
cbCallback to be registered to receive notification about detection result.
Returns
If this function returns PJ_SUCCESS, the procedure will complete asynchronously and callback will be called when it completes. For other return values, it means that an error has occured and the procedure did not start.

◆ pj_stun_detect_nat_type2()

pj_status_t pj_stun_detect_nat_type2 ( const pj_sockaddr server,
pj_stun_config stun_cfg,
void *  user_data,
pj_stun_nat_detect_cb cb 
)

Variant of pj_stun_detect_nat_type() that supports IPv6.

Parameters
serverSTUN server address.
stun_cfgA structure containing various STUN configurations, such as the ioqueue and timer heap instance used to receive network I/O and timer events.
user_dataApplication data, which will be returned back in the callback.
cbCallback to be registered to receive notification about detection result.
Returns
If this function returns PJ_SUCCESS, the procedure will complete asynchronously and callback will be called when it completes. For other return values, it means that an error has occured and the procedure did not start.

References PJ_END_DECL.

◆ pj_stun_get_nat_name()

const char * pj_stun_get_nat_name ( pj_stun_nat_type  type)

Get the NAT name from the specified NAT type.

Parameters
typeNAT type.
Returns
NAT name.

 


PJNATH - Open Source NAT traversal helper library supporting STUN, TURN, and ICE
Copyright (C) 2006-2009 Teluu Inc.