Navigation


Changeset 28:3628f7d2ba88 in freeDiameter for freeDiameter/peers.c


Ignore:
Timestamp:
Oct 26, 2009, 6:07:24 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

some new functions backbones

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/peers.c

    r22 r28  
    131131       
    132132        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)
    136136                        continue;
    137137                if (cmp == 0)
     
    375375}
    376376
     377/* Handle an incoming CER request on a new connection */
     378int 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 */
     437int 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}
Note: See TracChangeset for help on using the changeset viewer.