Changeset 29:5ba91682f0bc in freeDiameter for freeDiameter/peers.c
- Timestamp:
- Oct 28, 2009, 3:19:50 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/peers.c
r28 r29 376 376 377 377 /* Handle an incoming CER request on a new connection */ 378 int fd_peer_handle_newCER( struct msg ** cer, struct cnxctx ** cnx , int tls_done)378 int fd_peer_handle_newCER( struct msg ** cer, struct cnxctx ** cnx ) 379 379 { 380 380 struct msg * msg; … … 385 385 struct fd_list * li; 386 386 int found = 0; 387 int ret = 0; 387 388 struct fd_peer * peer; 388 389 TRACE_ENTRY("%p %p %d", cer, cnx, tls_done); 389 struct cnx_incoming * ev_data; 390 391 TRACE_ENTRY("%p %p", cer, cnx); 390 392 CHECK_PARAMS(cer && *cer && cnx && *cnx); 391 393 … … 411 413 412 414 if (!found) { 413 414 TODO("Create a new peer entry with this diameter id (pf_responder = 1)"); 415 TODO("Upgrade the lock to wr"); 416 TODO("Add the new peer in the list"); 417 TODO("Release the wr lock"); 418 TODO("Start the peer PSM, which will have to validate if this peer is authorized to connect, and so on"); 419 } 420 421 TODO("Send the new connection event to the peer SM with the appropriate data: msg, conn, tls_done, found"); 422 /* FDEVP_CNX_INCOMING */ 423 424 /* Reset the "out" parameters, so that they are not cleanup on function return. */ 425 *cer = NULL; 426 *cnx = NULL; 427 415 /* Create a new peer entry for this new remote peer */ 416 peer = NULL; 417 CHECK_FCT_DO( ret = fd_peer_alloc(&peer), goto out ); 418 419 /* Set the peer Diameter Id and the responder flag parameters */ 420 CHECK_MALLOC_DO( peer->p_hdr.info.pi_diamid = malloc(avp_hdr->avp_value->os.len + 1), { ret = ENOMEM; goto out; } ); 421 CHECK_MALLOC_DO( peer->p_dbgorig = strdup(fd_cnx_getid(*cnx)), { ret = ENOMEM; goto out; } ); 422 peer->p_flags.pf_responder = 1; 423 424 /* Upgrade the lock to write lock */ 425 CHECK_POSIX_DO( ret = pthread_rwlock_wrlock(&fd_g_peers_rw), goto out ); 426 427 /* Insert the new peer in the list (the PSM will take care of setting the expiry after validation) */ 428 fd_list_insert_before( li, &peer->p_hdr.chain ); 429 430 /* Release the write lock */ 431 CHECK_POSIX_DO( ret = pthread_rwlock_unlock(&fd_g_peers_rw), goto out ); 432 433 /* Start the PSM, which will receive the event bellow */ 434 CHECK_FCT_DO( ret = fd_psm_begin(peer), goto out ); 435 } 436 437 /* Send the new connection event to the PSM */ 438 CHECK_MALLOC_DO( ev_data = malloc(sizeof(struct cnx_incoming)), { ret = ENOMEM; goto out; } ); 439 memset(ev_data, 0, sizeof(ev_data)); 440 441 ev_data->cer = msg; 442 ev_data->cnx = *cnx; 443 ev_data->validate = !found; 444 445 CHECK_FCT_DO( ret = fd_event_send(peer->p_events, FDEVP_CNX_INCOMING, sizeof(ev_data), ev_data), goto out ); 446 447 out: 428 448 CHECK_POSIX( pthread_rwlock_unlock(&fd_g_peers_rw) ); 429 449 430 431 TODO("(later if not tls_done) handshake or start_clear(.., 1) "); 432 433 return 0; 450 if (ret == 0) { 451 /* Reset the "out" parameters, so that they are not cleanup on function return. */ 452 *cer = NULL; 453 *cnx = NULL; 454 } 455 456 return ret; 434 457 } 435 458 … … 441 464 return ENOTSUP; 442 465 } 466 467 /* Validate a peer by calling the callbacks in turn -- return 0 if the peer is validated, ! 0 in case of error or if the peer is rejected */ 468 int fd_peer_validate( struct fd_peer * peer ) 469 { 470 TODO("Default to reject"); 471 TODO("Call all callbacks in turn"); 472 TODO("Save cb2 in the peer if needed"); 473 return ENOTSUP; 474 }
Note: See TracChangeset
for help on using the changeset viewer.