Changeset 1497


Ignore:
Timestamp:
Oct 12, 2007 11:29:27 PM (16 years ago)
Author:
bennylp
Message:

Related to ticket #399: added comments etc.

Location:
pjproject/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/include/pjnath/nat_detect.h

    r1495 r1497  
    3535 * @ingroup PJNATH_ICE 
    3636 * @{ 
     37 * 
    3738 * This module provides one function to perform NAT classification and 
    38  * detection. 
     39 * detection. NAT type detection is performed by calling 
     40 * #pj_stun_detect_nat_type() function. 
    3941 */ 
    4042 
     43 
    4144/** 
    42  * This enumeration describes the NAT types. 
     45 * This enumeration describes the NAT types, as specified by RFC 3489 
     46 * Section 5, NAT Variations. 
    4347 */ 
    4448typedef enum pj_stun_nat_type 
    4549{ 
     50    /** 
     51     * NAT type is unknown, because the detection has failed. 
     52     */ 
    4653    PJ_STUN_NAT_TYPE_UNKNOWN, 
     54 
     55    /** 
     56     * This specifies that the client has open access to Internet (or 
     57     * at least, its behind a firewall that behaves like a full-cone NAT, 
     58     * but without the translation) 
     59     */ 
    4760    PJ_STUN_NAT_TYPE_OPEN, 
     61 
     62    /** 
     63     * This specifies that communication with server has failed, probably 
     64     * because UDP packets are blocked. 
     65     */ 
    4866    PJ_STUN_NAT_TYPE_BLOCKED, 
     67 
     68    /** 
     69     * Firewall that allows UDP out, and responses have to come back to 
     70     * the source of the request (like a symmetric NAT, but no 
     71     * translation. 
     72     */ 
    4973    PJ_STUN_NAT_TYPE_SYMMETRIC_UDP, 
     74 
     75    /** 
     76     * A full cone NAT is one where all requests from the same internal  
     77     * IP address and port are mapped to the same external IP address and 
     78     * port.  Furthermore, any external host can send a packet to the  
     79     * internal host, by sending a packet to the mapped external address. 
     80     */ 
    5081    PJ_STUN_NAT_TYPE_FULL_CONE, 
     82 
     83    /** 
     84     * A symmetric NAT is one where all requests from the same internal  
     85     * IP address and port, to a specific destination IP address and port, 
     86     * are mapped to the same external IP address and port.  If the same  
     87     * host sends a packet with the same source address and port, but to  
     88     * a different destination, a different mapping is used.  Furthermore, 
     89     * only the external host that receives a packet can send a UDP packet 
     90     * back to the internal host. 
     91     */ 
    5192    PJ_STUN_NAT_TYPE_SYMMETRIC, 
     93 
     94    /** 
     95     * A restricted cone NAT is one where all requests from the same  
     96     * internal IP address and port are mapped to the same external IP  
     97     * address and port.  Unlike a full cone NAT, an external host (with  
     98     * IP address X) can send a packet to the internal host only if the  
     99     * internal host had previously sent a packet to IP address X. 
     100     */ 
    52101    PJ_STUN_NAT_TYPE_RESTRICTED, 
     102 
     103    /** 
     104     * A port restricted cone NAT is like a restricted cone NAT, but the  
     105     * restriction includes port numbers. Specifically, an external host  
     106     * can send a packet, with source IP address X and source port P,  
     107     * to the internal host only if the internal host had previously sent 
     108     * a packet to IP address X and port P. 
     109     */ 
    53110    PJ_STUN_NAT_TYPE_PORT_RESTRICTED 
     111 
    54112} pj_stun_nat_type; 
    55113 
     
    60118typedef struct pj_stun_nat_detect_result 
    61119{ 
     120    /** 
     121     * Status of the detection process. If this value is not PJ_SUCCESS, 
     122     * the detection has failed and \a nat_type field will contain 
     123     * PJ_STUN_NAT_TYPE_UNKNOWN. 
     124     */ 
    62125    pj_status_t          status; 
     126 
     127    /** 
     128     * The text describing the status, if the status is not PJ_SUCCESS. 
     129     */ 
    63130    const char          *status_text; 
     131 
     132    /** 
     133     * This contains the NAT type as detected by the detection procedure. 
     134     * This value is only valid when the \a status is PJ_SUCCESS. 
     135     */ 
    64136    pj_stun_nat_type     nat_type; 
     137 
     138    /** 
     139     * Text describing that NAT type. 
     140     */ 
    65141    const char          *nat_type_name; 
     142 
    66143} pj_stun_nat_detect_result; 
    67144 
     
    76153 
    77154/** 
    78  * Perform NAT classification function. 
     155 * Perform NAT classification function according to the procedures 
     156 * specified in RFC 3489. Once this function returns successfully, 
     157 * the procedure will run in the "background" and will complete 
     158 * asynchronously. Application can register a callback to be notified 
     159 * when such detection has completed. 
     160 * 
     161 * @param server        STUN server address. 
     162 * @param stun_cfg      A structure containing various STUN configurations, 
     163 *                      such as the ioqueue and timer heap instance used 
     164 *                      to receive network I/O and timer events. 
     165 * @param user_data     Application data, which will be returned back 
     166 *                      in the callback. 
     167 * @param cb            Callback to be registered to receive notification 
     168 *                      about detection result. 
     169 * 
     170 * @return              If this function returns PJ_SUCCESS, the procedure 
     171 *                      will complete asynchronously and callback will be 
     172 *                      called when it completes. For other return 
     173 *                      values, it means that an error has occured and 
     174 *                      the procedure did not start. 
    79175 */ 
    80176PJ_DECL(pj_status_t) pj_stun_detect_nat_type(const pj_sockaddr_in *server, 
  • pjproject/trunk/pjnath/src/pjnath/nat_detect.c

    r1496 r1497  
    4242 
    4343 
    44 //#define CHANGE_PORT       (0x01 << 30) 
    45 //#define CHANGE_ADDR_PORT    (0x03 << 29) 
    46 //#define CHANGE_ADDR_PORT      0xFFFFFFFFU 
     44#define CHANGE_ADDR             4 
    4745#define CHANGE_PORT             2 
    48 #define CHANGE_ADDR_PORT        6 
     46#define CHANGE_ADDR_PORT        (CHANGE_ADDR | CHANGE_PORT) 
    4947 
    5048 
  • pjproject/trunk/pjsip-apps/src/pjsua_wince/pjsua_wince.cpp

    r1495 r1497  
    5454// 
    5555// STUN server 
    56 #if 0 
     56#if 1 
    5757        // Use this to have the STUN server resolved normally 
    5858#   define STUN_DOMAIN  NULL 
    59 #   define STUN_SERVER  "192.168.0.2" 
     59#   define STUN_SERVER  "stun.fwdnet.net" 
    6060#elif 0 
    6161        // Use this to have the STUN server resolved with DNS SRV 
Note: See TracChangeset for help on using the changeset viewer.