Ignore:
Timestamp:
May 15, 2007 10:42:56 AM (17 years ago)
Author:
bennylp
Message:

Fixed several STUN bugs: USERNAME, REALM etc are not allowed in the response, retransmission timer calculation bug, etc.

File:
1 edited

Legend:

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

    r1154 r1275  
    133133#define PJ_STUN_IS_REQUEST(msg_type)    (((msg_type) & 0x0110) == 0x0000) 
    134134 
     135/** 
     136 * Determine if the message type is a successful response. 
     137 */ 
     138#define PJ_STUN_IS_SUCCESS_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0100) 
     139 
     140/** 
     141 * The response bit in the message type. 
     142 */ 
     143#define PJ_STUN_RESPONSE_BIT            (0x0100) 
     144 
     145/** 
     146 * Determine if the message type is an error response. 
     147 */ 
     148#define PJ_STUN_IS_ERROR_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0110) 
     149 
     150/** 
     151 * The error response bit in the message type. 
     152 */ 
     153#define PJ_STUN_ERROR_RESPONSE_BIT      (0x0110) 
    135154 
    136155/** 
    137156 * Determine if the message type is a response. 
    138157 */ 
    139 #define PJ_STUN_IS_SUCCESS_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0100) 
    140  
    141  
    142 /** 
    143  * The response bit in the message type. 
    144  */ 
    145 #define PJ_STUN_RESPONSE_BIT            (0x0100) 
    146  
    147 /** 
    148  * Determine if the message type is an error response. 
    149  */ 
    150 #define PJ_STUN_IS_ERROR_RESPONSE(msg_type) (((msg_type) & 0x0110) == 0x0110) 
    151  
    152  
    153 /** 
    154  * The error response bit in the message type. 
    155  */ 
    156 #define PJ_STUN_ERROR_RESPONSE_BIT      (0x0110) 
    157  
     158#define PJ_STUN_IS_RESPONSE(msg_type) (((msg_type) & 0x0100) == 0x0100) 
    158159 
    159160/** 
     
    11491150 * sent to remote destination. This function will take care about  
    11501151 * calculating the MESSAGE-INTEGRITY digest as well as FINGERPRINT 
    1151  * value. 
    1152  * 
    1153  * If MESSAGE-INTEGRITY attribute is present, the function assumes 
    1154  * that application wants to include credential (short or long term) 
    1155  * in the message, and this function will calculate the HMAC digest 
    1156  * from the message using the supplied password in the parameter.  
    1157  * If REALM attribute is present, the HMAC digest is calculated as 
    1158  * long term credential, otherwise as short term credential. 
     1152 * value, if these attributes are present in the message. 
     1153 * 
     1154 * If application wants to apply credential to the message, it MUST 
     1155 * include a blank MESSAGE-INTEGRITY attribute in the message, as the 
     1156 * last attribute or the attribute before FINGERPRINT. This function will 
     1157 * calculate the HMAC digest from the message using  the supplied key in 
     1158 * the parameter. The key should be set to the password if short term  
     1159 * credential is used, or calculated from the MD5 hash of the realm,  
     1160 * username, and password using #pj_stun_create_key() if long term  
     1161 * credential is used. 
    11591162 * 
    11601163 * If FINGERPRINT attribute is present, this function will calculate 
    1161  * the FINGERPRINT CRC attribute for the message. 
     1164 * the FINGERPRINT CRC attribute for the message. The FINGERPRINT MUST 
     1165 * be added as the last attribute of the message. 
    11621166 * 
    11631167 * @param msg           The STUN message to be printed. Upon return, 
     
    11671171 * @param buf_size      Size of the buffer. 
    11681172 * @param options       Options, which currently must be zero. 
    1169  * @param password      Password to be used when credential is to be 
    1170  *                      included. This parameter MUST be specified when 
    1171  *                      the message contains MESSAGE-INTEGRITY attribute. 
     1173 * @param key           Authentication key to calculate MESSAGE-INTEGRITY 
     1174 *                      value. Application can create this key by using 
     1175 *                      #pj_stun_create_key() function. 
    11721176 * @param p_msg_len     Upon return, it will be filed with the size of  
    11731177 *                      the packet in bytes, or negative value on error. 
     
    11791183                                        unsigned buf_size, 
    11801184                                        unsigned options, 
    1181                                         const pj_str_t *password, 
     1185                                        const pj_str_t *key, 
    11821186                                        unsigned *p_msg_len); 
     1187 
     1188 
     1189/** 
     1190 * Create authentication key to be used for encoding the message with 
     1191 * MESSAGE-INTEGRITY. If short term credential is used (i.e. the realm 
     1192 * argument is NULL or empty), the key will be copied from the password. 
     1193 * If long term credential is used, the key will be calculated from the 
     1194 * MD5 hash of the realm, username, and password. 
     1195 * 
     1196 * @param pool          Pool to allocate memory for the key. 
     1197 * @param key           String to receive the key. 
     1198 * @param realm         The realm of the credential, if long term credential 
     1199 *                      is to be used. If short term credential is wanted, 
     1200 *                      application can put NULL or empty string here. 
     1201 * @param username      The username. 
     1202 * @param passwd        The clear text password. 
     1203 */ 
     1204PJ_DECL(void) pj_stun_create_key(pj_pool_t *pool, 
     1205                                 pj_str_t *key, 
     1206                                 const pj_str_t *realm, 
     1207                                 const pj_str_t *username, 
     1208                                 const pj_str_t *passwd); 
     1209 
     1210 
    11831211 
    11841212/** 
Note: See TracChangeset for help on using the changeset viewer.