Changeset 2234
- Timestamp:
- Aug 22, 2008 5:46:33 PM (16 years ago)
- Location:
- pjproject/trunk/pjnath
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/include/pjnath/stun_msg.h
r2044 r2234 291 291 PJ_STUN_ATTR_LIFETIME = 0x000D,/**< TURN LIFETIME attr. */ 292 292 PJ_STUN_ATTR_MAGIC_COOKIE = 0x000F,/**< MAGIC-COOKIE attr (deprec)*/ 293 PJ_STUN_ATTR_BANDWIDTH = 0x0010,/**< TURN BANDWIDTH attr.*/293 PJ_STUN_ATTR_BANDWIDTH = 0x0010,/**< TURN BANDWIDTH (deprec) */ 294 294 PJ_STUN_ATTR_PEER_ADDR = 0x0012,/**< TURN PEER-ADDRESS attr. */ 295 295 PJ_STUN_ATTR_DATA = 0x0013,/**< DATA attribute. */ 296 296 PJ_STUN_ATTR_REALM = 0x0014,/**< REALM attribute. */ 297 297 PJ_STUN_ATTR_NONCE = 0x0015,/**< NONCE attribute. */ 298 PJ_STUN_ATTR_RELAY _ADDR = 0x0016,/**< RELAY-ADDRESS attribute.*/298 PJ_STUN_ATTR_RELAYED_ADDR = 0x0016,/**< RELAYED-ADDRESS attribute.*/ 299 299 PJ_STUN_ATTR_REQ_ADDR_TYPE = 0x0017,/**< REQUESTED-ADDRESS-TYPE */ 300 300 PJ_STUN_ATTR_REQ_PROPS = 0x0018,/**< REQUESTED-PROPS */ … … 306 306 PJ_STUN_ATTR_PRIORITY = 0x0024,/**< PRIORITY */ 307 307 PJ_STUN_ATTR_USE_CANDIDATE = 0x0025,/**< USE-CANDIDATE */ 308 PJ_STUN_ATTR_ XOR_INTERNAL_ADDR = 0x0026,/**< XOR-INTERNAL-ADDRESS*/308 PJ_STUN_ATTR_ICMP = 0x0030,/**< ICMP (TURN) */ 309 309 310 310 PJ_STUN_ATTR_END_MANDATORY_ATTR, … … 312 312 PJ_STUN_ATTR_START_EXTENDED_ATTR= 0x8021, 313 313 314 PJ_STUN_ATTR_S ERVER = 0x8022,/**< SERVERattribute. */314 PJ_STUN_ATTR_SOFTWARE = 0x8022,/**< SOFTWARE attribute. */ 315 315 PJ_STUN_ATTR_ALTERNATE_SERVER = 0x8023,/**< ALTERNATE-SERVER. */ 316 316 PJ_STUN_ATTR_REFRESH_INTERVAL = 0x8024,/**< REFRESH-INTERVAL. */ … … 346 346 PJ_STUN_SC_STALE_NONCE = 438, /**< Stale Nonce */ 347 347 PJ_STUN_SC_TRANSITIONING = 439, /**< Transitioning. */ 348 PJ_STUN_SC_WRONG_CREDENTIALS = 441, /**< TURN Wrong Credentials */ 348 349 PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO = 442, /**< Unsupported Transport or 349 350 Protocol (TURN) */ … … 515 516 /** 516 517 * This structure represents generic STUN string attributes, such as STUN 517 * USERNAME, PASSWORD, SERVER, REALM, and NONCE attributes. Note that for REALM and 518 * NONCE attributes, the text MUST be quoted with. 518 * USERNAME, PASSWORD, SOFTWARE, REALM, and NONCE attributes. 519 519 */ 520 520 typedef struct pj_stun_string_attr … … 740 740 741 741 /** 742 * This describes STUN SERVER attribute. 743 * The server attribute contains a textual description of the software 744 * being used by the server, including manufacturer and version number. 745 * The attribute has no impact on operation of the protocol, and serves 746 * only as a tool for diagnostic and debugging purposes. The value of 747 * SERVER is variable length. 748 */ 749 typedef struct pj_stun_string_attr pj_stun_server_attr; 742 * This describes STUN SOFTWARE attribute. 743 * The SOFTWARE attribute contains a textual description of the software 744 * being used by the agent sending the message. It is used by clients 745 * and servers. Its value SHOULD include manufacturer and version 746 * number. */ 747 typedef struct pj_stun_string_attr pj_stun_software_attr; 750 748 751 749 … … 933 931 934 932 /** 935 * This describes the STUN RELAY -ADDRESS attribute.936 * The RELAY -ADDRESS is present in Allocate responses. It specifies the933 * This describes the STUN RELAYED-ADDRESS attribute. 934 * The RELAYED-ADDRESS is present in Allocate responses. It specifies the 937 935 * address and port that the server allocated to the client. It is 938 936 * encoded in the same way as XOR-MAPPED-ADDRESS. 939 937 */ 940 typedef struct pj_stun_sockaddr_attr pj_stun_relay _addr_attr;938 typedef struct pj_stun_sockaddr_attr pj_stun_relayed_addr_attr; 941 939 942 940 … … 965 963 * #PJ_STUN_SET_PROP_TYPE(). 966 964 * 967 * This attribute allows the client to request certain properties for968 * the relayed transport address that is allocated by the server. The969 * a ttribute is 32 bits long. Its format is:965 * This attribute allows the client to request that the allocation have 966 * certain properties, and by the server to indicate which properties 967 * are supported. The attribute is 32 bits long. Its format is: 970 968 971 969 \verbatim … … 982 980 * desired property. The rest of the attribute is RFFU (Reserved For 983 981 * Future Use) and MUST be set to 0 on transmission and ignored on 984 * reception. The values of the "Prop-type" field are: 985 * 986 * 0x00 (Reserved) 987 * 0x01 Even port number 988 * 0x02 Pair of ports 982 * reception. 983 * 984 * The "Prop-type" field is formatted as follows: 985 986 \verbatim 987 988 0 1 2 3 4 5 6 7 989 +-+-+-+-+-+-+-+-+ 990 |E|R|P| | 991 +-+-+-+-+-+-+-+-+ 992 993 \endverbatim 994 995 The bits in "Prop-type" are: 996 997 E: If 1, the port number for the relayed-transport-address must be 998 even. If 0, the port number can be even or odd. 999 1000 R: If 1, the server must reserve the next highest port for a 1001 subsequent allocation. If 0, no such reservation is requested. 1002 If the client sets the R bit to 1, it MUST also set the E bit to 1 1003 (however, the E bit may be 1 when the R bit is 0). 1004 1005 P: If 1, the allocation must be a Preserving allocation. If 0, the 1006 allocation can be either Preserving or Non-Preserving. 1007 989 1008 */ 990 1009 typedef struct pj_stun_uint_attr pj_stun_req_props_attr; … … 1091 1110 1092 1111 /** 1093 * This structure describes STUN XOR-INTERNAL-ADDRESS attribute from1094 * draft-wing-behave-nat-control-stun-usage-00.1095 * This attribute MUST be present in a Binding Response and may be used1096 * in other responses as well. This attribute is necessary to allow a1097 * STUN client to 'walk backwards' and communicate directly with all of1098 * the STUN-aware NATs along the path.1099 */1100 typedef pj_stun_sockaddr_attr pj_stun_xor_internal_addr_attr;1101 1102 /**1103 1112 * This describes the STUN TIMER-VAL attribute. 1104 1113 * The TIMER-VAL attribute is used only in conjunction with the Set … … 1117 1126 */ 1118 1127 typedef struct pj_stun_uint64_attr pj_stun_ice_controlled_attr; 1128 1129 /** 1130 * This describes TURN ICMP attribute 1131 */ 1132 typedef struct pj_stun_uint_attr pj_stun_icmp_attr; 1119 1133 1120 1134 /** -
pjproject/trunk/pjnath/include/pjnath/turn_session.h
r1988 r2234 237 237 /** 238 238 * The requested BANDWIDTH. Default is zero to not request any 239 * specific bandwidth. 239 * specific bandwidth. Note that this attribute has been deprecated 240 * after TURN-08 draft, hence application should only use this 241 * attribute when talking to TURN-07 or older version. 240 242 */ 241 243 int bandwidth; … … 582 584 * a ChannelData packet. 583 585 * @param pkt_len The length of the packet. 586 * @param parsed_len Optional argument to receive the number of parsed 587 * or processed data from the packet. 584 588 * 585 589 * @return The function may return non-PJ_SUCCESS if it receives … … 589 593 PJ_DECL(pj_status_t) pj_turn_session_on_rx_pkt(pj_turn_session *sess, 590 594 void *pkt, 591 unsigned pkt_len); 595 unsigned pkt_len, 596 unsigned *parsed_len); 592 597 593 598 -
pjproject/trunk/pjnath/include/pjnath/types.h
r1988 r2234 98 98 99 99 This version of PJNATH implements the following STUN-bis draft: 100 - <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-behave-rfc3489bis-1 5.txt">101 <B>draft-ietf-behave-rfc3489bis-1 5</b></A>: Session Traversal100 - <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-behave-rfc3489bis-18.txt"> 101 <B>draft-ietf-behave-rfc3489bis-18</b></A>: Session Traversal 102 102 Utilities for (NAT) (STUN), 103 103 … … 110 110 This version of PJNATH implements both TCP and UDP client transport and it 111 111 complies with the following TURN draft: 112 - <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-behave-turn-0 7.txt">113 <B>draft-ietf-behave-turn-0 7</B></A>: Obtaining Relay Addresses112 - <A HREF="http://www.ietf.org/internet-drafts/draft-ietf-behave-turn-09.txt"> 113 <B>draft-ietf-behave-turn-09</B></A>: Obtaining Relay Addresses 114 114 from Simple Traversal Underneath NAT (STUN) 115 115 -
pjproject/trunk/pjnath/src/pjnath-test/server.c
r2015 r2234 310 310 pj_stun_msg_add_uint_attr(pool, resp, PJ_STUN_ATTR_LIFETIME, lifetime); 311 311 if (lifetime != 0) { 312 /* Add RELAY -ADDRESS */313 pj_stun_msg_add_sockaddr_attr(pool, resp, PJ_STUN_ATTR_RELAY _ADDR, PJ_TRUE, &alloc->alloc_addr,312 /* Add RELAYED-ADDRESS */ 313 pj_stun_msg_add_sockaddr_attr(pool, resp, PJ_STUN_ATTR_RELAYED_ADDR, PJ_TRUE, &alloc->alloc_addr, 314 314 pj_sockaddr_get_len(&alloc->alloc_addr)); 315 315 /* Add XOR-MAPPED-ADDRESS */ -
pjproject/trunk/pjnath/src/pjnath-test/stun.c
r2041 r2234 695 695 (pj_uint8_t*)v->tsx_id, &msg); 696 696 697 pj_stun_msg_add_string_attr(pool, msg, PJ_STUN_ATTR_S ERVER,697 pj_stun_msg_add_string_attr(pool, msg, PJ_STUN_ATTR_SOFTWARE, 698 698 pj_cstr(&s1, "test vector")); 699 699 -
pjproject/trunk/pjnath/src/pjnath/stun_msg.c
r2056 r2234 67 67 { PJ_STUN_SC_STALE_NONCE, "Stale Nonce"}, 68 68 { PJ_STUN_SC_TRANSITIONING, "Active Destination Already Set"}, 69 { PJ_STUN_SC_WRONG_CREDENTIALS, "Wrong Credentials"}, 69 70 { PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO, "Unsupported Transport Protocol"}, 70 71 { PJ_STUN_SC_INVALID_IP_ADDR, "Invalid IP Address"}, … … 310 311 { 311 312 /* PJ_STUN_ATTR_RELAY_ADDRESS, */ 312 "RELAY -ADDRESS",313 "RELAYED-ADDRESS", 313 314 &decode_xored_sockaddr_attr, 314 315 &encode_sockaddr_attr, … … 421 422 }, 422 423 { 423 /* PJ_STUN_ATTR_XOR_INTERNAL_ADDR, */ 424 "XOR-INTERNAL-ADDRESS", 425 &decode_xored_sockaddr_attr, 426 &encode_sockaddr_attr, 427 &clone_sockaddr_attr 424 /* ID 0x0026 is not assigned */ 425 NULL, 426 NULL, 427 NULL, 428 NULL 429 }, 430 { 431 /* ID 0x0027 is not assigned */ 432 NULL, 433 NULL, 434 NULL, 435 NULL 436 }, 437 { 438 /* ID 0x0028 is not assigned */ 439 NULL, 440 NULL, 441 NULL, 442 NULL 443 }, 444 { 445 /* ID 0x0029 is not assigned */ 446 NULL, 447 NULL, 448 NULL, 449 NULL 450 }, 451 { 452 /* ID 0x002a is not assigned */ 453 NULL, 454 NULL, 455 NULL, 456 NULL 457 }, 458 { 459 /* ID 0x002b is not assigned */ 460 NULL, 461 NULL, 462 NULL, 463 NULL 464 }, 465 { 466 /* ID 0x002c is not assigned */ 467 NULL, 468 NULL, 469 NULL, 470 NULL 471 }, 472 { 473 /* ID 0x002d is not assigned */ 474 NULL, 475 NULL, 476 NULL, 477 NULL 478 }, 479 { 480 /* ID 0x002e is not assigned */ 481 NULL, 482 NULL, 483 NULL, 484 NULL 485 }, 486 { 487 /* ID 0x002f is not assigned */ 488 NULL, 489 NULL, 490 NULL, 491 NULL 492 }, 493 { 494 /* PJ_STUN_ATTR_ICMP, */ 495 "ICMP", 496 &decode_uint_attr, 497 &encode_uint_attr, 498 &clone_uint_attr 428 499 }, 429 500 … … 448 519 }, 449 520 { 450 /* PJ_STUN_ATTR_S ERVER, */451 "S ERVER",521 /* PJ_STUN_ATTR_SOFTWARE, */ 522 "SOFTWARE", 452 523 &decode_string_attr, 453 524 &encode_string_attr, -
pjproject/trunk/pjnath/src/pjnath/stun_msg_dump.c
r1852 r2234 73 73 case PJ_STUN_ATTR_REFLECTED_FROM: 74 74 case PJ_STUN_ATTR_PEER_ADDR: 75 case PJ_STUN_ATTR_RELAY _ADDR:75 case PJ_STUN_ATTR_RELAYED_ADDR: 76 76 case PJ_STUN_ATTR_XOR_MAPPED_ADDR: 77 77 case PJ_STUN_ATTR_XOR_REFLECTED_FROM: 78 case PJ_STUN_ATTR_XOR_INTERNAL_ADDR:79 78 case PJ_STUN_ATTR_ALTERNATE_SERVER: 80 79 { … … 123 122 case PJ_STUN_ATTR_FINGERPRINT: 124 123 case PJ_STUN_ATTR_REFRESH_INTERVAL: 124 case PJ_STUN_ATTR_ICMP: 125 125 { 126 126 const pj_stun_uint_attr *attr; … … 139 139 case PJ_STUN_ATTR_REALM: 140 140 case PJ_STUN_ATTR_NONCE: 141 case PJ_STUN_ATTR_S ERVER:141 case PJ_STUN_ATTR_SOFTWARE: 142 142 { 143 143 const pj_stun_string_attr *attr; -
pjproject/trunk/pjnath/src/pjnath/stun_session.c
r1993 r2234 217 217 pj_str_t realm, username, nonce, auth_key; 218 218 219 /* The server SHOULD include a S ERVERattribute in all responses */219 /* The server SHOULD include a SOFTWARE attribute in all responses */ 220 220 if (sess->srv_name.slen && PJ_STUN_IS_RESPONSE(msg->hdr.type)) { 221 pj_stun_msg_add_string_attr(pool, msg, PJ_STUN_ATTR_S ERVER,221 pj_stun_msg_add_string_attr(pool, msg, PJ_STUN_ATTR_SOFTWARE, 222 222 &sess->srv_name); 223 223 } -
pjproject/trunk/pjnath/src/pjnath/stun_transaction.c
r1988 r2234 252 252 unsigned pkt_len) 253 253 { 254 pj_status_t status; 255 254 256 PJ_ASSERT_RETURN(tsx && pkt && pkt_len, PJ_EINVAL); 255 257 PJ_ASSERT_RETURN(tsx->retransmit_timer.id == 0, PJ_EBUSY); … … 262 264 tsx->require_retransmit = retransmit; 263 265 266 /* For TCP, schedule timeout timer after PJ_STUN_TIMEOUT_VALUE. 267 * Since we don't have timeout timer, simulate this by using 268 * retransmit timer. 269 */ 270 if (!retransmit) { 271 unsigned timeout; 272 273 pj_assert(tsx->retransmit_timer.id == 0); 274 tsx->transmit_count = PJ_STUN_MAX_TRANSMIT_COUNT; 275 276 timeout = tsx->rto_msec * 16; 277 tsx->retransmit_time.sec = timeout / 1000; 278 tsx->retransmit_time.msec = timeout % 1000; 279 280 /* Schedule timer first because when send_msg() failed we can 281 * cancel it (as opposed to when schedule_timer() failed we cannot 282 * cancel transmission). 283 */; 284 status = pj_timer_heap_schedule(tsx->timer_heap, 285 &tsx->retransmit_timer, 286 &tsx->retransmit_time); 287 if (status != PJ_SUCCESS) { 288 tsx->retransmit_timer.id = 0; 289 return status; 290 } 291 } 292 264 293 /* Send the message */ 265 return tsx_transmit_msg(tsx); 294 status = tsx_transmit_msg(tsx); 295 if (status != PJ_SUCCESS) { 296 if (tsx->retransmit_timer.id != 0) { 297 pj_timer_heap_cancel(tsx->timer_heap, 298 &tsx->retransmit_timer); 299 tsx->retransmit_timer.id = 0; 300 } 301 return status; 302 } 303 304 return PJ_SUCCESS; 266 305 } 267 306 -
pjproject/trunk/pjnath/src/pjnath/turn_session.c
r2090 r2234 915 915 PJ_DEF(pj_status_t) pj_turn_session_on_rx_pkt(pj_turn_session *sess, 916 916 void *pkt, 917 unsigned pkt_len) 917 unsigned pkt_len, 918 unsigned *parsed_len) 918 919 { 919 920 pj_bool_t is_stun; … … 941 942 options |= PJ_STUN_IS_DATAGRAM; 942 943 status=pj_stun_session_on_rx_pkt(sess->stun, pkt, pkt_len, 943 options, NULL, NULL,944 options, NULL, parsed_len, 944 945 sess->srv_addr, 945 946 pj_sockaddr_get_len(sess->srv_addr)); 946 947 947 } else if (sess->cb.on_rx_data) { 948 949 /* This must be ChannelData. Only makes sense when on_rx_data() is 950 * implemented by application. 951 */ 948 } else { 949 /* This must be ChannelData. */ 952 950 pj_turn_channel_data cd; 953 951 struct peer *peer; 954 952 955 PJ_ASSERT_RETURN(pkt_len >= 4, PJ_ETOOSMALL); 956 957 /* Lookup peer */ 953 if (pkt_len < 4) { 954 if (parsed_len) *parsed_len = 0; 955 return PJ_ETOOSMALL; 956 } 957 958 /* Decode ChannelData packet */ 958 959 pj_memcpy(&cd, pkt, sizeof(pj_turn_channel_data)); 959 960 cd.ch_number = pj_ntohs(cd.ch_number); 960 961 cd.length = pj_ntohs(cd.length); 962 963 /* Check that size is sane */ 964 if (pkt_len < cd.length+sizeof(cd)) { 965 if (parsed_len) { 966 if (is_datagram) { 967 /* Discard the datagram */ 968 *parsed_len = pkt_len; 969 } else { 970 /* Insufficient fragment */ 971 *parsed_len = 0; 972 } 973 } 974 status = PJ_ETOOSMALL; 975 goto on_return; 976 } else { 977 if (parsed_len) { 978 *parsed_len = cd.length + sizeof(cd); 979 } 980 } 981 982 /* Lookup peer */ 961 983 peer = lookup_peer_by_chnum(sess, cd.ch_number); 962 984 if (!peer || !peer->bound) { … … 965 987 } 966 988 967 /* Check that size is correct, for UDP */968 if (pkt_len < cd.length+sizeof(cd)) {969 status = PJ_ETOOSMALL;970 goto on_return;971 }972 973 989 /* Notify application */ 974 (*sess->cb.on_rx_data)(sess, ((pj_uint8_t*)pkt)+sizeof(cd), 975 cd.length, &peer->addr, 976 pj_sockaddr_get_len(&peer->addr)); 977 978 status = PJ_SUCCESS; 979 980 } else { 981 /* This is ChannelData and application doesn't implement 982 * on_rx_data() callback. Just ignore the packet. 983 */ 990 if (sess->cb.on_rx_data) { 991 (*sess->cb.on_rx_data)(sess, ((pj_uint8_t*)pkt)+sizeof(cd), 992 cd.length, &peer->addr, 993 pj_sockaddr_get_len(&peer->addr)); 994 } 995 984 996 status = PJ_SUCCESS; 985 997 } … … 1078 1090 { 1079 1091 const pj_stun_lifetime_attr *lf_attr; 1080 const pj_stun_relay _addr_attr *raddr_attr;1092 const pj_stun_relayed_addr_attr *raddr_attr; 1081 1093 const pj_stun_sockaddr_attr *mapped_attr; 1082 1094 pj_str_t s; … … 1126 1138 * address family. 1127 1139 */ 1128 raddr_attr = (const pj_stun_relay _addr_attr*)1129 pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_RELAY _ADDR, 0);1140 raddr_attr = (const pj_stun_relayed_addr_attr*) 1141 pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_RELAYED_ADDR, 0); 1130 1142 if (raddr_attr == NULL && method==PJ_STUN_ALLOCATE_METHOD) { 1131 1143 on_session_fail(sess, method, PJNATH_EINSTUNMSG, … … 1342 1354 pj_turn_session *sess; 1343 1355 pj_stun_peer_addr_attr *peer_attr; 1356 pj_stun_icmp_attr *icmp; 1344 1357 pj_stun_data_attr *data_attr; 1345 1358 … … 1357 1370 pj_stun_get_method_name(msg->hdr.type))); 1358 1371 return PJ_EINVALIDOP; 1372 } 1373 1374 /* Check if there is ICMP attribute in the message */ 1375 icmp = (pj_stun_icmp_attr*) 1376 pj_stun_msg_find_attr(msg, PJ_STUN_ATTR_ICMP, 0); 1377 if (icmp != NULL) { 1378 /* This is a forwarded ICMP packet. Ignore it for now */ 1379 return PJ_SUCCESS; 1359 1380 } 1360 1381 -
pjproject/trunk/pjnath/src/pjnath/turn_sock.c
r2177 r2234 464 464 { 465 465 pj_turn_sock *turn_sock; 466 unsigned parsed_len; 466 467 pj_bool_t ret = PJ_TRUE; 467 468 … … 471 472 if (status == PJ_SUCCESS && turn_sock->sess) { 472 473 /* Report incoming packet to TURN session */ 473 PJ_TODO(REPORT_PARSED_LEN); 474 pj_turn_session_on_rx_pkt(turn_sock->sess, data, size); 474 parsed_len = (unsigned)size; 475 pj_turn_session_on_rx_pkt(turn_sock->sess, data, size, &parsed_len); 476 if (parsed_len < (unsigned)size) { 477 *remainder = size - parsed_len; 478 pj_memmove(data, ((char*)data)+parsed_len, *remainder); 479 } else { 480 *remainder = 0; 481 } 475 482 } else if (status != PJ_SUCCESS && 476 483 turn_sock->conn_type != PJ_TURN_TP_UDP) -
pjproject/trunk/pjnath/src/pjturn-srv/allocation.c
r1924 r2234 213 213 /* Add RELAYED-ADDRESS attribute */ 214 214 pj_stun_msg_add_sockaddr_attr(tdata->pool, tdata->msg, 215 PJ_STUN_ATTR_RELAY _ADDR, PJ_TRUE,215 PJ_STUN_ATTR_RELAYED_ADDR, PJ_TRUE, 216 216 &alloc->relay.hkey.addr, 217 217 pj_sockaddr_get_len(&alloc->relay.hkey.addr)); -
pjproject/trunk/pjnath/src/pjturn-srv/listener_udp.c
r1913 r2234 126 126 for (i=0; i<concurrency_cnt; ++i) { 127 127 pj_pool_t *rpool = pj_pool_create(srv->core.pf, "rop%p", 128 sizeof(struct read_op)+1000, 129 1000, NULL); 130 131 udp->read_op[i] = PJ_POOL_ZALLOC_T(rpool, struct read_op); 128 1000, 1000, NULL); 129 130 udp->read_op[i] = PJ_POOL_ZALLOC_T(pool, struct read_op); 132 131 udp->read_op[i]->pkt.pool = rpool; 133 132 -
pjproject/trunk/pjnath/src/pjturn-srv/server.c
r1929 r2234 552 552 } 553 553 554 /* Handle STUN Binding request */ 555 static void handle_binding_request(pj_turn_pkt *pkt, 556 unsigned options) 557 { 558 pj_stun_msg *request, *response; 559 pj_uint8_t pdu[200]; 560 pj_size_t len; 561 pj_status_t status; 562 563 /* Decode request */ 564 status = pj_stun_msg_decode(pkt->pool, pkt->pkt, pkt->len, options, 565 &request, NULL, NULL); 566 if (status != PJ_SUCCESS) 567 return; 568 569 /* Create response */ 570 status = pj_stun_msg_create_response(pkt->pool, request, 0, NULL, 571 &response); 572 if (status != PJ_SUCCESS) 573 return; 574 575 /* Add XOR-MAPPED-ADDRESS */ 576 pj_stun_msg_add_sockaddr_attr(pkt->pool, response, 577 PJ_STUN_ATTR_XOR_MAPPED_ADDR, 578 PJ_TRUE, 579 &pkt->src.clt_addr, 580 pkt->src_addr_len); 581 582 /* Encode */ 583 status = pj_stun_msg_encode(response, pdu, sizeof(pdu), 0, NULL, &len); 584 if (status != PJ_SUCCESS) 585 return; 586 587 /* Send response */ 588 pkt->transport->sendto(pkt->transport, pdu, len, 0, 589 &pkt->src.clt_addr, pkt->src_addr_len); 590 } 554 591 555 592 /* … … 616 653 } 617 654 655 /* Special handling for Binding Request. We won't give it to the 656 * STUN session since this request is not authenticated. 657 */ 658 if (pkt->pkt[1] == 1) { 659 handle_binding_request(pkt, options); 660 return; 661 } 662 618 663 /* Hand over processing to STUN session. This will trigger 619 664 * on_rx_stun_request() callback to be called if the STUN
Note: See TracChangeset
for help on using the changeset viewer.