aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_tcp.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-01-26 15:32:28 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-01-26 15:32:28 +0000
commite511364a0c2dd06579c883d8ed87c7a4b6719509 (patch)
tree51b867ac253ef50816a54ea7aff0652199a2f43d /src/transport/plugin_transport_tcp.c
parent0545cda24a18d5120c2e3af9710410f1b65edc90 (diff)
downloadgnunet-e511364a0c2dd06579c883d8ed87c7a4b6719509.tar.gz
gnunet-e511364a0c2dd06579c883d8ed87c7a4b6719509.zip
- session sending in tcp
Diffstat (limited to 'src/transport/plugin_transport_tcp.c')
-rw-r--r--src/transport/plugin_transport_tcp.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 625747585..a2444504d 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -932,7 +932,7 @@ select_better_session (struct Session *s1, struct Session *s2)
932 * and does NOT mean that the message was not transmitted (DV and NAT) 932 * and does NOT mean that the message was not transmitted (DV and NAT)
933 */ 933 */
934static ssize_t 934static ssize_t
935tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, 935tcp_plugin_send_old (void *cls, const struct GNUNET_PeerIdentity *target,
936 const char *msg, size_t msgbuf_size, uint32_t priority, 936 const char *msg, size_t msgbuf_size, uint32_t priority,
937 struct GNUNET_TIME_Relative timeout, struct Session *session, 937 struct GNUNET_TIME_Relative timeout, struct Session *session,
938 const void *addr, size_t addrlen, int force_address, 938 const void *addr, size_t addrlen, int force_address,
@@ -1202,24 +1202,15 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
1202 * a fresh connection to another peer. 1202 * a fresh connection to another peer.
1203 * 1203 *
1204 * @param cls closure 1204 * @param cls closure
1205 * @param target who should receive this message 1205 * @param session which session must be used
1206 * @param msg the message to transmit 1206 * @param msgbuf the message to transmit
1207 * @param msgbuf_size number of bytes in 'msg' 1207 * @param msgbuf_size number of bytes in 'msgbuf'
1208 * @param priority how important is the message (most plugins will 1208 * @param priority how important is the message (most plugins will
1209 * ignore message priority and just FIFO) 1209 * ignore message priority and just FIFO)
1210 * @param timeout how long to wait at most for the transmission (does not 1210 * @param to how long to wait at most for the transmission (does not
1211 * require plugins to discard the message after the timeout, 1211 * require plugins to discard the message after the timeout,
1212 * just advisory for the desired delay; most plugins will ignore 1212 * just advisory for the desired delay; most plugins will ignore
1213 * this as well) 1213 * this as well)
1214 * @param session which session must be used (or NULL for "any")
1215 * @param addr the address to use (can be NULL if the plugin
1216 * is "on its own" (i.e. re-use existing TCP connection))
1217 * @param addrlen length of the address in bytes
1218 * @param force_address GNUNET_YES if the plugin MUST use the given address,
1219 * GNUNET_NO means the plugin may use any other address and
1220 * GNUNET_SYSERR means that only reliable existing
1221 * bi-directional connections should be used (regardless
1222 * of address)
1223 * @param cont continuation to call once the message has 1214 * @param cont continuation to call once the message has
1224 * been transmitted (or if the transport is ready 1215 * been transmitted (or if the transport is ready
1225 * for the next transmission call; or if the 1216 * for the next transmission call; or if the
@@ -1227,10 +1218,10 @@ tcp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
1227 * @param cont_cls closure for cont 1218 * @param cont_cls closure for cont
1228 * @return number of bytes used (on the physical network, with overheads); 1219 * @return number of bytes used (on the physical network, with overheads);
1229 * -1 on hard errors (i.e. address invalid); 0 is a legal value 1220 * -1 on hard errors (i.e. address invalid); 0 is a legal value
1230 * and does NOT mean that the message was not transmitted (DV and NAT) 1221 * and does NOT mean that the message was not transmitted (DV)
1231 */ 1222 */
1232static ssize_t 1223static ssize_t
1233tcp_plugin_send_new (void *cls, 1224tcp_plugin_send (void *cls,
1234 struct Session *session, 1225 struct Session *session,
1235 const char *msgbuf, size_t msgbuf_size, 1226 const char *msgbuf, size_t msgbuf_size,
1236 unsigned int priority, 1227 unsigned int priority,
@@ -1240,6 +1231,7 @@ tcp_plugin_send_new (void *cls,
1240 struct Plugin * plugin = cls; 1231 struct Plugin * plugin = cls;
1241 struct PendingMessage *pm; 1232 struct PendingMessage *pm;
1242 1233
1234 GNUNET_assert (plugin != NULL);
1243 GNUNET_assert (session != NULL); 1235 GNUNET_assert (session != NULL);
1244 GNUNET_assert (session->client != NULL); 1236 GNUNET_assert (session->client != NULL);
1245 1237
@@ -1306,7 +1298,7 @@ int session_it (void *cls,
1306 * @return the session if the address is valid, NULL otherwise 1298 * @return the session if the address is valid, NULL otherwise
1307 */ 1299 */
1308static struct Session * 1300static struct Session *
1309tcp_plugin_create_session (void *cls, 1301tcp_plugin_get_session (void *cls,
1310 const struct GNUNET_HELLO_Address *address) 1302 const struct GNUNET_HELLO_Address *address)
1311{ 1303{
1312 struct Plugin * plugin = cls; 1304 struct Plugin * plugin = cls;
@@ -2281,10 +2273,10 @@ libgnunet_plugin_transport_tcp_init (void *cls)
2281 } 2273 }
2282 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 2274 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
2283 api->cls = plugin; 2275 api->cls = plugin;
2284 api->send = &tcp_plugin_send; 2276 api->send = &tcp_plugin_send_old;
2285 2277
2286 api->send_with_session = &tcp_plugin_send_new; 2278 api->send_with_session = &tcp_plugin_send;
2287 api->get_session = &tcp_plugin_create_session; 2279 api->get_session = &tcp_plugin_get_session;
2288 2280
2289 api->disconnect = &tcp_plugin_disconnect; 2281 api->disconnect = &tcp_plugin_disconnect;
2290 api->address_pretty_printer = &tcp_plugin_address_pretty_printer; 2282 api->address_pretty_printer = &tcp_plugin_address_pretty_printer;