Navigation


Changeset 23:db6c40b8b307 in freeDiameter for freeDiameter/cnxctx.c


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

Added some code in cnxctx.c mainly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/cnxctx.c

    r22 r23  
    214214                        break;
    215215
     216#ifndef DISABLE_SCTP
    216217                case IPPROTO_SCTP:
    217218                        CHECK_FCT(fd_sctp_listen(conn->cc_socket));
    218219                        break;
     220#endif /* DISABLE_SCTP */
    219221
    220222                default:
     
    400402}
    401403
    402 /* Get the list of endpoints (IP addresses) of the local and remote peers on this conenction */
     404/* Get the list of endpoints (IP addresses) of the local and remote peers on this connection */
    403405int fd_cnx_getendpoints(struct cnxctx * conn, struct fd_list * local, struct fd_list * remote)
    404406{
     
    408410        if (local) {
    409411                /* Retrieve the local endpoint(s) of the connection */
    410                 TODO("TCP : getsockname");
    411                 TODO("SCTP: sctp_getladdrs / _sctp_getboundaddrs (waaad)");
     412                switch (conn->cc_proto) {
     413                        case IPPROTO_TCP: {
     414                                sSS ss;
     415                                socklen_t sl;
     416                                CHECK_FCT(fd_tcp_get_local_ep(conn->cc_socket, &ss, &sl));
     417                                CHECK_FCT(fd_ep_add_merge( local, (sSA *)&ss, sl, 0, 0, 0, 1 ));
     418                        }
     419                        break;
     420
     421                        #ifndef DISABLE_SCTP
     422                        case IPPROTO_SCTP: {
     423                                CHECK_FCT(fd_sctp_get_local_ep(conn->cc_socket, local));
     424                        }
     425                        break;
     426                        #endif /* DISABLE_SCTP */
     427
     428                        default:
     429                                CHECK_PARAMS(0);
     430                }
    412431        }
    413432       
    414433        if (remote) {
     434                /* Check we have a full connection object, not a listening socket (with no remote) */
     435                CHECK_PARAMS( conn->cc_events );
     436               
    415437                /* Retrieve the peer endpoint(s) of the connection */
    416                 TODO("TCP : getpeername");
    417                 TODO("SCTP: sctp_getpaddrs");
    418                
    419         }
    420 
    421         return ENOTSUP;
     438                switch (conn->cc_proto) {
     439                        case IPPROTO_TCP: {
     440                                sSS ss;
     441                                socklen_t sl;
     442                                CHECK_FCT(fd_tcp_get_remote_ep(conn->cc_socket, &ss, &sl));
     443                                CHECK_FCT(fd_ep_add_merge( remote, (sSA *)&ss, sl, 0, 0, 0, 1 ));
     444                        }
     445                        break;
     446
     447                        #ifndef DISABLE_SCTP
     448                        case IPPROTO_SCTP: {
     449                                CHECK_FCT(fd_sctp_get_remote_ep(conn->cc_socket, remote));
     450                        }
     451                        break;
     452                        #endif /* DISABLE_SCTP */
     453
     454                        default:
     455                                CHECK_PARAMS(0);
     456                }
     457        }
     458
     459        return 0;
    422460}
    423461
Note: See TracChangeset for help on using the changeset viewer.