Changeset 1002 for pjproject/trunk/pjlib-util/src/pjstun-srv/server_main.c
- Timestamp:
- Feb 26, 2007 2:33:14 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjstun-srv/server_main.c
r996 r1002 52 52 pj_uint32_t msg_type = req_msg->hdr.type; 53 53 pj_stun_msg *response; 54 pj_stun_error_code_attr *err_attr; 55 pj_status_t status; 56 57 /* Create response or error response */ 58 if (err_code) 59 msg_type |= PJ_STUN_ERROR_RESPONSE_BIT; 60 else 61 msg_type |= PJ_STUN_RESPONSE_BIT; 62 63 status = pj_stun_msg_create(pool, msg_type, req_msg->hdr.magic, 64 req_msg->hdr.tsx_id, &response); 65 if (status != PJ_SUCCESS) { 54 pj_status_t status; 55 56 status = pj_stun_msg_create_response(pool, req_msg, err_code, NULL, 57 &response); 58 if (status != PJ_SUCCESS) 66 59 return status; 67 }68 69 /* Add error code attribute */70 if (err_code) {71 status = pj_stun_error_code_attr_create(pool, err_code, NULL,72 &err_attr);73 if (status != PJ_SUCCESS) {74 return status;75 }76 77 pj_stun_msg_add_attr(response, &err_attr->hdr);78 }79 60 80 61 /* Add unknown_attribute attributes if err_code is 420 */ … … 111 92 tx_pkt_len = sizeof(svc->tx_pkt); 112 93 status = pj_stun_msg_encode(msg, svc->tx_pkt, tx_pkt_len, 0, 113 &tx_pkt_len);94 NULL, &tx_pkt_len); 114 95 if (status != PJ_SUCCESS) 115 96 return status; … … 224 205 struct service *svc = (struct service *) pj_ioqueue_get_user_data(key); 225 206 pj_pool_t *pool = NULL; 226 pj_stun_msg *rx_msg; 227 unsigned err_code; 228 unsigned uattr_cnt; 229 pj_uint16_t uattr_types[16]; 207 pj_stun_msg *rx_msg, *response; 230 208 char dump[512]; 231 209 pj_status_t status; … … 236 214 pool = pj_pool_create(&server.cp.factory, "service", 4000, 4000, NULL); 237 215 238 err_code = 0;239 uattr_cnt = PJ_ARRAY_SIZE(uattr_types);240 216 rx_msg = NULL; 241 217 status = pj_stun_msg_decode(pool, svc->rx_pkt, bytes_read, 0, &rx_msg, 242 NULL, & err_code, &uattr_cnt, uattr_types);218 NULL, &response); 243 219 if (status != PJ_SUCCESS) { 244 220 server_perror(THIS_FILE, "STUN msg_decode() error", status); 245 if (err_code != 0 && rx_msg && PJ_STUN_IS_REQUEST(rx_msg->hdr.type)) { 246 err_respond(svc, pool, rx_msg, err_code, 247 uattr_cnt, uattr_types); 221 if (response) { 222 send_msg(svc, response); 248 223 } 249 224 goto next_read;
Note: See TracChangeset
for help on using the changeset viewer.