Navigation


Changeset 26:b4684b76c6ab in freeDiameter


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)

Location:
freeDiameter
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/cnxctx.c

    r25 r26  
    504504                   || (length > DIAMETER_MSG_SIZE_MAX)) { /* to avoid too big mallocs */
    505505                        /* The message is suspect */
    506                         TRACE_DEBUG(INFO, "Received suspect header [ver: %d, size: %g], assume disconnection", (int)header[0], length);
     506                        TRACE_DEBUG(INFO, "Received suspect header [ver: %d, size: %z], assume disconnection", (int)header[0], length);
    507507                        goto error; /* Stop the thread, the recipient of the event will cleanup */
    508508                }
     
    630630                   || (length > DIAMETER_MSG_SIZE_MAX)) { /* to avoid too big mallocs */
    631631                        /* The message is suspect */
    632                         TRACE_DEBUG(INFO, "Received suspect header [ver: %d, size: %g], assume disconnection", (int)header[0], length);
     632                        TRACE_DEBUG(INFO, "Received suspect header [ver: %d, size: %z], assume disconnection", (int)header[0], length);
    633633                        goto out;
    634634                }
     
    895895        ssize_t ret;
    896896        size_t sent = 0;
    897         TRACE_ENTRY("%p %p %g", conn, buf, len);
     897        TRACE_ENTRY("%p %p %z", conn, buf, len);
    898898        do {
    899899                if (conn->cc_tls) {
     
    910910int fd_cnx_send(struct cnxctx * conn, unsigned char * buf, size_t len)
    911911{
    912         TRACE_ENTRY("%p %p %g", conn, buf, len);
     912        TRACE_ENTRY("%p %p %z", conn, buf, len);
    913913       
    914914        CHECK_PARAMS(conn && (conn->cc_socket > 0) && buf && len);
    915915
    916         TRACE_DEBUG(FULL, "Sending %gb %sdata on connection %s", len, conn->cc_tls ? "TLS-protected ":"", conn->cc_id);
     916        TRACE_DEBUG(FULL, "Sending %zb %sdata on connection %s", len, conn->cc_tls ? "TLS-protected ":"", conn->cc_id);
    917917       
    918918        switch (conn->cc_proto) {
  • freeDiameter/p_psm.c

    r25 r26  
    164164        /* Get next event */
    165165        CHECK_FCT_DO( fd_event_timedget(peer->p_events, &peer->p_psm_timer, FDEVP_PSM_TIMEOUT, &event, &ev_sz, &ev_data), goto psm_end );
    166         TRACE_DEBUG(FULL, "'%s'\t<-- '%s'\t(%p,%g)\t'%s'",
     166        TRACE_DEBUG(FULL, "'%s'\t<-- '%s'\t(%p,%z)\t'%s'",
    167167                        STATE_STR(peer->p_hdr.info.pi_state),
    168168                        fd_pev_str(event), ev_data, ev_sz,
  • freeDiameter/sctp.c

    r25 r26  
    764764        if (sz != sizeof(status))
    765765        {
    766                 TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %g", sz, sizeof(status));
     766                TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %z", sz, sizeof(status));
    767767                return ENOTSUP;
    768768        }
     
    911911        ssize_t ret;
    912912       
    913         TRACE_ENTRY("%d %hu %p %g", sock, strid, buf, len);
     913        TRACE_ENTRY("%d %hu %p %z", sock, strid, buf, len);
    914914       
    915915        memset(&mhdr, 0, sizeof(mhdr));
  • freeDiameter/sctps.c

    r25 r26  
    136136        struct sctps_ctx * ctx = (struct sctps_ctx *) tr;
    137137       
    138         TRACE_ENTRY("%p %p %g", tr, data, len);
     138        TRACE_ENTRY("%p %p %z", tr, data, len);
    139139        CHECK_PARAMS_DO( tr && data, { errno = EINVAL; return -1; } );
    140140       
     
    151151        int emptied;
    152152       
    153         TRACE_ENTRY("%p %p %g", tr, buf, len);
     153        TRACE_ENTRY("%p %p %z", tr, buf, len);
    154154        CHECK_PARAMS_DO( tr && buf, { errno = EINVAL; return -1; } );
    155155       
  • 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.