diff options
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 2 | ||||
-rw-r--r-- | src/transport/plugin_transport_udp.c | 68 | ||||
-rw-r--r-- | src/transport/plugin_transport_unix.c | 67 |
3 files changed, 132 insertions, 5 deletions
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index d1b68be2f..786dca9f9 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -63,7 +63,7 @@ | |||
63 | 63 | ||
64 | #define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) | 64 | #define SETUP_CONNECTION_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) |
65 | 65 | ||
66 | #define TEST_NEW_CODE GNUNET_YES | 66 | #define TEST_NEW_CODE GNUNET_NO |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Entry in neighbours. | 69 | * Entry in neighbours. |
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 7e28dd98b..486f72364 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -618,6 +618,67 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
618 | 618 | ||
619 | 619 | ||
620 | /** | 620 | /** |
621 | * Creates a new outbound session the transport service will use to send data to the | ||
622 | * peer | ||
623 | * | ||
624 | * @param cls the plugin | ||
625 | * @param address the address | ||
626 | * @return the session or NULL of max connections exceeded | ||
627 | */ | ||
628 | |||
629 | static struct Session * | ||
630 | udp_plugin_get_session (void *cls, | ||
631 | const struct GNUNET_HELLO_Address *address) | ||
632 | { | ||
633 | struct Session * s = NULL; | ||
634 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "To be implemented\n"); | ||
635 | GNUNET_break (0); | ||
636 | return s; | ||
637 | } | ||
638 | |||
639 | /** | ||
640 | * Function that can be used by the transport service to transmit | ||
641 | * a message using the plugin. Note that in the case of a | ||
642 | * peer disconnecting, the continuation MUST be called | ||
643 | * prior to the disconnect notification itself. This function | ||
644 | * will be called with this peer's HELLO message to initiate | ||
645 | * a fresh connection to another peer. | ||
646 | * | ||
647 | * @param cls closure | ||
648 | * @param session which session must be used | ||
649 | * @param msgbuf the message to transmit | ||
650 | * @param msgbuf_size number of bytes in 'msgbuf' | ||
651 | * @param priority how important is the message (most plugins will | ||
652 | * ignore message priority and just FIFO) | ||
653 | * @param to how long to wait at most for the transmission (does not | ||
654 | * require plugins to discard the message after the timeout, | ||
655 | * just advisory for the desired delay; most plugins will ignore | ||
656 | * this as well) | ||
657 | * @param cont continuation to call once the message has | ||
658 | * been transmitted (or if the transport is ready | ||
659 | * for the next transmission call; or if the | ||
660 | * peer disconnected...); can be NULL | ||
661 | * @param cont_cls closure for cont | ||
662 | * @return number of bytes used (on the physical network, with overheads); | ||
663 | * -1 on hard errors (i.e. address invalid); 0 is a legal value | ||
664 | * and does NOT mean that the message was not transmitted (DV) | ||
665 | */ | ||
666 | static ssize_t | ||
667 | udp_plugin_send (void *cls, | ||
668 | struct Session *session, | ||
669 | const char *msgbuf, size_t msgbuf_size, | ||
670 | unsigned int priority, | ||
671 | struct GNUNET_TIME_Relative to, | ||
672 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | ||
673 | { | ||
674 | ssize_t sent = -1; | ||
675 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "To be implemented\n"); | ||
676 | GNUNET_break (0); | ||
677 | return sent; | ||
678 | } | ||
679 | |||
680 | |||
681 | /** | ||
621 | * Actually send out the message. | 682 | * Actually send out the message. |
622 | * | 683 | * |
623 | * @param plugin the plugin | 684 | * @param plugin the plugin |
@@ -799,7 +860,7 @@ udp_call_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
799 | * still be transmitted later!) | 860 | * still be transmitted later!) |
800 | */ | 861 | */ |
801 | static ssize_t | 862 | static ssize_t |
802 | udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | 863 | udp_plugin_send_old (void *cls, const struct GNUNET_PeerIdentity *target, |
803 | const char *msgbuf, size_t msgbuf_size, unsigned int priority, | 864 | const char *msgbuf, size_t msgbuf_size, unsigned int priority, |
804 | struct GNUNET_TIME_Relative timeout, struct Session *session, | 865 | struct GNUNET_TIME_Relative timeout, struct Session *session, |
805 | const void *addr, size_t addrlen, int force_address, | 866 | const void *addr, size_t addrlen, int force_address, |
@@ -2122,12 +2183,15 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2122 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 2183 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); |
2123 | api->cls = plugin; | 2184 | api->cls = plugin; |
2124 | 2185 | ||
2125 | api->send = &udp_plugin_send; | 2186 | api->send = &udp_plugin_send_old; |
2126 | api->disconnect = &udp_disconnect; | 2187 | api->disconnect = &udp_disconnect; |
2127 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; | 2188 | api->address_pretty_printer = &udp_plugin_address_pretty_printer; |
2128 | api->address_to_string = &udp_address_to_string; | 2189 | api->address_to_string = &udp_address_to_string; |
2129 | api->check_address = &udp_plugin_check_address; | 2190 | api->check_address = &udp_plugin_check_address; |
2130 | 2191 | ||
2192 | api->get_session = &udp_plugin_get_session; | ||
2193 | api->send_with_session = &udp_plugin_send; | ||
2194 | |||
2131 | if (GNUNET_YES == | 2195 | if (GNUNET_YES == |
2132 | GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-udp", | 2196 | GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-udp", |
2133 | "BINDTO", &plugin->bind4_address)) | 2197 | "BINDTO", &plugin->bind4_address)) |
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index aebfeb883..7d41b95a7 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -659,6 +659,67 @@ unix_real_send (void *cls, struct RetrySendContext *incoming_retry_context, | |||
659 | 659 | ||
660 | 660 | ||
661 | /** | 661 | /** |
662 | * Creates a new outbound session the transport service will use to send data to the | ||
663 | * peer | ||
664 | * | ||
665 | * @param cls the plugin | ||
666 | * @param address the address | ||
667 | * @return the session or NULL of max connections exceeded | ||
668 | */ | ||
669 | |||
670 | static struct Session * | ||
671 | unix_plugin_get_session (void *cls, | ||
672 | const struct GNUNET_HELLO_Address *address) | ||
673 | { | ||
674 | struct Session * s = NULL; | ||
675 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "To be implemented\n"); | ||
676 | GNUNET_break (0); | ||
677 | return s; | ||
678 | } | ||
679 | |||
680 | /** | ||
681 | * Function that can be used by the transport service to transmit | ||
682 | * a message using the plugin. Note that in the case of a | ||
683 | * peer disconnecting, the continuation MUST be called | ||
684 | * prior to the disconnect notification itself. This function | ||
685 | * will be called with this peer's HELLO message to initiate | ||
686 | * a fresh connection to another peer. | ||
687 | * | ||
688 | * @param cls closure | ||
689 | * @param session which session must be used | ||
690 | * @param msgbuf the message to transmit | ||
691 | * @param msgbuf_size number of bytes in 'msgbuf' | ||
692 | * @param priority how important is the message (most plugins will | ||
693 | * ignore message priority and just FIFO) | ||
694 | * @param to how long to wait at most for the transmission (does not | ||
695 | * require plugins to discard the message after the timeout, | ||
696 | * just advisory for the desired delay; most plugins will ignore | ||
697 | * this as well) | ||
698 | * @param cont continuation to call once the message has | ||
699 | * been transmitted (or if the transport is ready | ||
700 | * for the next transmission call; or if the | ||
701 | * peer disconnected...); can be NULL | ||
702 | * @param cont_cls closure for cont | ||
703 | * @return number of bytes used (on the physical network, with overheads); | ||
704 | * -1 on hard errors (i.e. address invalid); 0 is a legal value | ||
705 | * and does NOT mean that the message was not transmitted (DV) | ||
706 | */ | ||
707 | static ssize_t | ||
708 | unix_plugin_send (void *cls, | ||
709 | struct Session *session, | ||
710 | const char *msgbuf, size_t msgbuf_size, | ||
711 | unsigned int priority, | ||
712 | struct GNUNET_TIME_Relative to, | ||
713 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | ||
714 | { | ||
715 | ssize_t sent = -1; | ||
716 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "To be implemented\n"); | ||
717 | GNUNET_break (0); | ||
718 | return sent; | ||
719 | } | ||
720 | |||
721 | |||
722 | /** | ||
662 | * Function that can be used by the transport service to transmit | 723 | * Function that can be used by the transport service to transmit |
663 | * a message using the plugin. | 724 | * a message using the plugin. |
664 | * | 725 | * |
@@ -683,7 +744,7 @@ unix_real_send (void *cls, struct RetrySendContext *incoming_retry_context, | |||
683 | * still be transmitted later!) | 744 | * still be transmitted later!) |
684 | */ | 745 | */ |
685 | static ssize_t | 746 | static ssize_t |
686 | unix_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | 747 | unix_plugin_send_old (void *cls, const struct GNUNET_PeerIdentity *target, |
687 | const char *msgbuf, size_t msgbuf_size, unsigned int priority, | 748 | const char *msgbuf, size_t msgbuf_size, unsigned int priority, |
688 | struct GNUNET_TIME_Relative timeout, struct Session *session, | 749 | struct GNUNET_TIME_Relative timeout, struct Session *session, |
689 | const void *addr, size_t addrlen, int force_address, | 750 | const void *addr, size_t addrlen, int force_address, |
@@ -1086,7 +1147,9 @@ libgnunet_plugin_transport_unix_init (void *cls) | |||
1086 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 1147 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); |
1087 | api->cls = plugin; | 1148 | api->cls = plugin; |
1088 | 1149 | ||
1089 | api->send = &unix_plugin_send; | 1150 | api->get_session = &unix_plugin_get_session; |
1151 | api->send_with_session = &unix_plugin_send; | ||
1152 | api->send = &unix_plugin_send_old; | ||
1090 | api->disconnect = &unix_disconnect; | 1153 | api->disconnect = &unix_disconnect; |
1091 | api->address_pretty_printer = &unix_plugin_address_pretty_printer; | 1154 | api->address_pretty_printer = &unix_plugin_address_pretty_printer; |
1092 | api->address_to_string = &unix_address_to_string; | 1155 | api->address_to_string = &unix_address_to_string; |