aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2015-04-27 19:14:44 +0000
committerBart Polot <bart@net.in.tum.de>2015-04-27 19:14:44 +0000
commit0cf4faf197f2e210d5fa1aee441aa478d13f803c (patch)
tree78dc82229d91d2da1db8a29e343679eafd935611 /src
parent08f16ec45cb48fa9068e477b85a04f38895fe22b (diff)
downloadgnunet-0cf4faf197f2e210d5fa1aee441aa478d13f803c.tar.gz
gnunet-0cf4faf197f2e210d5fa1aee441aa478d13f803c.zip
- refactor kx sending, unify under send_kx
Diffstat (limited to 'src')
-rw-r--r--src/cadet/cadet_protocol.h5
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c6
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c3
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c19
4 files changed, 7 insertions, 26 deletions
diff --git a/src/cadet/cadet_protocol.h b/src/cadet/cadet_protocol.h
index c084ecc05..d866e20d3 100644
--- a/src/cadet/cadet_protocol.h
+++ b/src/cadet/cadet_protocol.h
@@ -120,11 +120,6 @@ struct GNUNET_CADET_AX_KX
120 * Type: GNUNET_MESSAGE_TYPE_CADET_AX_KX. 120 * Type: GNUNET_MESSAGE_TYPE_CADET_AX_KX.
121 */ 121 */
122 struct GNUNET_MessageHeader header; 122 struct GNUNET_MessageHeader header;
123
124 /**
125 * ID of the connection.
126 */
127 struct GNUNET_CADET_Hash cid;
128 123
129 /** 124 /**
130 * Sender's ephemeral public ECC key (always for NIST P-521) encoded in a 125 * Sender's ephemeral public ECC key (always for NIST P-521) encoded in a
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 5408b107d..10acee8f9 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -3108,7 +3108,6 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3108 { 3108 {
3109 struct GNUNET_CADET_Encrypted *emsg; 3109 struct GNUNET_CADET_Encrypted *emsg;
3110 struct GNUNET_CADET_KX *kmsg; 3110 struct GNUNET_CADET_KX *kmsg;
3111 struct GNUNET_CADET_AX_KX *axkxmsg;
3112 struct GNUNET_CADET_ACK *amsg; 3111 struct GNUNET_CADET_ACK *amsg;
3113 struct GNUNET_CADET_Poll *pmsg; 3112 struct GNUNET_CADET_Poll *pmsg;
3114 struct GNUNET_CADET_ConnectionDestroy *dmsg; 3113 struct GNUNET_CADET_ConnectionDestroy *dmsg;
@@ -3149,11 +3148,6 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3149 kmsg->cid = c->id; 3148 kmsg->cid = c->id;
3150 break; 3149 break;
3151 3150
3152 case GNUNET_MESSAGE_TYPE_CADET_AX_KX:
3153 axkxmsg = (struct GNUNET_CADET_AX_KX *) data;
3154 axkxmsg->cid = c->id;
3155 break;
3156
3157 case GNUNET_MESSAGE_TYPE_CADET_ACK: 3151 case GNUNET_MESSAGE_TYPE_CADET_ACK:
3158 amsg = (struct GNUNET_CADET_ACK *) data; 3152 amsg = (struct GNUNET_CADET_ACK *) data;
3159 amsg->cid = c->id; 3153 amsg->cid = c->id;
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index 25aaf9408..19c6c99bf 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -926,8 +926,6 @@ queue_is_sendable (struct CadetPeerQueue *q)
926 case GNUNET_MESSAGE_TYPE_CADET_ACK: 926 case GNUNET_MESSAGE_TYPE_CADET_ACK:
927 case GNUNET_MESSAGE_TYPE_CADET_POLL: 927 case GNUNET_MESSAGE_TYPE_CADET_POLL:
928 case GNUNET_MESSAGE_TYPE_CADET_KX: 928 case GNUNET_MESSAGE_TYPE_CADET_KX:
929 case GNUNET_MESSAGE_TYPE_CADET_AX_KX:
930 case GNUNET_MESSAGE_TYPE_CADET_AX:
931 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE: 929 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE:
932 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK: 930 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK:
933 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY: 931 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY:
@@ -935,6 +933,7 @@ queue_is_sendable (struct CadetPeerQueue *q)
935 return GNUNET_YES; 933 return GNUNET_YES;
936 934
937 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED: 935 case GNUNET_MESSAGE_TYPE_CADET_ENCRYPTED:
936 case GNUNET_MESSAGE_TYPE_CADET_AX:
938 break; 937 break;
939 938
940 default: 939 default:
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index b46ce8b18..39c8de1c4 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -1570,7 +1570,7 @@ ephm_sent (void *cls,
1570 uint16_t type, int fwd, size_t size) 1570 uint16_t type, int fwd, size_t size)
1571{ 1571{
1572 struct CadetTunnel *t = cls; 1572 struct CadetTunnel *t = cls;
1573 LOG (GNUNET_ERROR_TYPE_DEBUG, "ephm_sent %s\n", GC_m2s (type)); 1573 LOG (GNUNET_ERROR_TYPE_DEBUG, "ephemeral sent %s\n", GC_m2s (type));
1574 t->ephm_h = NULL; 1574 t->ephm_h = NULL;
1575} 1575}
1576 1576
@@ -1621,7 +1621,6 @@ send_kx (struct CadetTunnel *t,
1621 /* Avoid loopback. */ 1621 /* Avoid loopback. */
1622 if (GCT_is_loopback (t)) 1622 if (GCT_is_loopback (t))
1623 { 1623 {
1624 LOG (GNUNET_ERROR_TYPE_DEBUG, " loopback!\n");
1625 GNUNET_break (0); 1624 GNUNET_break (0);
1626 return NULL; 1625 return NULL;
1627 } 1626 }
@@ -1635,7 +1634,7 @@ send_kx (struct CadetTunnel *t,
1635 /* Must have a connection, or be looking for one. */ 1634 /* Must have a connection, or be looking for one. */
1636 if (NULL == t->connection_head) 1635 if (NULL == t->connection_head)
1637 { 1636 {
1638 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s while no connection\n", GC_m2s (type)); 1637 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s with no connection\n", GC_m2s (type));
1639 if (CADET_TUNNEL_SEARCHING != t->cstate) 1638 if (CADET_TUNNEL_SEARCHING != t->cstate)
1640 { 1639 {
1641 GNUNET_break (0); 1640 GNUNET_break (0);
@@ -1651,8 +1650,7 @@ send_kx (struct CadetTunnel *t,
1651 c = tunnel_get_connection (t); 1650 c = tunnel_get_connection (t);
1652 if (NULL == c) 1651 if (NULL == c)
1653 { 1652 {
1654 if (NULL == t->destroy_task 1653 if (NULL == t->destroy_task && CADET_TUNNEL_READY == t->cstate)
1655 && CADET_TUNNEL_READY == t->cstate)
1656 { 1654 {
1657 GNUNET_break (0); 1655 GNUNET_break (0);
1658 GCT_debug (t, GNUNET_ERROR_TYPE_ERROR); 1656 GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
@@ -1662,20 +1660,20 @@ send_kx (struct CadetTunnel *t,
1662 switch (type) 1660 switch (type)
1663 { 1661 {
1664 case GNUNET_MESSAGE_TYPE_CADET_KX_EPHEMERAL: 1662 case GNUNET_MESSAGE_TYPE_CADET_KX_EPHEMERAL:
1663 case GNUNET_MESSAGE_TYPE_CADET_AX_KX:
1665 GNUNET_assert (NULL == t->ephm_h); 1664 GNUNET_assert (NULL == t->ephm_h);
1666 cont = &ephm_sent; 1665 cont = &ephm_sent;
1667 memcpy (&msg[1], message, size);
1668 break; 1666 break;
1669 case GNUNET_MESSAGE_TYPE_CADET_KX_PONG: 1667 case GNUNET_MESSAGE_TYPE_CADET_KX_PONG:
1670 GNUNET_assert (NULL == t->pong_h); 1668 GNUNET_assert (NULL == t->pong_h);
1671 cont = &pong_sent; 1669 cont = &pong_sent;
1672 memcpy (&msg[1], message, size);
1673 break; 1670 break;
1674 1671
1675 default: 1672 default:
1676 LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n", GC_m2s (type)); 1673 LOG (GNUNET_ERROR_TYPE_DEBUG, "unkown type %s\n", GC_m2s (type));
1677 GNUNET_assert (0); 1674 GNUNET_assert (0);
1678 } 1675 }
1676 memcpy (&msg[1], message, size);
1679 1677
1680 fwd = GCC_is_origin (c, GNUNET_YES); 1678 fwd = GCC_is_origin (c, GNUNET_YES);
1681 1679
@@ -3639,7 +3637,6 @@ void
3639GCT_send_ax_kx (struct CadetTunnel *t) 3637GCT_send_ax_kx (struct CadetTunnel *t)
3640{ 3638{
3641 struct GNUNET_CADET_AX_KX msg; 3639 struct GNUNET_CADET_AX_KX msg;
3642 struct CadetConnection *c;
3643 3640
3644 LOG (GNUNET_ERROR_TYPE_INFO, "===> AX_KX for %s\n", GCT_2s (t)); 3641 LOG (GNUNET_ERROR_TYPE_INFO, "===> AX_KX for %s\n", GCT_2s (t));
3645 3642
@@ -3648,11 +3645,7 @@ GCT_send_ax_kx (struct CadetTunnel *t)
3648 GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->kx_0, &msg.ephemeral_key); 3645 GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->kx_0, &msg.ephemeral_key);
3649 GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->DHRs, &msg.ratchet_key); 3646 GNUNET_CRYPTO_ecdhe_key_get_public (t->ax->DHRs, &msg.ratchet_key);
3650 3647
3651 c = tunnel_get_connection (t); 3648 t->ephm_h = send_kx (t, &msg);
3652 /* TODO: save queue */
3653 GCC_send_prebuilt_message (&msg.header, GNUNET_MESSAGE_TYPE_CADET_AX_KX, 0,
3654 c, GCC_is_origin (c, GNUNET_YES), GNUNET_NO,
3655 NULL, NULL);
3656} 3649}
3657 3650
3658 3651