From: Bart Polot Date: Fri, 22 Jun 2012 14:01:54 +0000 (+0000) Subject: - api part of connect by string X-Git-Tag: initial-import-from-subversion-38251~12883 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=763c0ece42f1a69f6114c2e0013127a730e7afb0;p=oweals%2Fgnunet.git - api part of connect by string --- 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); }