diff options
Diffstat (limited to 'src/dv/dv_api.c')
-rw-r--r-- | src/dv/dv_api.c | 148 |
1 files changed, 138 insertions, 10 deletions
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index d3cdb0fb7..ca4334f2f 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009, 2010 Christian Grothoff (and other contributing authors) | 3 | (C) 2009--2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -25,21 +25,147 @@ | |||
25 | * @author Nathan Evans | 25 | * @author Nathan Evans |
26 | */ | 26 | */ |
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "gnunet_bandwidth_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_client_lib.h" | ||
30 | #include "gnunet_constants.h" | ||
31 | #include "gnunet_container_lib.h" | ||
32 | #include "gnunet_arm_service.h" | ||
33 | #include "gnunet_hello_lib.h" | ||
34 | #include "gnunet_protocols.h" | ||
35 | #include "gnunet_server_lib.h" | ||
36 | #include "gnunet_time_lib.h" | ||
37 | #include "gnunet_dv_service.h" | 29 | #include "gnunet_dv_service.h" |
30 | #include "gnunet_protocols.h" | ||
38 | #include "dv.h" | 31 | #include "dv.h" |
39 | #include "gnunet_transport_plugin.h" | 32 | #include "gnunet_transport_plugin.h" |
40 | 33 | ||
41 | #define LOG(kind,...) GNUNET_log_from (kind, "dv-api",__VA_ARGS__) | 34 | #define LOG(kind,...) GNUNET_log_from (kind, "dv-api",__VA_ARGS__) |
42 | 35 | ||
36 | |||
37 | /** | ||
38 | * Handle for a send operation. | ||
39 | */ | ||
40 | struct GNUNET_DV_TransmitHandle | ||
41 | { | ||
42 | struct GNUNET_DV_TransmitHandle *next; | ||
43 | |||
44 | struct GNUNET_DV_TransmitHandle *prev; | ||
45 | |||
46 | struct GNUNET_DV_ServiceHandle *sh; | ||
47 | |||
48 | GNUNET_DV_MessageSentCallback cb; | ||
49 | |||
50 | void *cb_cls; | ||
51 | |||
52 | const struct GNUNET_MessageHeader *msg; | ||
53 | |||
54 | struct GNUNET_PeerIdentity target; | ||
55 | |||
56 | }; | ||
57 | |||
58 | |||
59 | /** | ||
60 | * Handle to the DV service. | ||
61 | */ | ||
62 | struct GNUNET_DV_ServiceHandle | ||
63 | { | ||
64 | |||
65 | struct GNUNET_ClientHandle *client; | ||
66 | |||
67 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
68 | |||
69 | void *cls; | ||
70 | |||
71 | GNUNET_DV_ConnectCallback connect_cb; | ||
72 | |||
73 | GNUNET_DV_DisconnectCallback disconnect_cb; | ||
74 | |||
75 | GNUNET_DV_MessageReceivedCallback message_cb; | ||
76 | |||
77 | struct GNUNET_DV_TransmitHandle *th_head; | ||
78 | |||
79 | struct GNUNET_DV_TransmitHandle *th_tail; | ||
80 | |||
81 | }; | ||
82 | |||
83 | |||
84 | /** | ||
85 | * Connect to the DV service. | ||
86 | * | ||
87 | * @param cfg configuration | ||
88 | * @param cls closure for callbacks | ||
89 | * @param connect_cb function to call on connects | ||
90 | * @param disconnect_cb function to call on disconnects | ||
91 | * @param message_cb function to call if we receive messages | ||
92 | * @return handle to access the service | ||
93 | */ | ||
94 | struct GNUNET_DV_ServiceHandle * | ||
95 | GNUNET_DV_service_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
96 | void *cls, | ||
97 | GNUNET_DV_ConnectCallback connect_cb, | ||
98 | GNUNET_DV_DisconnectCallback disconnect_cb, | ||
99 | GNUNET_DV_MessageReceivedCallback message_cb) | ||
100 | { | ||
101 | GNUNET_break (0); | ||
102 | return NULL; | ||
103 | } | ||
104 | |||
105 | |||
106 | /** | ||
107 | * Disconnect from DV service. | ||
108 | * | ||
109 | * @param sh service handle | ||
110 | */ | ||
111 | void | ||
112 | GNUNET_DV_service_disconnect (struct GNUNET_DV_ServiceHandle *sh) | ||
113 | { | ||
114 | GNUNET_break (0); | ||
115 | } | ||
116 | |||
117 | |||
118 | |||
119 | /** | ||
120 | * Send a message via DV service. | ||
121 | * | ||
122 | * @param sh service handle | ||
123 | * @param target intended recpient | ||
124 | * @param msg message payload | ||
125 | * @param cb function to invoke when done | ||
126 | * @param cb_cls closure for 'cb' | ||
127 | * @return handle to cancel the operation | ||
128 | */ | ||
129 | struct GNUNET_DV_TransmitHandle * | ||
130 | GNUNET_DV_send (struct GNUNET_DV_ServiceHandle *sh, | ||
131 | const struct GNUNET_PeerIdentity *target, | ||
132 | const struct GNUNET_MessageHeader *msg, | ||
133 | GNUNET_DV_MessageSentCallback cb, | ||
134 | void *cb_cls) | ||
135 | { | ||
136 | GNUNET_break (0); | ||
137 | return NULL; | ||
138 | } | ||
139 | |||
140 | |||
141 | /** | ||
142 | * Abort send operation (naturally, the message may have | ||
143 | * already been transmitted; this only stops the 'cb' | ||
144 | * from being called again). | ||
145 | * | ||
146 | * @param th send operation to cancel | ||
147 | */ | ||
148 | void | ||
149 | GNUNET_DV_send_cancel (struct GNUNET_DV_TransmitHandle *th) | ||
150 | { | ||
151 | GNUNET_break (0); | ||
152 | } | ||
153 | |||
154 | |||
155 | |||
156 | #if 0 | ||
157 | |||
158 | |||
159 | |||
160 | |||
161 | |||
162 | |||
163 | |||
164 | |||
165 | |||
166 | |||
167 | |||
168 | |||
43 | /** | 169 | /** |
44 | * Store ready to send messages | 170 | * Store ready to send messages |
45 | */ | 171 | */ |
@@ -639,4 +765,6 @@ GNUNET_DV_disconnect (struct GNUNET_DV_Handle *handle) | |||
639 | GNUNET_free (handle); | 765 | GNUNET_free (handle); |
640 | } | 766 | } |
641 | 767 | ||
768 | #endif | ||
769 | |||
642 | /* end of dv_api.c */ | 770 | /* end of dv_api.c */ |