Navigation


Changeset 895:fbf77629cb7b in freeDiameter for libfdproto


Ignore:
Timestamp:
Nov 30, 2012, 8:44:10 AM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Added received and sent timestamps in the messages; added logs on emission and reception

Location:
libfdproto
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/messages.c

    r894 r895  
    128128        DiamId_t                 msg_src_id;            /* Diameter Id of the peer this message was received from. This string is malloc'd and must be freed */
    129129        size_t                   msg_src_id_len;        /* cached length of this string */
    130         struct timespec          msg_ts;                /* Timestamp associated with the message */
     130        struct timespec          msg_ts_rcv;            /* Timestamp when this message was received from the network */
     131        struct timespec          msg_ts_sent;           /* Timestamp when this message was sent to the network */
    131132       
    132133};
     
    678679{
    679680        int ret = 0;
     681        char buftime[256];
     682        size_t tsoffset = 0;
     683        struct tm tm;
    680684       
    681685        CHECK_FCT( dump_add_str(outstr, offset, outlen, "%*sMSG: %p\n", INOBJHDRVAL, msg) );
     
    684688                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "INVALID!\n", INOBJHDRVAL) );
    685689                return 0;
     690        }
     691       
     692        if ((msg->msg_ts_rcv.tv_sec != 0) || (msg->msg_ts_rcv.tv_nsec != 0)) {
     693                tsoffset += strftime(buftime + tsoffset, sizeof(buftime) - tsoffset, "%D,%T", localtime_r( &msg->msg_ts_rcv.tv_sec , &tm ));
     694                tsoffset += snprintf(buftime + tsoffset, sizeof(buftime) - tsoffset, ".%6.6ld", msg->msg_ts_rcv.tv_nsec / 1000);
     695                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "Received: %s\n", INOBJHDRVAL, buftime) );
     696        }
     697        if ((msg->msg_ts_sent.tv_sec != 0) || (msg->msg_ts_sent.tv_nsec != 0)) {
     698                tsoffset += strftime(buftime + tsoffset, sizeof(buftime) - tsoffset, "%D,%T", localtime_r( &msg->msg_ts_sent.tv_sec , &tm ));
     699                tsoffset += snprintf(buftime + tsoffset, sizeof(buftime) - tsoffset, ".%6.6ld", msg->msg_ts_sent.tv_nsec / 1000);
     700                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "Sent    : %s\n", INOBJHDRVAL, buftime) );
    686701        }
    687702       
     
    734749        if (!avp->avp_model) {
    735750               
    736                 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model)\n", INOBJHDRVAL) );
     751                CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model resolved)\n", INOBJHDRVAL) );
    737752               
    738753        } else {
     
    826841       
    827842        /* now really output this in one shot, so it is not interrupted */
    828         fd_log_debug_fstr(fstr, "%s", outstr);
     843        fd_log_debug_fstr(fstr, "%s\n", outstr);
    829844       
    830845        free(outstr);
     
    838853                                fd_log_debug_fstr(fstr, "Error while dumping %p\n", msg) );
    839854        /* now really output this in one shot, so it is not interrupted */
    840         fd_log_debug_fstr(fstr, "%s", outstr);
     855        fd_log_debug_fstr(fstr, "%s\n", outstr);
    841856       
    842857        free(outstr);
     
    11521167        return 0;
    11531168}
     1169
     1170int fd_msg_ts_set_recv( struct msg * msg, struct timespec * ts )
     1171{
     1172        TRACE_ENTRY("%p %p", msg, ts);
     1173       
     1174        /* Check we received valid parameters */
     1175        CHECK_PARAMS( CHECK_MSG(msg) );
     1176        CHECK_PARAMS( ts );
     1177       
     1178        memcpy(&msg->msg_ts_rcv, ts, sizeof(struct timespec));
     1179        return 0;
     1180}
     1181
     1182int fd_msg_ts_get_recv( struct msg * msg, struct timespec * ts )
     1183{
     1184        TRACE_ENTRY("%p %p", msg, ts);
     1185       
     1186        /* Check we received valid parameters */
     1187        CHECK_PARAMS( CHECK_MSG(msg) );
     1188        CHECK_PARAMS( ts );
     1189       
     1190        memcpy(ts, &msg->msg_ts_rcv, sizeof(struct timespec));
     1191        return 0;
     1192}
     1193
     1194int fd_msg_ts_set_sent( struct msg * msg, struct timespec * ts )
     1195{
     1196        TRACE_ENTRY("%p %p", msg, ts);
     1197       
     1198        /* Check we received valid parameters */
     1199        CHECK_PARAMS( CHECK_MSG(msg) );
     1200        CHECK_PARAMS( ts );
     1201       
     1202        memcpy(&msg->msg_ts_sent, ts, sizeof(struct timespec));
     1203        return 0;
     1204}
     1205
     1206int fd_msg_ts_get_sent( struct msg * msg, struct timespec * ts )
     1207{
     1208        TRACE_ENTRY("%p %p", msg, ts);
     1209       
     1210        /* Check we received valid parameters */
     1211        CHECK_PARAMS( CHECK_MSG(msg) );
     1212        CHECK_PARAMS( ts );
     1213       
     1214        memcpy(ts, &msg->msg_ts_sent, sizeof(struct timespec));
     1215        return 0;
     1216}
     1217
    11541218
    11551219/* Retrieve the session of the message */
  • libfdproto/msg_log.c

    r765 r895  
    166166        (void)pthread_mutex_lock(&fd_log_lock);
    167167        pthread_cleanup_push(fd_cleanup_mutex_silent, &fd_log_lock);
     168        fprintf( fstr, "\n");
    168169        va_start(ap, prefix_format);
    169170        vfprintf( fstr, prefix_format, ap);
     
    173174        (void)pthread_mutex_unlock(&fd_log_lock);
    174175       
    175         fd_log_debug_fstr(fstr, "\nLogged: %s\n\n", buftime);
     176        fd_log_debug_fstr(fstr, "\n Logged: %s\n", buftime);
    176177       
    177178        /* And now the message itself */
Note: See TracChangeset for help on using the changeset viewer.