aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/gnunet-service-mesh_local.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-10-09 14:42:15 +0000
committerBart Polot <bart@net.in.tum.de>2013-10-09 14:42:15 +0000
commit84acdaf73e35f0851ec0fb6dc2c4d6afb840bd6e (patch)
treedf2cd93bf38082842bb6d1d90af803f8085dcec8 /src/mesh/gnunet-service-mesh_local.c
parentb3f4f964227220a10639f4484b86f396ca2dceed (diff)
downloadgnunet-84acdaf73e35f0851ec0fb6dc2c4d6afb840bd6e.tar.gz
gnunet-84acdaf73e35f0851ec0fb6dc2c4d6afb840bd6e.zip
- fixing channel functions
Diffstat (limited to 'src/mesh/gnunet-service-mesh_local.c')
-rw-r--r--src/mesh/gnunet-service-mesh_local.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c
index 9d7db28bc..3fea3a714 100644
--- a/src/mesh/gnunet-service-mesh_local.c
+++ b/src/mesh/gnunet-service-mesh_local.c
@@ -848,6 +848,7 @@ GML_shutdown (void)
848 } 848 }
849} 849}
850 850
851
851/** 852/**
852 * Get a chennel from a client 853 * Get a chennel from a client
853 * 854 *
@@ -870,6 +871,49 @@ GML_channel_get (struct MeshClient *c, MESH_ChannelNumber chid)
870 return GNUNET_CONTAINER_multihashmap32_get (c->own_channels, chid); 871 return GNUNET_CONTAINER_multihashmap32_get (c->own_channels, chid);
871} 872}
872 873
874
875/**
876 * Add a channel to a client
877 *
878 * @param client Client.
879 * @param chid Channel ID.
880 * @param ch Channel.
881 */
882void
883GML_channel_add (struct MeshClient *client,
884 uint32_t chid,
885 struct MeshChannel *ch)
886{
887 if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV)
888 GNUNET_CONTAINER_multihashmap32_put (client->incoming_channels, chid, ch,
889 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
890 else if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_CLI)
891 GNUNET_CONTAINER_multihashmap32_put (client->own_channels, chid, ch,
892 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
893 else
894 GNUNET_break (0);
895}
896
897/**
898 * Remove a channel from a client
899 *
900 * @param client Client.
901 * @param chid Channel ID.
902 * @param ch Channel.
903 */
904void
905GML_channel_remove (struct MeshClient *client,
906 uint32_t chid,
907 struct MeshChannel *ch)
908{
909 if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_SERV)
910 GNUNET_CONTAINER_multihashmap32_remove (c->incoming_channels, chid, ch);
911 else if (chid >= GNUNET_MESH_LOCAL_CHANNEL_ID_CLI)
912 GNUNET_CONTAINER_multihashmap32_remove (c->own_channels, chid, ch);
913 else
914 GNUNET_break (0);
915}
916
873/** 917/**
874 * Check if client has registered with the service and has not disconnected 918 * Check if client has registered with the service and has not disconnected
875 * 919 *
@@ -1056,4 +1100,18 @@ GML_send_data (struct MeshClient *c,
1056} 1100}
1057 1101
1058 1102
1103/**
1104 * Get the static string to represent a client.
1105 *
1106 * @param c Client.
1107 *
1108 * @return Static string for the client.
1109 */
1110const char *
1111GML_2s (const struct MeshClient *c)
1112{
1113 static char buf[32];
1059 1114
1115 sprintf (buf, "%u", c->id);
1116 return buf;
1117}