Navigation


Changeset 26:b4684b76c6ab in freeDiameter for freeDiameter/server.c


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

Fix erroneous %g specifiers for size_t (correct is %z)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/server.c

    r25 r26  
    100100        struct client * c = arg;
    101101        struct server * s = NULL;
     102        uint8_t       * buf = NULL;
     103        size_t          bufsz;
     104        struct msg    * msg = NULL;
     105        struct msg_hdr *hdr = NULL;
    102106       
    103107        TRACE_ENTRY("%p", c);
     
    127131        c->ts.tv_sec += INCNX_TIMEOUT;
    128132       
    129         TODO("receive message until c->ts");
    130        
    131         TODO("Timeout => close");
    132         TODO("Message != CER => close");
    133         TODO("Message == CER : ");
     133        /* Receive the first Diameter message on the connection -- cleanup in case of timeout */
     134        CHECK_FCT_DO( fd_cnx_receive(c->conn, &c->ts, &buf, &bufsz), goto cleanup );
     135       
     136        TRACE_DEBUG(FULL, "Received %zb from new client '%s'", bufsz, fd_cnx_getid(c->conn));
     137       
     138        /* Try parsing this message */
     139        CHECK_FCT_DO( fd_msg_parse_buffer( &buf, bufsz, &msg ), /* Parsing failed */ goto cleanup );
     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 );
     143       
     144        if (TRACE_BOOL(FULL)) {
     145                fd_log_debug("Received Diameter message from new client '%s':\n", fd_cnx_getid(c->conn));
     146                fd_msg_dump_walk(FULL, msg);
     147        }
     148       
     149        /* Now check we received a CER */
     150        CHECK_FCT_DO( fd_msg_hdr ( msg, &hdr ), goto fatal_error );
     151       
     152        CHECK_PARAMS_DO( (hdr->msg_appl == 0) && (hdr->msg_flags & CMD_FLAG_REQUEST) && (hdr->msg_code == CC_CAPABILITIES_EXCHANGE),
     153                { fd_log_debug("Connection '%s', expecting CER, received something else, closing...\n", fd_cnx_getid(c->conn)); goto cleanup; } );
     154       
     155       
    134156        TODO("Search matching peer");
    135157        TODO("Send event to the peer");
     
    146168        if (c->conn)
    147169                fd_cnx_destroy(c->conn);
     170       
     171        /* Cleanup the received buffer if any */
     172        free(buf);
     173       
     174        /* Cleanup the parsed message if any */
     175        if (msg) {
     176                CHECK_FCT_DO( fd_msg_free(msg), /* continue */);
     177        }
    148178       
    149179        /* Detach the thread, cleanup the client structure */
Note: See TracChangeset for help on using the changeset viewer.