diff options
Diffstat (limited to 'src/include/gnunet_transport_core_service.h')
-rw-r--r-- | src/include/gnunet_transport_core_service.h | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/src/include/gnunet_transport_core_service.h b/src/include/gnunet_transport_core_service.h index 816d5efaa..6dada4f54 100644 --- a/src/include/gnunet_transport_core_service.h +++ b/src/include/gnunet_transport_core_service.h | |||
@@ -50,49 +50,41 @@ extern "C" | |||
50 | 50 | ||
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Function called by the transport for each received message. | ||
54 | * | ||
55 | * @param cls closure | ||
56 | * @param peer (claimed) identity of the other peer | ||
57 | * @param message the message | ||
58 | */ | ||
59 | typedef void | ||
60 | (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls, | ||
61 | const struct GNUNET_PeerIdentity *peer, | ||
62 | const struct GNUNET_MessageHeader *message); | ||
63 | |||
64 | |||
65 | /** | ||
66 | * Opaque handle to the service. | 53 | * Opaque handle to the service. |
67 | */ | 54 | */ |
68 | struct GNUNET_TRANSPORT_Handle; | 55 | struct GNUNET_TRANSPORT_CoreHandle; |
69 | 56 | ||
70 | 57 | ||
71 | /** | 58 | /** |
72 | * Function called to notify CORE service that another | 59 | * Function called to notify transport users that another |
73 | * @a peer connected to us. | 60 | * peer connected to us. |
74 | * | 61 | * |
75 | * @param cls closure | 62 | * @param cls closure |
76 | * @param peer the peer that connected, never NULL | 63 | * @param peer the peer that connected |
77 | * @param mq message queue for sending messages to this peer | 64 | * @param mq message queue to use to transmit to @a peer |
65 | * @return closure to use in MQ handlers | ||
78 | */ | 66 | */ |
79 | typedef void | 67 | typedef void * |
80 | (*GNUNET_TRANSPORT_NotifyConnect) (void *cls, | 68 | (*GNUNET_TRANSPORT_NotifyConnecT) (void *cls, |
81 | const struct GNUNET_PeerIdentity *peer, | 69 | const struct GNUNET_PeerIdentity *peer, |
82 | struct GNUNET_MQ_Handle *mq); | 70 | struct GNUNET_MQ_Handle *mq); |
83 | 71 | ||
84 | 72 | ||
85 | /** | 73 | /** |
86 | * Function called to notify CORE service that another | 74 | * Function called to notify transport users that another peer |
87 | * @a peer disconnected from us. The associated message | 75 | * disconnected from us. The message queue that was given to the |
88 | * queue must not be used henceforth. | 76 | * connect notification will be destroyed and must not be used |
77 | * henceforth. | ||
89 | * | 78 | * |
90 | * @param cls closure | 79 | * @param cls closure from #GNUNET_TRANSPORT_connecT |
91 | * @param peer the peer that disconnected, never NULL | 80 | * @param peer the peer that disconnected |
81 | * @param handlers_cls closure of the handlers, was returned from the | ||
82 | * connect notification callback | ||
92 | */ | 83 | */ |
93 | typedef void | 84 | typedef void |
94 | (*GNUNET_TRANSPORT_NotifyDisconnect) (void *cls, | 85 | (*GNUNET_TRANSPORT_NotifyDisconnecT) (void *cls, |
95 | const struct GNUNET_PeerIdentity *peer); | 86 | const struct GNUNET_PeerIdentity *peer, |
87 | void *handler_cls); | ||
96 | 88 | ||
97 | 89 | ||
98 | /** | 90 | /** |
@@ -108,34 +100,41 @@ typedef void | |||
108 | * | 100 | * |
109 | * @param cls the closure | 101 | * @param cls the closure |
110 | * @param neighbour peer that we have excess bandwidth to | 102 | * @param neighbour peer that we have excess bandwidth to |
103 | * @param handlers_cls closure of the handlers, was returned from the | ||
104 | * connect notification callback | ||
111 | */ | 105 | */ |
112 | typedef void | 106 | typedef void |
113 | (*GNUNET_TRANSPORT_NotifyExcessBandwidth)(void *cls, | 107 | (*GNUNET_TRANSPORT_NotifyExcessBandwidtH)(void *cls, |
114 | const struct GNUNET_PeerIdentity *neighbour); | 108 | const struct GNUNET_PeerIdentity *neighbour, |
109 | void *handlers_cls); | ||
110 | |||
115 | 111 | ||
116 | 112 | ||
117 | /** | 113 | /** |
118 | * Connect to the transport service. | 114 | * Connect to the transport service. Note that the connection may |
115 | * complete (or fail) asynchronously. | ||
119 | * | 116 | * |
120 | * @param cfg configuration to use | 117 | * @param cfg configuration to use |
121 | * @param self our own identity (if API should check that it matches | 118 | * @param self our own identity (API should check that it matches |
122 | * the identity found by transport), or NULL (no check) | 119 | * the identity found by transport), or NULL (no check) |
123 | * @param cls closure for the callbacks | 120 | * @param handlers array of message handlers; note that the |
124 | * @param rec_handlers NULL-terminated array of handlers for incoming | 121 | * closures provided will be ignored and replaced |
125 | * messages, or NULL | 122 | * with the respective return value from @a nc |
123 | * @param handlers array with handlers to call when we receive messages, or NULL | ||
124 | * @param cls closure for the @a nc, @a nd and @a neb callbacks | ||
126 | * @param nc function to call on connect events, or NULL | 125 | * @param nc function to call on connect events, or NULL |
127 | * @param nd function to call on disconnect events, or NULL | 126 | * @param nd function to call on disconnect events, or NULL |
128 | * @param neb function to call if we have excess bandwidth to a peer | 127 | * @param neb function to call if we have excess bandwidth to a peer, or NULL |
129 | * @return NULL on error | 128 | * @return NULL on error |
130 | */ | 129 | */ |
131 | struct GNUNET_TRANSPORT_Handle * | 130 | struct GNUNET_TRANSPORT_CoreHandle * |
132 | GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 131 | GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
133 | const struct GNUNET_PeerIdentity *self, | 132 | const struct GNUNET_PeerIdentity *self, |
133 | const struct GNUNET_MQ_MessageHandler *handlers, | ||
134 | void *cls, | 134 | void *cls, |
135 | GNUNET_MQ_MessageHandler *rec_handlers, | 135 | GNUNET_TRANSPORT_NotifyConnecT nc, |
136 | GNUNET_TRANSPORT_NotifyConnect nc, | 136 | GNUNET_TRANSPORT_NotifyDisconnecT nd, |
137 | GNUNET_TRANSPORT_NotifyDisconnect nd, | 137 | GNUNET_TRANSPORT_NotifyExcessBandwidtH neb); |
138 | GNUNET_TRANSPORT_NotifyExcessBandwidth neb); | ||
139 | 138 | ||
140 | 139 | ||
141 | /** | 140 | /** |
@@ -144,22 +143,19 @@ GNUNET_TRANSPORT_core_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
144 | * @param handle handle returned from connect | 143 | * @param handle handle returned from connect |
145 | */ | 144 | */ |
146 | void | 145 | void |
147 | GNUNET_TRANSPORT_disconnect (struct GNUNET_TRANSPORT_Handle *handle); | 146 | GNUNET_TRANSPORT_core_disconnect (struct GNUNET_TRANSPORT_CoreHandle *handle); |
148 | 147 | ||
149 | 148 | ||
150 | /** | 149 | /** |
151 | * Checks if a given peer is connected to us. Convenience | 150 | * Checks if a given peer is connected to us and get the message queue. |
152 | * API in case a client does not track connect/disconnect | ||
153 | * events internally. | ||
154 | * | 151 | * |
155 | * @param handle connection to transport service | 152 | * @param handle connection to transport service |
156 | * @param peer the peer to check | 153 | * @param peer the peer to check |
157 | * @return #GNUNET_YES (connected) or #GNUNET_NO (disconnected) | 154 | * @return NULL if disconnected, otherwise message queue for @a peer |
158 | */ | 155 | */ |
159 | int | 156 | struct GNUNET_MQ_Handle * |
160 | GNUNET_TRANSPORT_check_peer_connected (struct GNUNET_TRANSPORT_Handle *handle, | 157 | GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle, |
161 | const struct GNUNET_PeerIdentity *peer); | 158 | const struct GNUNET_PeerIdentity *peer); |
162 | |||
163 | 159 | ||
164 | 160 | ||
165 | #if 0 /* keep Emacsens' auto-indent happy */ | 161 | #if 0 /* keep Emacsens' auto-indent happy */ |