From 763c0ece42f1a69f6114c2e0013127a730e7afb0 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Fri, 22 Jun 2012 14:01:54 +0000 Subject: [PATCH] - api part of connect by string --- src/mesh/mesh.h | 21 ++++++++++++++++++++- src/mesh/mesh_api.c | 13 ++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/mesh/mesh.h b/src/mesh/mesh.h index 5be4544ad..fd9de27d8 100644 --- a/src/mesh/mesh.h +++ b/src/mesh/mesh.h @@ -191,7 +191,7 @@ struct GNUNET_MESH_PeerControl /** - * Message for connecting to peers offering a certain service. + * Message for connecting to peers offering a service, by service number. */ struct GNUNET_MESH_ConnectPeerByType { @@ -211,6 +211,25 @@ struct GNUNET_MESH_ConnectPeerByType */ GNUNET_MESH_ApplicationType type GNUNET_PACKED; }; + + +/** + * Message for connecting to peers offering a service, by service string. + */ +struct GNUNET_MESH_ConnectPeerByString +{ + /** + * Type: GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING + */ + struct GNUNET_MessageHeader header; + + /** + * ID of a tunnel controlled by this client. + */ + MESH_TunnelNumber tunnel_id GNUNET_PACKED; + + /* String describing the service */ +}; GNUNET_NETWORK_STRUCT_END /******************************************************************************/ diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 086b5fa71..ca4bff36f 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -1591,7 +1591,18 @@ void GNUNET_MESH_peer_request_connect_by_string (struct GNUNET_MESH_Tunnel *tunnel, const char *description) { - + struct GNUNET_MESH_ConnectPeerByString *msg; + size_t len; + size_t msgsize; + + len = strlen(description); + msgsize = sizeof(struct GNUNET_MESH_ConnectPeerByString) + len; + GNUNET_assert (UINT16_MAX > msgsize); + msg = GNUNET_malloc (msgsize); + msg->header.size = htons (msgsize); + msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING); + msg->tunnel_id = htonl (tunnel->tid); + memcpy(&msg[1], description, len); } -- 2.25.1