aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_unix.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-02-13 16:02:44 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-02-13 16:02:44 +0000
commit2e2e5b4a8e5cebd71b880da8c613be4a49f44fe2 (patch)
tree270c64858fd4494c0d62970b7aa5926d185cef46 /src/transport/plugin_transport_unix.c
parent5b9e61b9c3832e69164ee8574fff6711b2f18ef6 (diff)
downloadgnunet-2e2e5b4a8e5cebd71b880da8c613be4a49f44fe2.tar.gz
gnunet-2e2e5b4a8e5cebd71b880da8c613be4a49f44fe2.zip
removing legacy send functions from plugins and renaming new send function
Diffstat (limited to 'src/transport/plugin_transport_unix.c')
-rw-r--r--src/transport/plugin_transport_unix.c101
1 files changed, 1 insertions, 100 deletions
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index c2f113b7c..9f717f649 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -636,104 +636,6 @@ unix_plugin_send (void *cls,
636 636
637 637
638/** 638/**
639 * Function that can be used by the transport service to transmit
640 * a message using the plugin.
641 *
642 * @param cls closure
643 * @param target who should receive this message (ignored by UNIX)
644 * @param msgbuf one or more GNUNET_MessageHeader(s) strung together
645 * @param msgbuf_size the size of the msgbuf to send
646 * @param priority how important is the message (ignored by UNIX)
647 * @param timeout when should we time out (give up) if we can not transmit?
648 * @param session identifier used for this session (can be NULL)
649 * @param addr the addr to send the message to, needs to be a sockaddr for us
650 * @param addrlen the len of addr
651 * @param force_address not used, we had better have an address to send to
652 * because we are stateless!!
653 * @param cont continuation to call once the message has
654 * been transmitted (or if the transport is ready
655 * for the next transmission call; or if the
656 * peer disconnected...)
657 * @param cont_cls closure for cont
658 *
659 * @return the number of bytes written (may return 0 and the message can
660 * still be transmitted later!)
661 */
662static ssize_t
663unix_plugin_send_old (void *cls, const struct GNUNET_PeerIdentity *target,
664 const char *msgbuf, size_t msgbuf_size, unsigned int priority,
665 struct GNUNET_TIME_Relative timeout, struct Session *session,
666 const void *addr, size_t addrlen, int force_address,
667 GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
668{
669 struct Plugin *plugin = cls;
670 struct UNIXMessage *message;
671 struct UNIXMessageWrapper *wrapper;
672 int ssize;
673 struct gsi_ctx gsi;
674
675 /* Build the message to be sent */
676 wrapper = GNUNET_malloc (sizeof (struct UNIXMessageWrapper) + addrlen);
677 message = GNUNET_malloc (sizeof (struct UNIXMessage) + msgbuf_size);
678 ssize = sizeof (struct UNIXMessage) + msgbuf_size;
679
680#if DEBUG_UNIX
681 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to send message to `%s'\n",
682 (char *) addr);
683#endif
684
685 message->header.size = htons (ssize);
686 message->header.type = htons (0);
687 memcpy (&message->sender, plugin->env->my_identity,
688 sizeof (struct GNUNET_PeerIdentity));
689 memcpy (&message[1], msgbuf, msgbuf_size);
690
691 if (session == NULL)
692 {
693 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking for existing session\n");
694 gsi.address = (char *) addr;
695 gsi.addrlen = addrlen;
696 gsi.res = NULL;
697 GNUNET_CONTAINER_multihashmap_get_multiple (plugin->session_map, &target->hashPubKey, &get_session_it, &gsi);
698 wrapper->session = gsi.res;
699 if (gsi.res == NULL)
700 {
701 wrapper->session = GNUNET_malloc (sizeof (struct Session) + addrlen);
702 wrapper->session->addr = &wrapper->session[1];
703 wrapper->session->addrlen = addrlen;
704 memcpy(wrapper->session->addr, addr, wrapper->session->addrlen);
705 memcpy(&wrapper->session->target, target, sizeof (struct GNUNET_PeerIdentity));
706 GNUNET_CONTAINER_multihashmap_put (plugin->session_map,
707 &target->hashPubKey, wrapper->session,
708 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
709
710 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created new session for `%s'\n", addr);
711 }
712 else
713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found existing session\n");
714
715 }
716 else
717 wrapper->session = session;
718
719 wrapper->msg = message;
720 wrapper->msgsize = ssize;
721 wrapper->priority = priority;
722 wrapper->timeout = timeout;
723 wrapper->cont = cont;
724 wrapper->cont_cls = cont_cls;
725 wrapper->retry_counter = 0;
726 GNUNET_CONTAINER_DLL_insert(plugin->msg_head, plugin->msg_tail, wrapper);
727
728#if DEBUG_UNIX
729 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %d bytes to `%s'\n", ssize,
730 (char *) addr);
731#endif
732 return ssize;
733}
734
735
736/**
737 * Demultiplexer for UNIX messages 639 * Demultiplexer for UNIX messages
738 * 640 *
739 * @param plugin the main plugin for this transport 641 * @param plugin the main plugin for this transport
@@ -1121,8 +1023,7 @@ libgnunet_plugin_transport_unix_init (void *cls)
1121 api->cls = plugin; 1023 api->cls = plugin;
1122 1024
1123 api->get_session = &unix_plugin_get_session; 1025 api->get_session = &unix_plugin_get_session;
1124 api->send_with_session = &unix_plugin_send; 1026 api->send = &unix_plugin_send;
1125 api->send = &unix_plugin_send_old;
1126 api->disconnect = &unix_disconnect; 1027 api->disconnect = &unix_disconnect;
1127 api->address_pretty_printer = &unix_plugin_address_pretty_printer; 1028 api->address_pretty_printer = &unix_plugin_address_pretty_printer;
1128 api->address_to_string = &unix_address_to_string; 1029 api->address_to_string = &unix_address_to_string;