diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-05-07 11:40:57 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-05-07 11:40:57 +0000 |
commit | ce1f13b0c623d222a080e9745093bd74b98c7b70 (patch) | |
tree | 494ba8044b596c2cef32c1c326dc94fb848da87e /src | |
parent | b0b173f897b1f2b015667c96f37b8bc383f2c12a (diff) | |
download | gnunet-ce1f13b0c623d222a080e9745093bd74b98c7b70.tar.gz gnunet-ce1f13b0c623d222a080e9745093bd74b98c7b70.zip |
- remove unnecessary code
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/mesh2_api.c | 204 |
1 files changed, 0 insertions, 204 deletions
diff --git a/src/mesh/mesh2_api.c b/src/mesh/mesh2_api.c index c847bc419..2956fecf3 100644 --- a/src/mesh/mesh2_api.c +++ b/src/mesh/mesh2_api.c | |||
@@ -95,12 +95,6 @@ struct GNUNET_MESH_TransmitHandle | |||
95 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 95 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Target of the message, 0 for multicast. This field | ||
99 | * is only valid if 'notify' is non-NULL. | ||
100 | */ | ||
101 | GNUNET_PEER_Id target; | ||
102 | |||
103 | /** | ||
104 | * Size of 'data' -- or the desired size of 'notify' if 'data' is NULL. | 98 | * Size of 'data' -- or the desired size of 'notify' if 'data' is NULL. |
105 | */ | 99 | */ |
106 | size_t size; | 100 | size_t size; |
@@ -1491,30 +1485,6 @@ send_callback (void *cls, size_t size, void *buf) | |||
1491 | memcpy (cbuf, &to, sizeof (to)); | 1485 | memcpy (cbuf, &to, sizeof (to)); |
1492 | } | 1486 | } |
1493 | } | 1487 | } |
1494 | else if (th->target == 0) | ||
1495 | { | ||
1496 | /* multicast */ | ||
1497 | struct GNUNET_MESH_Multicast mc; | ||
1498 | struct GNUNET_MessageHeader *mh; | ||
1499 | |||
1500 | GNUNET_assert (size >= th->size); | ||
1501 | mh = (struct GNUNET_MessageHeader *) &cbuf[sizeof (mc)]; | ||
1502 | psize = th->notify (th->notify_cls, size - sizeof (mc), mh); | ||
1503 | LOG (GNUNET_ERROR_TYPE_DEBUG, " multicast, type %s\n", | ||
1504 | GNUNET_MESH_DEBUG_M2S (ntohs (mh->type))); | ||
1505 | if (psize > 0) | ||
1506 | { | ||
1507 | psize += sizeof (mc); | ||
1508 | GNUNET_assert (size >= psize); | ||
1509 | mc.header.size = htons (psize); | ||
1510 | mc.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_MULTICAST); | ||
1511 | mc.tid = htonl (t->tid); | ||
1512 | mc.pid = htonl (t->next_send_pid); | ||
1513 | mc.ttl = 0; | ||
1514 | memset (&mc.oid, 0, sizeof (struct GNUNET_PeerIdentity)); | ||
1515 | memcpy (cbuf, &mc, sizeof (mc)); | ||
1516 | } | ||
1517 | } | ||
1518 | else | 1488 | else |
1519 | { | 1489 | { |
1520 | /* unicast */ | 1490 | /* unicast */ |
@@ -1977,177 +1947,6 @@ GNUNET_MESH_tunnel_buffer (struct GNUNET_MESH_Tunnel *tunnel, int buffer) | |||
1977 | } | 1947 | } |
1978 | 1948 | ||
1979 | 1949 | ||
1980 | /** | ||
1981 | * Request that a peer should be added to the tunnel. The existing | ||
1982 | * connect handler will be called ONCE with either success or failure. | ||
1983 | * This function should NOT be called again with the same peer before the | ||
1984 | * connect handler is called. | ||
1985 | * FIXME: I think the above documentation is false. I think it should | ||
1986 | * read: "The connect handler will be called once the peer was actually | ||
1987 | * successfully added to the multicast group. This function should | ||
1988 | * not be called twice for the same peer (unless, of course, | ||
1989 | * the peer was removed using GNUNET_MESH_peer_Request_connect_del in | ||
1990 | * the meantime). | ||
1991 | * | ||
1992 | * @param tunnel handle to existing tunnel | ||
1993 | * @param peer peer to add | ||
1994 | */ | ||
1995 | void | ||
1996 | GNUNET_MESH_peer_request_connect_add (struct GNUNET_MESH_Tunnel *tunnel, | ||
1997 | const struct GNUNET_PeerIdentity *peer) | ||
1998 | { | ||
1999 | struct GNUNET_MESH_PeerControl msg; | ||
2000 | GNUNET_PEER_Id peer_id; | ||
2001 | unsigned int i; | ||
2002 | |||
2003 | peer_id = GNUNET_PEER_intern (peer); | ||
2004 | for (i = 0; i < tunnel->npeers; i++) | ||
2005 | { | ||
2006 | if (tunnel->peers[i]->id == peer_id) | ||
2007 | { | ||
2008 | /* Peer already exists in tunnel */ | ||
2009 | GNUNET_PEER_change_rc (peer_id, -1); | ||
2010 | GNUNET_break (0); | ||
2011 | return; | ||
2012 | } | ||
2013 | } | ||
2014 | if (NULL == add_peer_to_tunnel (tunnel, peer)) | ||
2015 | return; | ||
2016 | |||
2017 | msg.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); | ||
2018 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD); | ||
2019 | msg.tunnel_id = htonl (tunnel->tid); | ||
2020 | msg.peer = *peer; | ||
2021 | send_packet (tunnel->mesh, &msg.header, tunnel); | ||
2022 | } | ||
2023 | |||
2024 | |||
2025 | /** | ||
2026 | * Request that a peer should be removed from the tunnel. The existing | ||
2027 | * disconnect handler will be called ONCE if we were connected. | ||
2028 | * | ||
2029 | * @param tunnel handle to existing tunnel | ||
2030 | * @param peer peer to remove | ||
2031 | */ | ||
2032 | void | ||
2033 | GNUNET_MESH_peer_request_connect_del (struct GNUNET_MESH_Tunnel *tunnel, | ||
2034 | const struct GNUNET_PeerIdentity *peer) | ||
2035 | { | ||
2036 | struct GNUNET_MESH_PeerControl msg; | ||
2037 | GNUNET_PEER_Id peer_id; | ||
2038 | unsigned int i; | ||
2039 | |||
2040 | peer_id = GNUNET_PEER_search (peer); | ||
2041 | if (0 == peer_id) | ||
2042 | { | ||
2043 | GNUNET_break (0); | ||
2044 | return; | ||
2045 | } | ||
2046 | for (i = 0; i < tunnel->npeers; i++) | ||
2047 | if (tunnel->peers[i]->id == peer_id) | ||
2048 | break; | ||
2049 | if (i == tunnel->npeers) | ||
2050 | { | ||
2051 | GNUNET_break (0); | ||
2052 | return; | ||
2053 | } | ||
2054 | if (NULL != tunnel->disconnect_handler && tunnel->peers[i]->connected == 1) | ||
2055 | tunnel->disconnect_handler (tunnel->cls, peer); | ||
2056 | GNUNET_PEER_change_rc (peer_id, -1); | ||
2057 | GNUNET_free (tunnel->peers[i]); | ||
2058 | tunnel->peers[i] = tunnel->peers[tunnel->npeers - 1]; | ||
2059 | GNUNET_array_grow (tunnel->peers, tunnel->npeers, tunnel->npeers - 1); | ||
2060 | |||
2061 | msg.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); | ||
2062 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_DEL); | ||
2063 | msg.tunnel_id = htonl (tunnel->tid); | ||
2064 | memcpy (&msg.peer, peer, sizeof (struct GNUNET_PeerIdentity)); | ||
2065 | send_packet (tunnel->mesh, &msg.header, tunnel); | ||
2066 | } | ||
2067 | |||
2068 | /** | ||
2069 | * Request that the mesh should try to connect to a peer matching the | ||
2070 | * description given in the service string. | ||
2071 | * | ||
2072 | * FIXME: allow multiple? how to deal with reconnect? | ||
2073 | * | ||
2074 | * @param tunnel handle to existing tunnel | ||
2075 | * @param description string describing the destination node requirements | ||
2076 | */ | ||
2077 | void | ||
2078 | GNUNET_MESH_peer_request_connect_by_string (struct GNUNET_MESH_Tunnel *tunnel, | ||
2079 | const char *description) | ||
2080 | { | ||
2081 | struct GNUNET_MESH_ConnectPeerByString *m; | ||
2082 | size_t len; | ||
2083 | size_t msgsize; | ||
2084 | |||
2085 | len = strlen (description); | ||
2086 | msgsize = sizeof(struct GNUNET_MESH_ConnectPeerByString) + len; | ||
2087 | GNUNET_assert (UINT16_MAX > msgsize); | ||
2088 | { | ||
2089 | char buffer[msgsize]; | ||
2090 | |||
2091 | m = (struct GNUNET_MESH_ConnectPeerByString *) buffer; | ||
2092 | m->header.size = htons (msgsize); | ||
2093 | m->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_ADD_BY_STRING); | ||
2094 | m->tunnel_id = htonl (tunnel->tid); | ||
2095 | memcpy(&m[1], description, len); | ||
2096 | |||
2097 | send_packet (tunnel->mesh, &m->header, tunnel); | ||
2098 | } | ||
2099 | } | ||
2100 | |||
2101 | |||
2102 | /** | ||
2103 | * Request that the given peer isn't added to this tunnel in calls to | ||
2104 | * connect_by_* calls, (due to misbehaviour, bad performance, ...). | ||
2105 | * | ||
2106 | * @param tunnel handle to existing tunnel. | ||
2107 | * @param peer peer identity of the peer which should be blacklisted | ||
2108 | * for the tunnel. | ||
2109 | */ | ||
2110 | void | ||
2111 | GNUNET_MESH_peer_blacklist (struct GNUNET_MESH_Tunnel *tunnel, | ||
2112 | const struct GNUNET_PeerIdentity *peer) | ||
2113 | { | ||
2114 | struct GNUNET_MESH_PeerControl msg; | ||
2115 | |||
2116 | msg.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); | ||
2117 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_BLACKLIST); | ||
2118 | msg.tunnel_id = htonl (tunnel->tid); | ||
2119 | msg.peer = *peer; | ||
2120 | send_packet (tunnel->mesh, &msg.header, tunnel); | ||
2121 | |||
2122 | return; | ||
2123 | } | ||
2124 | |||
2125 | |||
2126 | /** | ||
2127 | * Request that the given peer isn't blacklisted anymore from this tunnel, | ||
2128 | * and therefore can be added in future calls to connect_by_*. | ||
2129 | * The peer must have been previously blacklisted for this tunnel. | ||
2130 | * | ||
2131 | * @param tunnel handle to existing tunnel. | ||
2132 | * @param peer peer identity of the peer which shouldn't be blacklisted | ||
2133 | * for the tunnel anymore. | ||
2134 | */ | ||
2135 | void | ||
2136 | GNUNET_MESH_peer_unblacklist (struct GNUNET_MESH_Tunnel *tunnel, | ||
2137 | const struct GNUNET_PeerIdentity *peer) | ||
2138 | { | ||
2139 | struct GNUNET_MESH_PeerControl msg; | ||
2140 | |||
2141 | msg.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); | ||
2142 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_UNBLACKLIST); | ||
2143 | msg.tunnel_id = htonl (tunnel->tid); | ||
2144 | msg.peer = *peer; | ||
2145 | send_packet (tunnel->mesh, &msg.header, tunnel); | ||
2146 | |||
2147 | return; | ||
2148 | } | ||
2149 | |||
2150 | |||
2151 | struct GNUNET_MESH_TransmitHandle * | 1950 | struct GNUNET_MESH_TransmitHandle * |
2152 | GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork, | 1951 | GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork, |
2153 | struct GNUNET_TIME_Relative maxdelay, | 1952 | struct GNUNET_TIME_Relative maxdelay, |
@@ -2171,11 +1970,8 @@ GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork, | |||
2171 | th = GNUNET_malloc (sizeof (struct GNUNET_MESH_TransmitHandle)); | 1970 | th = GNUNET_malloc (sizeof (struct GNUNET_MESH_TransmitHandle)); |
2172 | th->tunnel = tunnel; | 1971 | th->tunnel = tunnel; |
2173 | th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); | 1972 | th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay); |
2174 | th->target = GNUNET_PEER_intern (target); | ||
2175 | if (tunnel->tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) | 1973 | if (tunnel->tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) |
2176 | overhead = sizeof (struct GNUNET_MESH_ToOrigin); | 1974 | overhead = sizeof (struct GNUNET_MESH_ToOrigin); |
2177 | else if (NULL == target) | ||
2178 | overhead = sizeof (struct GNUNET_MESH_Multicast); | ||
2179 | else | 1975 | else |
2180 | overhead = sizeof (struct GNUNET_MESH_Unicast); | 1976 | overhead = sizeof (struct GNUNET_MESH_Unicast); |
2181 | tunnel->packet_size = th->size = notify_size + overhead; | 1977 | tunnel->packet_size = th->size = notify_size + overhead; |