aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_connection.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2016-09-20 01:22:01 +0000
committerBart Polot <bart@net.in.tum.de>2016-09-20 01:22:01 +0000
commit38fb8781ef545244d6b8ce9151d5968deb7ab1a1 (patch)
tree6dcee29ca80168338e1b40262dbef22bf25e5043 /src/cadet/gnunet-service-cadet_connection.c
parentb4d5f474eef10017a470dccb01dae86c32bd5ddb (diff)
downloadgnunet-38fb8781ef545244d6b8ce9151d5968deb7ab1a1.tar.gz
gnunet-38fb8781ef545244d6b8ce9151d5968deb7ab1a1.zip
- fix PID accounting without direct queue control
Diffstat (limited to 'src/cadet/gnunet-service-cadet_connection.c')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 29695243f..eb6ba5aa7 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -76,6 +76,11 @@ struct CadetFlowControl
76 unsigned int queue_max; 76 unsigned int queue_max;
77 77
78 /** 78 /**
79 * ID of the next packet to send.
80 */
81 uint32_t next_pid;
82
83 /**
79 * ID of the last packet sent towards the peer. 84 * ID of the last packet sent towards the peer.
80 */ 85 */
81 uint32_t last_pid_sent; 86 uint32_t last_pid_sent;
@@ -439,7 +444,8 @@ GCC_state2s (enum CadetConnectionState s)
439static void 444static void
440fc_init (struct CadetFlowControl *fc) 445fc_init (struct CadetFlowControl *fc)
441{ 446{
442 fc->last_pid_sent = (uint32_t) -1; /* Next (expected) = 0 */ 447 fc->next_pid = (uint32_t) 0;
448 fc->last_pid_sent = (uint32_t) -1;
443 fc->last_pid_recv = (uint32_t) -1; 449 fc->last_pid_recv = (uint32_t) -1;
444 fc->last_ack_sent = (uint32_t) 0; 450 fc->last_ack_sent = (uint32_t) 0;
445 fc->last_ack_recv = (uint32_t) 0; 451 fc->last_ack_recv = (uint32_t) 0;
@@ -3016,16 +3022,18 @@ GCC_get_qn (struct CadetConnection *c, int fwd)
3016 * @param c Connection. 3022 * @param c Connection.
3017 * @param fwd Is query about FWD traffic? 3023 * @param fwd Is query about FWD traffic?
3018 * 3024 *
3019 * @return Last PID used + 1. 3025 * @return Next PID to use.
3020 */ 3026 */
3021unsigned int 3027uint32_t
3022GCC_get_pid (struct CadetConnection *c, int fwd) 3028GCC_get_pid (struct CadetConnection *c, int fwd)
3023{ 3029{
3024 struct CadetFlowControl *fc; 3030 struct CadetFlowControl *fc;
3031 uint32_t pid;
3025 3032
3026 fc = fwd ? &c->fwd_fc : &c->bck_fc; 3033 fc = fwd ? &c->fwd_fc : &c->bck_fc;
3027 3034 pid = fc->next_pid;
3028 return fc->last_pid_sent + 1; 3035 fc->next_pid++;
3036 return pid;
3029} 3037}
3030 3038
3031 3039
@@ -3221,6 +3229,12 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3221 struct CadetConnection *c, int fwd, int force, 3229 struct CadetConnection *c, int fwd, int force,
3222 GCC_sent cont, void *cont_cls) 3230 GCC_sent cont, void *cont_cls)
3223{ 3231{
3232 struct GNUNET_CADET_AX *axmsg;
3233 struct GNUNET_CADET_KX *kmsg;
3234 struct GNUNET_CADET_ACK *amsg;
3235 struct GNUNET_CADET_Poll *pmsg;
3236 struct GNUNET_CADET_ConnectionDestroy *dmsg;
3237 struct GNUNET_CADET_ConnectionBroken *bmsg;
3224 struct CadetFlowControl *fc; 3238 struct CadetFlowControl *fc;
3225 struct CadetConnectionQueue *q; 3239 struct CadetConnectionQueue *q;
3226 struct GNUNET_MessageHeader *copy; 3240 struct GNUNET_MessageHeader *copy;
@@ -3244,19 +3258,13 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3244 "--> %s (%s %4u) on conn %s (%p) %s [%5u]\n", 3258 "--> %s (%s %4u) on conn %s (%p) %s [%5u]\n",
3245 GC_m2s (type), GC_m2s (payload_type), payload_id, GCC_2s (c), c, 3259 GC_m2s (type), GC_m2s (payload_type), payload_id, GCC_2s (c), c,
3246 GC_f2s(fwd), size); 3260 GC_f2s(fwd), size);
3247 droppable = GNUNET_NO == force; 3261 droppable = (GNUNET_NO == force);
3248 switch (type) 3262 switch (type)
3249 { 3263 {
3250 struct GNUNET_CADET_AX *axmsg;
3251 struct GNUNET_CADET_KX *kmsg;
3252 struct GNUNET_CADET_ACK *amsg;
3253 struct GNUNET_CADET_Poll *pmsg;
3254 struct GNUNET_CADET_ConnectionDestroy *dmsg;
3255 struct GNUNET_CADET_ConnectionBroken *bmsg;
3256
3257 case GNUNET_MESSAGE_TYPE_CADET_AX: 3264 case GNUNET_MESSAGE_TYPE_CADET_AX:
3258 axmsg = (struct GNUNET_CADET_AX *) copy; 3265 axmsg = (struct GNUNET_CADET_AX *) copy;
3259 axmsg->cid = c->id; 3266 axmsg->cid = c->id;
3267 axmsg->pid = htonl (GCC_get_pid (c, fwd));
3260 LOG (GNUNET_ERROR_TYPE_DEBUG, " Q_N+ %p %u\n", fc, fc->queue_n); 3268 LOG (GNUNET_ERROR_TYPE_DEBUG, " Q_N+ %p %u\n", fc, fc->queue_n);
3261 LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid sent %u\n", fc->last_pid_sent); 3269 LOG (GNUNET_ERROR_TYPE_DEBUG, "last pid sent %u\n", fc->last_pid_sent);
3262 LOG (GNUNET_ERROR_TYPE_DEBUG, " ack recv %u\n", fc->last_ack_recv); 3270 LOG (GNUNET_ERROR_TYPE_DEBUG, " ack recv %u\n", fc->last_ack_recv);