Changeset 1154 for pjproject/trunk
- Timestamp:
- Apr 5, 2007 10:28:01 PM (18 years ago)
- Location:
- pjproject/trunk/pjnath
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/include/pjnath/errno.h
r1141 r1154 160 160 */ 161 161 #define PJNATH_EICEINCANDSDP (PJNATH_ERRNO_START+91) /* 370091 */ 162 162 /** 163 * @hideinitializer 164 * No host candidate associated with srflx. This error occurs when 165 * a server reflexive candidate is added without the matching 166 * host candidate. 167 */ 168 #define PJNATH_EICENOHOSTCAND (PJNATH_ERRNO_START+92) /* 370092 */ 163 169 164 170 -
pjproject/trunk/pjnath/include/pjnath/stun_msg.h
r1151 r1154 990 990 typedef struct pj_stun_uint_attr pj_stun_timer_val_attr; 991 991 992 /** 993 * This describes ICE-CONTROLLING attribute. 994 */ 995 typedef struct pj_stun_uint64_attr pj_stun_ice_controlling_attr; 996 997 /** 998 * This describes ICE-CONTROLLED attribute. 999 */ 1000 typedef struct pj_stun_uint64_attr pj_stun_ice_controlled_attr; 992 1001 993 1002 /** -
pjproject/trunk/pjnath/src/pjnath/errno.c
r1150 r1154 60 60 PJ_BUILD_ERR( PJNATH_EICEMISSINGSDP, "Missing ICE SDP attribute"), 61 61 PJ_BUILD_ERR( PJNATH_EICEINCANDSDP, "Invalid SDP \"candidate\" attribute"), 62 PJ_BUILD_ERR( PJNATH_EICENOHOSTCAND, "No host candidate associated with srflx"), 62 63 63 64 }; -
pjproject/trunk/pjnath/src/pjnath/ice_session.c
r1152 r1154 61 61 static const char *role_names[] = 62 62 { 63 "Unknown", 63 64 "Controlled", 64 65 "Controlling" … … 851 852 * is sorted. 852 853 */ 853 static void prune_checklist(pj_ice_sess *ice, pj_ice_sess_checklist *clist) 854 static pj_status_t prune_checklist(pj_ice_sess *ice, 855 pj_ice_sess_checklist *clist) 854 856 { 855 857 unsigned i; … … 865 867 * candidate pairs, called the check list for that media stream. 866 868 */ 869 /* First replace SRFLX candidates with their base */ 870 for (i=0; i<clist->count; ++i) { 871 pj_ice_sess_cand *srflx = clist->checks[i].lcand; 872 873 if (clist->checks[i].lcand->type == PJ_ICE_CAND_TYPE_SRFLX) { 874 /* Find the base for this candidate */ 875 unsigned j; 876 for (j=0; j<ice->lcand_cnt; ++j) { 877 pj_ice_sess_cand *host = &ice->lcand[j]; 878 879 if (host->type != PJ_ICE_CAND_TYPE_HOST) 880 continue; 881 882 if (sockaddr_cmp(&srflx->base_addr, &host->addr) == 0) { 883 /* Replace this SRFLX with its BASE */ 884 clist->checks[i].lcand = host; 885 break; 886 } 887 } 888 889 if (j==ice->lcand_cnt) { 890 /* Host candidate not found this this srflx! */ 891 LOG4((ice->obj_name, 892 "Base candidate %s:%d not found for srflx candidate %d", 893 pj_inet_ntoa(srflx->base_addr.ipv4.sin_addr), 894 pj_ntohs(srflx->base_addr.ipv4.sin_port), 895 GET_LCAND_ID(clist->checks[i].lcand))); 896 return PJNATH_EICENOHOSTCAND; 897 } 898 } 899 } 900 901 /* Next remove a pair if its local and remote candidates are identical 902 * to the local and remote candidates of a pair higher up on the priority 903 * list 904 */ 867 905 for (i=0; i<clist->count; ++i) { 868 906 pj_ice_sess_cand *licand = clist->checks[i].lcand; 869 907 pj_ice_sess_cand *ricand = clist->checks[i].rcand; 870 const pj_sockaddr *liaddr;871 908 unsigned j; 872 873 if (licand->type == PJ_ICE_CAND_TYPE_SRFLX)874 liaddr = &licand->base_addr;875 else876 liaddr = &licand->addr;877 909 878 910 for (j=i+1; j<clist->count;) { 879 911 pj_ice_sess_cand *ljcand = clist->checks[j].lcand; 880 912 pj_ice_sess_cand *rjcand = clist->checks[j].rcand; 881 const pj_sockaddr *ljaddr; 882 883 if (ljcand->type == PJ_ICE_CAND_TYPE_SRFLX) 884 ljaddr = &ljcand->base_addr; 885 else 886 ljaddr = &ljcand->addr; 887 888 if (ricand == rjcand && 889 sockaddr_cmp(liaddr, ljaddr) == SOCKADDR_EQUAL) 890 { 913 914 if ((licand == ljcand) && (ricand == rjcand)) { 891 915 /* Found duplicate, remove it */ 892 916 char buf[CHECK_NAME_LEN]; … … 905 929 } 906 930 } 931 932 return PJ_SUCCESS; 907 933 } 908 934 … … 1125 1151 timer_data *td; 1126 1152 unsigned i, j; 1153 pj_status_t status; 1127 1154 1128 1155 PJ_ASSERT_RETURN(ice && rem_ufrag && rem_passwd && rcand_cnt && rcand, … … 1175 1202 pj_ice_sess_check *chk = &clist->checks[clist->count]; 1176 1203 1177 if (clist->count > PJ_ICE_MAX_CHECKS) {1204 if (clist->count >= PJ_ICE_MAX_CHECKS) { 1178 1205 pj_mutex_unlock(ice->mutex); 1179 1206 return PJ_ETOOMANY; … … 1184 1211 * and have the same IP address version. 1185 1212 */ 1186 if ( lcand->comp_id != rcand->comp_id||1187 lcand->addr.addr.sa_family != rcand->addr.addr.sa_family)1213 if ((lcand->comp_id != rcand->comp_id) || 1214 (lcand->addr.addr.sa_family != rcand->addr.addr.sa_family)) 1188 1215 { 1189 1216 continue; … … 1205 1232 1206 1233 /* Prune the checklist */ 1207 prune_checklist(ice, clist); 1234 status = prune_checklist(ice, clist); 1235 if (status != PJ_SUCCESS) { 1236 pj_mutex_unlock(ice->mutex); 1237 return status; 1238 } 1208 1239 1209 1240 /* Init timer entry in the checklist. Initially the timer ID is FALSE … … 1466 1497 /* Pickup the first pair for component 1. */ 1467 1498 for (i=0; i<clist->count; ++i) { 1468 if (clist->checks[ 0].lcand->comp_id == 1)1499 if (clist->checks[i].lcand->comp_id == 1) 1469 1500 break; 1470 1501 } … … 1887 1918 } 1888 1919 1920 /* Handle the case when request comes before answer is received. 1921 * We need to put credential in the response, and since we haven't 1922 * got the response, copy the username from the request. 1923 */ 1924 if (ice->rcand_cnt == 0) { 1925 pj_stun_string_attr *uname_attr; 1926 1927 uname_attr = (pj_stun_string_attr*) 1928 pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_USERNAME, 0); 1929 pj_assert(uname_attr != NULL); 1930 pj_strdup(ice->pool, &ice->rx_uname, &uname_attr->value); 1931 } 1889 1932 1890 1933 /* … … 2090 2133 */ 2091 2134 pj_bool_t complete; 2135 unsigned j; 2136 2137 /* If this check is nominated, scan the valid_list for the 2138 * same check and update the nominated flag. A controlled 2139 * agent might have finished the check earlier. 2140 */ 2141 if (rcheck->use_candidate) { 2142 for (j=0; j<ice->valid_list.count; ++j) { 2143 pj_ice_sess_check *vc = &ice->valid_list.checks[j]; 2144 if (vc->lcand == c->lcand && vc->rcand == c->rcand) { 2145 vc->nominated = PJ_TRUE; 2146 } 2147 } 2148 } 2092 2149 2093 2150 LOG5((ice->obj_name, "Triggered check for check %d not performed " … … 2208 2265 PJ_STUN_IS_DATAGRAM, 2209 2266 NULL, src_addr, src_addr_len); 2267 if (status != PJ_SUCCESS) { 2268 char errmsg[PJ_ERR_MSG_SIZE]; 2269 pj_strerror(status, errmsg, sizeof(errmsg)); 2270 LOG4((ice->obj_name, "Error processing incoming message: %s", 2271 errmsg)); 2272 } 2210 2273 } else { 2211 2274 (*ice->cb.on_rx_data)(ice, comp_id, pkt, pkt_size, -
pjproject/trunk/pjnath/src/pjnath/ice_strans.c
r1141 r1154 462 462 if (status == PJ_SUCCESS) { 463 463 if (ice_st->ice==NULL || 464 pj_memcmp(comp->pkt+8, comp->ka_tsx_id, 12) == 0) 464 (comp->stun_sess && 465 pj_memcmp(comp->pkt+8, comp->ka_tsx_id, 12) == 0)) 465 466 { 466 467 status = pj_stun_session_on_rx_pkt(comp->stun_sess, comp->pkt, … … 469 470 &comp->src_addr, 470 471 comp->src_addr_len); 471 } else {472 } else if (ice_st->ice) { 472 473 PJ_TODO(DISTINGUISH_BETWEEN_LOCAL_AND_RELAY); 473 474 … … 482 483 &comp->src_addr, 483 484 comp->src_addr_len); 485 } else { 486 /* This must have been a very late STUN reponse */ 484 487 } 485 488 } else { -
pjproject/trunk/pjnath/src/pjnath/stun_session.c
r1152 r1154 812 812 tdata = tsx_lookup(sess, msg); 813 813 if (tdata == NULL) { 814 PJ_LOG( 4,(SNAME(sess),814 PJ_LOG(5,(SNAME(sess), 815 815 "Transaction not found, response silently discarded")); 816 816 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.