- Timestamp:
- Nov 23, 2007 3:54:49 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/stun_simple_client.c
r1410 r1596 19 19 #include <pjlib-util/stun_simple.h> 20 20 #include <pjlib-util/errno.h> 21 #include <pj/log.h> 21 22 #include <pj/os.h> 22 23 #include <pj/pool.h> … … 26 27 27 28 28 enum { MAX_REQUEST = 3};29 static int stun_timer[] = {1 600, 1600, 1600 };29 enum { MAX_REQUEST = 4 }; 30 static int stun_timer[] = {1000, 1000, 1000, 1000 }; 30 31 31 32 #define THIS_FILE "stun_client.c" … … 131 132 132 133 for (pj_gettimeofday(&now), select_rc=1; 133 status==PJ_SUCCESS && select_rc ==1 && wait_resp>0134 status==PJ_SUCCESS && select_rc>=1 && wait_resp>0 134 135 && PJ_TIME_VAL_LT(now, next_tx); 135 136 pj_gettimeofday(&now)) … … 166 167 &addrlen); 167 168 168 --wait_resp; 169 170 if (status != PJ_SUCCESS) 171 continue; 169 if (status != PJ_SUCCESS) { 170 char errmsg[PJ_ERR_MSG_SIZE]; 171 172 PJ_LOG(4,(THIS_FILE, "recvfrom() error ignored: %s", 173 pj_strerror(status, errmsg,sizeof(errmsg)).ptr)); 174 175 /* Ignore non-PJ_SUCCESS status. 176 * It possible that other SIP entity is currently 177 * sending SIP request to us, and because SIP message 178 * is larger than STUN, we could get EMSGSIZE when 179 * we call recvfrom(). 180 */ 181 status = PJ_SUCCESS; 182 continue; 183 } 172 184 173 185 status = pjstun_parse_msg(recv_buf, len, &msg); 174 186 if (status != PJ_SUCCESS) { 175 continue; 176 } 177 187 char errmsg[PJ_ERR_MSG_SIZE]; 188 189 PJ_LOG(4,(THIS_FILE, "STUN parsing error ignored: %s", 190 pj_strerror(status, errmsg,sizeof(errmsg)).ptr)); 191 192 /* Also ignore non-successful parsing. This may not 193 * be STUN response at all. See the comment above. 194 */ 195 status = PJ_SUCCESS; 196 continue; 197 } 178 198 179 199 sock_idx = pj_ntohl(msg.hdr->tsx[2]); … … 189 209 continue; 190 210 } 211 212 /* From this part, we consider the packet as a valid STUN 213 * response for our request. 214 */ 215 --wait_resp; 191 216 192 217 if (pjstun_msg_find_attr(&msg, PJSTUN_ATTR_ERROR_CODE) != NULL) {
Note: See TracChangeset
for help on using the changeset viewer.