Changeset 894:43fb27a9037f in freeDiameter for libfdcore
- Timestamp:
- Nov 30, 2012, 6:51:49 AM (11 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libfdcore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/cnxctx.c
r816 r894 641 641 } 642 642 643 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &conn->cc_tls_para.recvon), /* continue */ ); 644 643 645 return ret; 644 646 } … … 696 698 ssize_t ret = 0; 697 699 size_t received = 0; 700 struct timespec recv_on; 698 701 699 702 do { … … 718 721 719 722 /* Ok, now we can really receive the data */ 720 CHECK_MALLOC_DO( newmsg = malloc( length ), goto fatal );723 CHECK_MALLOC_DO( newmsg = malloc( length + sizeof(struct timespec) ), goto fatal ); 721 724 memcpy(newmsg, header, sizeof(header)); 722 725 … … 732 735 received += ret; 733 736 } 737 738 /* Piggy-tail the timestamp of reception */ 739 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &recv_on), /* continue */ ); 740 memcpy(newmsg + length, &recv_on, sizeof(struct timespec)); 734 741 735 742 /* We have received a complete message, pass it to the daemon */ … … 782 789 continue; 783 790 } 784 791 /* Note: the real size of buf is bufsz + struct timespec */ 785 792 CHECK_FCT_DO( fd_event_send( fd_cnx_target_queue(conn), event, bufsz, buf), goto fatal ); 786 793 … … 920 927 int fd_tls_rcvthr_core(struct cnxctx * conn, gnutls_session_t session) 921 928 { 929 struct timespec * rcv_on; 930 931 void * ptr = gnutls_transport_get_ptr(session); 932 if (ptr == conn) { 933 rcv_on = &conn->cc_tls_para.recvon; 934 } else { 935 struct sctps_ctx * ctx = (struct sctps_ctx *) ptr; 936 rcv_on = &ctx->recvon; 937 } 938 939 922 940 /* No guarantee that GnuTLS preserves the message boundaries, so we re-build it as in TCP */ 923 941 do { … … 927 945 ssize_t ret = 0; 928 946 size_t received = 0; 947 struct timespec recv_on; 929 948 930 949 do { … … 949 968 950 969 /* Ok, now we can really receive the data */ 951 CHECK_MALLOC( newmsg = malloc( length ) );970 CHECK_MALLOC( newmsg = malloc( length + sizeof(struct timespec)) ); 952 971 memcpy(newmsg, header, sizeof(header)); 953 972 … … 963 982 received += ret; 964 983 } 984 985 /* The timestamp of the last TLS chunk received for this rebuilt message lives close to the session pointer, we piggyback it */ 986 memcpy(newmsg + length, rcv_on, sizeof(struct timespec)); 965 987 966 988 /* We have received a complete message, pass it to the daemon */ -
libfdcore/cnxctx.h
r808 r894 66 66 int mode; /* GNUTLS_CLIENT / GNUTLS_SERVER */ 67 67 gnutls_session_t session; /* Session object (stream #0 in case of SCTP) */ 68 struct timespec recvon; /* Timestamp of the last chunk of data received on this session -- before uncipher */ 68 69 } cc_tls_para; 69 70 … … 130 131 size_t offset; 131 132 } partial; /* If the pull function did not read the full content of first message in raw, it stores it here for next read call. */ 133 struct timespec recvon; /* Timestamp of the last chunk of data received on this stream -- before uncipher */ 132 134 pthread_t thr; /* Thread to decrypt raw data in this pair of streams */ 133 135 gnutls_session_t session; /* TLS context using this pair of streams -- except if strid == 0, in that case session is outside the array */ -
libfdcore/fdcore-internal.h
r815 r894 215 215 ,FDEVP_TERMINATE 216 216 217 /* A connection object has received a message. (data contains the buffer ) */217 /* A connection object has received a message. (data contains the buffer + struct timespec piggytailed -- unaligned) */ 218 218 ,FDEVP_CNX_MSG_RECV 219 219 -
libfdcore/sctp.c
r817 r894 1068 1068 size_t mempagesz = sysconf(_SC_PAGESIZE); /* We alloc buffer by memory pages for efficiency */ 1069 1069 int timedout = 0; 1070 struct timespec recv_on; 1070 1071 1071 1072 TRACE_ENTRY("%p %p %p %p %p", conn, strid, buf, len, event); … … 1086 1087 /* We will loop while all data is not received. */ 1087 1088 incomplete: 1088 if (datasize == bufsz ) {1089 if (datasize == bufsz - sizeof(struct timespec)) { 1089 1090 /* The buffer is full, enlarge it */ 1090 1091 bufsz += mempagesz; 1091 CHECK_MALLOC( data = realloc(data, bufsz ) );1092 CHECK_MALLOC( data = realloc(data, bufsz ) ); 1092 1093 } 1093 1094 /* the new data will be received following the preceding */ 1094 1095 memset(&iov, 0, sizeof(iov)); 1095 1096 iov.iov_base = data + datasize ; 1096 iov.iov_len = bufsz - datasize;1097 iov.iov_len = bufsz - sizeof(struct timespec) - datasize; 1097 1098 1098 1099 /* Receive data from the socket */ … … 1188 1189 } 1189 1190 1191 /* Piggy-tail the timestamp of reception */ 1192 CHECK_SYS_DO( clock_gettime(CLOCK_REALTIME, &recv_on), /* continue */ ); 1193 memcpy(data + datasize, &recv_on, sizeof(struct timespec)); 1194 1190 1195 /* From this point, we have received a message */ 1191 1196 *event = FDEVP_CNX_MSG_RECV; -
libfdcore/sctps.c
r808 r894 92 92 /* Demux this message to the appropriate fifo, another thread will pull, gnutls process, and send to target queue */ 93 93 if (strid < conn->cc_sctp_para.pairs) { 94 /* Note, here the timespec is piggytailed to buf */ 94 95 CHECK_FCT_DO(fd_event_send(conn->cc_sctps_data.array[strid].raw_recv, event, bufsz, buf), goto fatal ); 95 96 } else { … … 195 196 return -1; 196 197 } 198 if (ev == FDEVP_CNX_MSG_RECV) { 199 memcpy(&ctx->recvon, ctx->partial.buf + ctx->partial.bufsz, sizeof(struct timespec)); /* retrieve piggy-tailed ts */ 200 } 197 201 } 198 202
Note: See TracChangeset
for help on using the changeset viewer.