Ignore:
Timestamp:
Feb 20, 2007 9:58:36 PM (17 years ago)
Author:
bennylp
Message:

Checked in latest changes in iceproject branch before merging in to the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/iceproject/pjlib-util/include/pjlib-util/stun_msg.h

    r929 r990  
    179179 * Determine if the message type is a request. 
    180180 */ 
    181 #define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0F00) == 0x0000) 
     181#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000) 
    182182 
    183183 
     
    185185 * Determine if the message type is a response. 
    186186 */ 
    187 #define PJ_STUN_IS_RESPONSE(msg_type)   (((msg_type) & 0x0F00) == 0x0100) 
    188  
     187#define PJ_STUN_IS_RESPONSE(msg_type)   (((msg_type) & 0x0110) == 0x0100) 
     188 
     189 
     190/** 
     191 * The response bit in the message type. 
     192 */ 
     193#define PJ_STUN_RESPONSE_BIT            (0x0100) 
    189194 
    190195/** 
    191196 * Determine if the message type is an error response. 
    192197 */ 
    193 #define PJ_STUN_IS_ERROR_RESPONSE(msg_type) (((msg_type) & 0x0FF0) == 0x0110) 
    194  
    195  
    196 #if 0 
     198#define PJ_STUN_IS_ERROR_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0110) 
     199 
     200 
     201/** 
     202 * The error response bit in the message type. 
     203 */ 
     204#define PJ_STUN_ERROR_RESPONSE_BIT      (0x0110) 
     205 
     206 
    197207/** 
    198208 * Determine if the message type is an indication message. 
    199209 */ 
    200 #define PJ_STUN_IS_INDICATION(msg_type) (((msg_type) & 0x0FF0) == 0x0010) 
    201 #endif 
     210#define PJ_STUN_IS_INDICATION(msg_type) (((msg_type) & 0x0110) == 0x0010) 
     211 
     212 
     213/** 
     214 * The error response bit in the message type. 
     215 */ 
     216#define PJ_STUN_INDICATION_BIT          (0x0010) 
    202217 
    203218 
     
    325340    PJ_STUN_ATTR_NONCE              = 0x0015,/**< NONCE attribute.          */ 
    326341    PJ_STUN_ATTR_RELAY_ADDRESS      = 0x0016,/**< RELAY-ADDRESS attribute.  */ 
     342    PJ_STUN_ATTR_REQUESTED_ADDR_TYPE= 0x0017,/**< REQUESTED-ADDRESS-TYPE    */ 
    327343    PJ_STUN_ATTR_REQUESTED_PORT_PROPS=0x0018,/**< REQUESTED-PORT-PROPS      */ 
    328344    PJ_STUN_ATTR_REQUESTED_TRANSPORT= 0x0019,/**< REQUESTED-TRANSPORT       */ 
     
    330346    PJ_STUN_ATTR_TIMER_VAL          = 0x0021,/**< TIMER-VAL attribute.      */ 
    331347    PJ_STUN_ATTR_REQUESTED_IP       = 0x0022,/**< REQUESTED-IP attribute    */ 
     348    PJ_STUN_ATTR_XOR_REFLECTED_FROM = 0x0023,/**< XOR-REFLECTED-FROM        */ 
     349    PJ_STUN_ATTR_PRIORITY           = 0x0024,/**< PRIORITY                  */ 
     350    PJ_STUN_ATTR_USE_CANDIDATE      = 0x0025,/**< USE-CANDIDATE             */ 
     351    PJ_STUN_ATTR_XOR_INTERNAL_ADDR  = 0x0026,/**< XOR-INTERNAL-ADDRESS      */ 
     352 
     353    PJ_STUN_ATTR_END_MANDATORY_ATTR, 
     354 
     355    PJ_STUN_ATTR_START_EXTENDED_ATTR= 0x8021, 
     356 
    332357    PJ_STUN_ATTR_FINGERPRINT        = 0x8021,/**< FINGERPRINT attribute.    */ 
    333358    PJ_STUN_ATTR_SERVER             = 0x8022,/**< SERVER attribute.         */ 
    334359    PJ_STUN_ATTR_ALTERNATE_SERVER   = 0x8023,/**< ALTERNATE-SERVER.         */ 
    335     PJ_STUN_ATTR_REFRESH_INTERVAL   = 0x8024 /**< REFRESH-INTERVAL.         */ 
     360    PJ_STUN_ATTR_REFRESH_INTERVAL   = 0x8024,/**< REFRESH-INTERVAL.         */ 
     361 
     362    PJ_STUN_ATTR_END_EXTENDED_ATTR 
     363 
    336364} pj_stun_attr_type; 
    337365 
    338366 
    339367/** 
    340  * STUN error codes. 
     368 * STUN error codes, which goes into STUN ERROR-CODE attribute. 
    341369 */ 
    342370typedef enum pj_stun_status 
     
    491519 
    492520    /** 
    493      * The first 8 bits of the attribute are ignored for the purposes 
    494      * of aligning parameters on natural 32 bit boundaries. 
    495      */ 
    496     pj_uint8_t          ignored; 
    497  
    498     /** 
    499      * The address family can take on the following values: 
    500      *  
    501      * 0x01:IPv4 
    502      * 0x02:IPv6 
    503      */ 
    504     pj_uint8_t          family; 
    505  
    506     /** 
    507      * Port number. 
    508      */ 
    509     pj_uint16_t         port; 
    510  
    511     /** 
    512      * The address. 
     521     * The socket address (as a union) 
    513522     */ 
    514523    union { 
    515  
    516         /** IPv4 address. */ 
    517         pj_uint32_t     ipv4; 
    518  
    519         /** IPv6 address. */ 
    520         char            ipv6[1]; 
    521  
     524        pj_sockaddr         addr;   /**< Generic socket address.    */ 
     525        pj_sockaddr_in      ipv4;   /**< IPv4 socket address.       */ 
     526        pj_sockaddr_in6     ipv6;   /**< IPv6 socket address.       */ 
    522527    } addr; 
    523528 
    524529} pj_stun_generic_ip_addr_attr; 
     530 
     531 
     532/** 
     533 * This structure represents a generic STUN attributes with no payload, 
     534 * and it is used for example by ICE USE-CANDIDATE attribute. 
     535 */ 
     536typedef struct pj_stun_empty_attr 
     537{ 
     538    /** 
     539     * Standard STUN attribute header. 
     540     */ 
     541    pj_stun_attr_hdr    hdr; 
     542 
     543} pj_stun_empty_attr; 
    525544 
    526545 
     
    900919 
    901920/** 
     921 * This describes the REQUESTED-ADDRESS-TYPE attribute. 
     922 * The REQUESTED-ADDRESS-TYPE attribute is used by clients to request 
     923 * the allocation of a specific address type from a server.  The 
     924 * following is the format of the REQUESTED-ADDRESS-TYPE attribute. 
     925 
     926 \verbatim 
     927 
     928      0                   1                   2                   3 
     929      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 
     930     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     931     |        Family                 |           Reserved            | 
     932     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 
     933 
     934 \endverbatim 
     935 */ 
     936typedef struct pj_stun_generic_uint_attr pj_stun_requested_addr_type; 
     937 
     938/** 
    902939 * This describes the STUN REQUESTED-PORT-PROPS attribute. 
    903940 * This attribute allows the client to request certain properties for 
     
    936973typedef struct pj_stun_generic_ip_addr_attr pj_stun_requested_ip_attr; 
    937974 
     975/** 
     976 * This describes the XOR-REFLECTED-FROM attribute, as described by 
     977 * draft-macdonald-behave-nat-behavior-discovery-00. 
     978 * The XOR-REFLECTED-FROM attribute is used in place of the REFLECTED- 
     979 * FROM attribute.  It provides the same information, but because the 
     980 * NAT's public address is obfuscated through the XOR function, It can 
     981 * pass through a NAT that would otherwise attempt to translate it to 
     982 * the private network address.  XOR-REFLECTED-FROM has identical syntax 
     983 * to XOR-MAPPED-ADDRESS. 
     984 */ 
     985typedef struct pj_stun_generic_ip_addr_attr pj_stun_xor_reflected_from_attr; 
     986 
     987/** 
     988 * This describes the PRIORITY attribute from draft-ietf-mmusic-ice-13. 
     989 * The PRIORITY attribute indicates the priority that is to be 
     990 * associated with a peer reflexive candidate, should one be discovered 
     991 * by this check.  It is a 32 bit unsigned integer, and has an attribute 
     992 * type of 0x0024. 
     993 */ 
     994typedef struct pj_stun_generic_uint_attr pj_stun_priority_attr; 
     995 
     996/** 
     997 * This describes the USE-CANDIDATE attribute from draft-ietf-mmusic-ice-13. 
     998 * The USE-CANDIDATE attribute indicates that the candidate pair 
     999 * resulting from this check should be used for transmission of media. 
     1000 * The attribute has no content (the Length field of the attribute is 
     1001 * zero); it serves as a flag. 
     1002 */ 
     1003typedef struct pj_stun_empty_attr pj_stun_use_candidate_attr; 
     1004 
     1005/** 
     1006 * This structure describes STUN XOR-INTERNAL-ADDRESS attribute from 
     1007 * draft-wing-behave-nat-control-stun-usage-00. 
     1008 * This attribute MUST be present in a Binding Response and may be used 
     1009 * in other responses as well.  This attribute is necessary to allow a 
     1010 * STUN client to 'walk backwards' and communicate directly with all of 
     1011 * the STUN-aware NATs along the path. 
     1012 */ 
     1013typedef pj_stun_generic_ip_addr_attr pj_stun_xor_internal_addr_attr; 
    9381014 
    9391015/** 
     
    9871063 * @param pool          Pool to create the STUN message. 
    9881064 * @param msg_type      The 14bit message type. 
     1065 * @param magic         Magic value to be put to the mesage; for requests, 
     1066 *                      the value should be PJ_STUN_MAGIC. 
    9891067 * @param tsx_id        Optional transaction ID, or NULL to let the 
    9901068 *                      function generates a random transaction ID. 
     
    9951073PJ_DECL(pj_status_t) pj_stun_msg_create(pj_pool_t *pool, 
    9961074                                        unsigned msg_type, 
     1075                                        pj_uint32_t magic, 
    9971076                                        const pj_uint8_t tsx_id[12], 
    9981077                                        pj_stun_msg **p_msg); 
     1078 
     1079 
     1080/** 
     1081 * Add STUN attribute to STUN message. 
     1082 * 
     1083 * @param msg           The STUN message. 
     1084 * @param attr          The STUN attribute to be added to the message. 
     1085 * 
     1086 * @return              PJ_SUCCESS on success, or PJ_ETOOMANY if there are 
     1087 *                      already too many attributes in the message. 
     1088 */ 
     1089PJ_DECL(pj_status_t) pj_stun_msg_add_attr(pj_stun_msg *msg, 
     1090                                          pj_stun_attr_hdr *attr); 
     1091 
    9991092 
    10001093/** 
     
    10921185 * @param pool          The pool to allocate memory from. 
    10931186 * @param attr_type     Attribute type. 
    1094  * @param ip_addr       IP address, in host byte order. 
    1095  * @param port          Port number, in host byte order. 
     1187 * @param xor_ed        If non-zero, the port and address will be XOR-ed 
     1188 *                      with magic, to make the XOR-MAPPED-ADDRESS attribute. 
     1189 * @param addr_len      Length of \a addr parameter. 
     1190 * @param addr          A pj_sockaddr_in or pj_sockaddr_in6 structure. 
    10961191 * @param p_attr        Pointer to receive the attribute. 
    10971192 * 
     
    11001195PJ_DECL(pj_status_t)  
    11011196pj_stun_generic_ip_addr_attr_create(pj_pool_t *pool, 
    1102                                     int attr_type, 
    1103                                     pj_uint32_t ip_addr, 
    1104                                     int port, 
     1197                                    int attr_type,  
     1198                                    pj_bool_t xor_ed, 
     1199                                    unsigned addr_len, 
     1200                                    const pj_sockaddr_t *addr, 
    11051201                                    pj_stun_generic_ip_addr_attr **p_attr); 
    11061202 
Note: See TracChangeset for help on using the changeset viewer.