- Timestamp:
- Mar 3, 2007 2:16:36 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjstun-client/client_main.c
r1030 r1037 30 30 pj_timer_heap_t *th; 31 31 pj_stun_session *sess; 32 unsigned sess_options;33 32 pj_sock_t sock; 34 33 pj_thread_t *thread; … … 46 45 char *user_name; 47 46 char *password; 47 char *nonce; 48 48 pj_bool_t use_fingerprint; 49 49 } o; … … 181 181 stun_cb.on_request_complete = &on_request_complete; 182 182 183 status = pj_stun_session_create(g.endpt, NULL, &stun_cb, &g.sess); 184 pj_assert(status == PJ_SUCCESS); 185 186 if (o.realm) { 187 pj_str_t r, u, p; 188 189 if (o.user_name == NULL) { 190 printf("error: username must be specified\n"); 191 return PJ_EINVAL; 192 } 193 if (o.password == NULL) 194 o.password = ""; 195 g.sess_options = PJ_STUN_USE_LONG_TERM_CRED; 196 pj_stun_session_set_long_term_credential(g.sess, pj_cstr(&r, o.realm), 197 pj_cstr(&u, o.user_name), 198 pj_cstr(&p, o.password)); 199 puts("Using long term credential"); 200 } else if (o.user_name) { 201 pj_str_t u, p; 202 203 if (o.password == NULL) 204 o.password = ""; 205 g.sess_options = PJ_STUN_USE_SHORT_TERM_CRED; 206 pj_stun_session_set_short_term_credential(g.sess, 207 pj_cstr(&u, o.user_name), 208 pj_cstr(&p, o.password)); 209 puts("Using short term credential"); 183 status = pj_stun_session_create(g.endpt, NULL, &stun_cb, 184 o.use_fingerprint!=0, &g.sess); 185 pj_assert(status == PJ_SUCCESS); 186 187 if (o.user_name) { 188 pj_stun_auth_cred cred; 189 190 pj_bzero(&cred, sizeof(cred)); 191 192 cred.type = PJ_STUN_AUTH_CRED_STATIC; 193 cred.data.static_cred.realm = pj_str(o.realm); 194 cred.data.static_cred.username = pj_str(o.user_name); 195 cred.data.static_cred.data_type = 0; 196 cred.data.static_cred.data = pj_str(o.password); 197 cred.data.static_cred.nonce = pj_str(o.nonce); 198 199 pj_stun_session_set_credential(g.sess, &cred); 200 puts("Session credential set"); 210 201 } else { 211 202 puts("Credential not set"); 212 203 } 213 214 if (o.use_fingerprint)215 g.sess_options |= PJ_STUN_USE_FINGERPRINT;216 204 217 205 status = pj_thread_create(g.pool, "stun", &worker_thread, NULL, … … 276 264 pj_assert(rc == PJ_SUCCESS); 277 265 278 rc = pj_stun_session_send_msg(g.sess, g.sess_options,266 rc = pj_stun_session_send_msg(g.sess, PJ_FALSE, 279 267 &g.dst_addr, sizeof(g.dst_addr), 280 268 tdata); … … 303 291 puts(" --username, -u Set username of the credential"); 304 292 puts(" --password, -p Set password of the credential"); 293 puts(" --nonce, -N Set NONCE"); 305 294 puts(" --fingerprint, -F Use fingerprint for outgoing requests"); 306 295 puts(" --help, -h"); … … 313 302 { "username", 1, 0, 'u'}, 314 303 { "password", 1, 0, 'p'}, 304 { "nonce", 1, 0, 'N'}, 315 305 { "fingerprint",0, 0, 'F'}, 316 306 { "help", 0, 0, 'h'} … … 331 321 o.password = pj_optarg; 332 322 break; 323 case 'N': 324 o.nonce = pj_optarg; 325 break; 333 326 case 'h': 334 327 usage();
Note: See TracChangeset
for help on using the changeset viewer.