Changeset 28:3628f7d2ba88 in freeDiameter
- Timestamp:
- Oct 26, 2009, 6:07:24 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- freeDiameter
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/fD.h
r25 r28 157 157 ,FDEVP_TERMINATE 158 158 159 /* A connection object has received a message. */159 /* A connection object has received a message. (data contains the buffer) */ 160 160 ,FDEVP_CNX_MSG_RECV 161 161 … … 166 166 ,FDEVP_CNX_EP_CHANGE 167 167 168 /* A message was received in the peer*/169 ,FDEVP_ MSG_INCOMING168 /* A new connection has been established (data contains the appropriate info) */ 169 ,FDEVP_CNX_INCOMING 170 170 171 171 /* The PSM state is expired */ … … 185 185 186 186 /* Functions */ 187 int fd_peer_fini();187 int fd_peer_fini(); 188 188 void fd_peer_dump_list(int details); 189 189 void fd_peer_dump(struct fd_peer * peer, int details); 190 int fd_peer_alloc(struct fd_peer ** ptr); 191 int fd_peer_free(struct fd_peer ** ptr); 190 int fd_peer_alloc(struct fd_peer ** ptr); 191 int fd_peer_free(struct fd_peer ** ptr); 192 int fd_peer_handle_newCER( struct msg ** cer, struct cnxctx ** cnx, int tls_done ); 192 193 /* fd_peer_add declared in freeDiameter.h */ 193 194 … … 198 199 199 200 /* Peer state machine */ 200 int fd_psm_start();201 int fd_psm_begin(struct fd_peer * peer );202 int fd_psm_terminate(struct fd_peer * peer );201 int fd_psm_start(); 202 int fd_psm_begin(struct fd_peer * peer ); 203 int fd_psm_terminate(struct fd_peer * peer ); 203 204 void fd_psm_abord(struct fd_peer * peer ); 204 205 205 206 /* Server sockets */ 206 207 void fd_servers_dump(); 207 int fd_servers_start();208 int fd_servers_stop();209 210 /* Connection contexts */208 int fd_servers_start(); 209 int fd_servers_stop(); 210 211 /* Connection contexts -- there are also definitions in cnxctx.h for the relevant files */ 211 212 struct cnxctx * fd_cnx_serv_tcp(uint16_t port, int family, struct fd_endpoint * ep); 212 213 struct cnxctx * fd_cnx_serv_sctp(uint16_t port, struct fd_list * ep_list); 213 int fd_cnx_serv_listen(struct cnxctx * conn);214 int fd_cnx_serv_listen(struct cnxctx * conn); 214 215 struct cnxctx * fd_cnx_serv_accept(struct cnxctx * serv); 215 216 struct cnxctx * fd_cnx_cli_connect_tcp(sSA * sa, socklen_t addrlen); 216 217 struct cnxctx * fd_cnx_cli_connect_sctp(int no_ip6, uint16_t port, struct fd_list * list); 217 char * fd_cnx_getid(struct cnxctx * conn);218 int fd_cnx_start_clear(struct cnxctx * conn, int loop);219 int fd_cnx_handshake(struct cnxctx * conn, int mode, char * priority);220 int fd_cnx_getcred(struct cnxctx * conn, const gnutls_datum_t **cert_list, unsigned int *cert_list_size);221 int fd_cnx_getendpoints(struct cnxctx * conn, struct fd_list * local, struct fd_list * remote);222 char * fd_cnx_getremoteid(struct cnxctx * conn);223 int fd_cnx_receive(struct cnxctx * conn, struct timespec * timeout, unsigned char **buf, size_t * len);224 int fd_cnx_recv_setaltfifo(struct cnxctx * conn, struct fifo * alt_fifo); /* send FDEVP_CNX_MSG_RECV event to the fifo list */225 int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len);226 void fd_cnx_destroy(struct cnxctx * conn);218 char * fd_cnx_getid(struct cnxctx * conn); 219 int fd_cnx_start_clear(struct cnxctx * conn, int loop); 220 int fd_cnx_handshake(struct cnxctx * conn, int mode, char * priority); 221 int fd_cnx_getcred(struct cnxctx * conn, const gnutls_datum_t **cert_list, unsigned int *cert_list_size); 222 int fd_cnx_getendpoints(struct cnxctx * conn, struct fd_list * local, struct fd_list * remote); 223 char * fd_cnx_getremoteid(struct cnxctx * conn); 224 int fd_cnx_receive(struct cnxctx * conn, struct timespec * timeout, unsigned char **buf, size_t * len); 225 int fd_cnx_recv_setaltfifo(struct cnxctx * conn, struct fifo * alt_fifo); /* send FDEVP_CNX_MSG_RECV event to the fifo list */ 226 int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len); 227 void fd_cnx_destroy(struct cnxctx * conn); 227 228 228 229 -
freeDiameter/p_psm.c
r27 r28 60 60 case_str(FDEVP_CNX_ERROR); 61 61 case_str(FDEVP_CNX_EP_CHANGE); 62 case_str(FDEVP_ MSG_INCOMING);62 case_str(FDEVP_CNX_INCOMING); 63 63 case_str(FDEVP_PSM_TIMEOUT); 64 64 … … 227 227 return NULL; 228 228 } 229 230 231 232 229 233 230 /* Create the PSM thread of one peer structure */ -
freeDiameter/peers.c
r22 r28 131 131 132 132 for (li = fd_g_peers.next; li != &fd_g_peers; li = li->next) { 133 struct fd_peer * prev= (struct fd_peer *)li;134 int cmp = strcasecmp( p->p_hdr.info.pi_diamid, prev->p_hdr.info.pi_diamid );135 if (cmp <0)133 struct fd_peer * next = (struct fd_peer *)li; 134 int cmp = strcasecmp( p->p_hdr.info.pi_diamid, next->p_hdr.info.pi_diamid ); 135 if (cmp > 0) 136 136 continue; 137 137 if (cmp == 0) … … 375 375 } 376 376 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 ) 379 { 380 struct msg * msg; 381 struct dict_object *avp_oh_model; 382 avp_code_t code = AC_ORIGIN_HOST; 383 struct avp *avp_oh; 384 struct avp_hdr * avp_hdr; 385 struct fd_list * li; 386 int found = 0; 387 struct fd_peer * peer; 388 389 TRACE_ENTRY("%p %p %d", cer, cnx, tls_done); 390 CHECK_PARAMS(cer && *cer && cnx && *cnx); 391 392 msg = *cer; 393 394 /* Find the Diameter Identity of the remote peer in the message */ 395 CHECK_FCT( fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_CODE, &code, &avp_oh_model, ENOENT) ); 396 CHECK_FCT( fd_msg_search_avp ( msg, avp_oh_model, &avp_oh ) ); 397 CHECK_FCT( fd_msg_avp_hdr ( avp_oh, &avp_hdr ) ); 398 399 /* Search if we already have this peer id in our list */ 400 CHECK_POSIX( pthread_rwlock_rdlock(&fd_g_peers_rw) ); 401 402 for (li = fd_g_peers.next; li != &fd_g_peers; li = li->next) { 403 peer = (struct fd_peer *)li; 404 int cmp = strncasecmp( avp_hdr->avp_value->os.data, peer->p_hdr.info.pi_diamid, avp_hdr->avp_value->os.len ); 405 if (cmp > 0) 406 continue; 407 if (cmp == 0) 408 found = 1; 409 break; 410 } 411 412 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 428 CHECK_POSIX( pthread_rwlock_unlock(&fd_g_peers_rw) ); 429 430 431 TODO("(later if not tls_done) handshake or start_clear(.., 1) "); 432 433 return 0; 434 } 435 436 /* Save a callback to accept / reject incoming unknown peers */ 437 int fd_peer_validate_register ( int (*peer_validate)(struct peer_info * /* info */, int * /* auth */, int (**cb2)(struct peer_info *)) ) 438 { 439 440 TODO("..."); 441 return ENOTSUP; 442 } -
freeDiameter/server.c
r27 r28 139 139 CHECK_FCT_DO( fd_msg_parse_buffer( &buf, bufsz, &msg ), /* Parsing failed */ goto cleanup ); 140 140 141 /* We expect a CER, it must parse with our dictionary */142 CHECK_FCT_DO( fd_msg_parse_ dict( msg, fd_g_config->cnf_dict ), /* Parsing failed*/ goto cleanup );141 /* We expect a CER, it must parse with our dictionary and rules */ 142 CHECK_FCT_DO( fd_msg_parse_rules( msg, fd_g_config->cnf_dict, NULL ), /* Parsing failed -- trace details ? */ goto cleanup ); 143 143 144 144 if (TRACE_BOOL(FULL)) { … … 149 149 /* Now check we received a CER */ 150 150 CHECK_FCT_DO( fd_msg_hdr ( msg, &hdr ), goto fatal_error ); 151 152 151 CHECK_PARAMS_DO( (hdr->msg_appl == 0) && (hdr->msg_flags & CMD_FLAG_REQUEST) && (hdr->msg_code == CC_CAPABILITIES_EXCHANGE), 153 152 { fd_log_debug("Connection '%s', expecting CER, received something else, closing...\n", fd_cnx_getid(c->conn)); goto cleanup; } ); 154 153 155 156 TODO("Search matching peer"); 157 TODO("Send event to the peer"); 158 159 TODO("(later) handshake or start_clear(.., 1)"); 160 /* The end */ 154 /* Finally, pass the information to the peers module which will handle it next */ 155 CHECK_FCT_DO( fd_peer_handle_newCER( &msg, &c->conn, s->secur ), goto fatal_error ); 156 157 /* The end, we cleanup the client structure */ 161 158 cleanup: 162 159 /* Unlink the client structure */
Note: See TracChangeset
for help on using the changeset viewer.