gnunet_stream_lib.h | gnunet_stream_lib.h | |||
---|---|---|---|---|
skipping to change at line 65 | skipping to change at line 65 | |||
/** | /** | |||
* Other side has shutdown the socket for this type of operation | * Other side has shutdown the socket for this type of operation | |||
* (reading/writing) | * (reading/writing) | |||
*/ | */ | |||
GNUNET_STREAM_SHUTDOWN = 2, | GNUNET_STREAM_SHUTDOWN = 2, | |||
/** | /** | |||
* A serious error occured while operating on this stream | * A serious error occured while operating on this stream | |||
*/ | */ | |||
GNUNET_STREAM_SYSERR = 3 | GNUNET_STREAM_SYSERR = 3, | |||
/** | ||||
* An error resulted in an unusable stream | ||||
*/ | ||||
GNUNET_STREAM_BROKEN | ||||
}; | }; | |||
/** | /** | |||
* Opaque handler for stream | * Opaque handler for stream | |||
*/ | */ | |||
struct GNUNET_STREAM_Socket; | struct GNUNET_STREAM_Socket; | |||
/** | /** | |||
* Functions of this type will be called when a stream is established | * Functions of this type will be called when a stream is established | |||
* | * | |||
skipping to change at line 125 | skipping to change at line 130 | |||
*/ | */ | |||
struct GNUNET_STREAM_Socket * | struct GNUNET_STREAM_Socket * | |||
GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg, | GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
const struct GNUNET_PeerIdentity *target, | const struct GNUNET_PeerIdentity *target, | |||
GNUNET_MESH_ApplicationType app_port, | GNUNET_MESH_ApplicationType app_port, | |||
GNUNET_STREAM_OpenCallback open_cb, | GNUNET_STREAM_OpenCallback open_cb, | |||
void *open_cb_cls, | void *open_cb_cls, | |||
...); | ...); | |||
/** | /** | |||
* Shutdown the stream for reading or writing (man 2 shutdown). | * Handle for shutdown | |||
*/ | ||||
struct GNUNET_STREAM_ShutdownHandle; | ||||
/** | ||||
* Completion callback for shutdown | ||||
* | ||||
* @param cls the closure from GNUNET_STREAM_shutdown call | ||||
* @param operation the operation that was shutdown (SHUT_RD, SHUT_WR, | ||||
* SHUT_RDWR) | ||||
*/ | ||||
typedef void (*GNUNET_STREAM_ShutdownCompletion) (void *cls, | ||||
int operation); | ||||
/** | ||||
* Shutdown the stream for reading or writing (similar to man 2 shutdown). | ||||
* | * | |||
* @param socket the stream socket | * @param socket the stream socket | |||
* @param how SHUT_RD, SHUT_WR or SHUT_RDWR | * @param operation SHUT_RD, SHUT_WR or SHUT_RDWR | |||
* @param completion_cb the callback that will be called upon successful | ||||
* shutdown of given operation | ||||
* @param completion_cls the closure for the completion callback | ||||
* @return the shutdown handle; NULL in case of any error | ||||
*/ | */ | |||
void | struct GNUNET_STREAM_ShutdownHandle * | |||
GNUNET_STREAM_shutdown (struct GNUNET_STREAM_Socket *socket, | GNUNET_STREAM_shutdown (struct GNUNET_STREAM_Socket *socket, | |||
int how); | int operation, | |||
GNUNET_STREAM_ShutdownCompletion completion_cb, | ||||
void *completion_cls); | ||||
/** | /** | |||
* Closes the stream | * Cancels a pending shutdown | |||
* | ||||
* @param handle the shutdown handle returned from GNUNET_STREAM_shutdown | ||||
*/ | ||||
void | ||||
GNUNET_STREAM_shutdown_cancel (struct GNUNET_STREAM_ShutdownHandle *handle) | ||||
; | ||||
/** | ||||
* Closes the stream and frees the associated state. The stream should be | ||||
* shutdown before closing. | ||||
* | * | |||
* @param socket the stream socket | * @param socket the stream socket | |||
*/ | */ | |||
void | void | |||
GNUNET_STREAM_close (struct GNUNET_STREAM_Socket *socket); | GNUNET_STREAM_close (struct GNUNET_STREAM_Socket *socket); | |||
/** | /** | |||
* Functions of this type are called upon new stream connection from other peers | * Functions of this type are called upon new stream connection from other peers | |||
* | * | |||
* @param cls the closure from GNUNET_STREAM_listen | * @param cls the closure from GNUNET_STREAM_listen | |||
skipping to change at line 181 | skipping to change at line 216 | |||
*/ | */ | |||
struct GNUNET_STREAM_ListenSocket * | struct GNUNET_STREAM_ListenSocket * | |||
GNUNET_STREAM_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, | GNUNET_STREAM_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
GNUNET_MESH_ApplicationType app_port, | GNUNET_MESH_ApplicationType app_port, | |||
GNUNET_STREAM_ListenCallback listen_cb, | GNUNET_STREAM_ListenCallback listen_cb, | |||
void *listen_cb_cls); | void *listen_cb_cls); | |||
/** | /** | |||
* Closes the listen socket | * Closes the listen socket | |||
* | * | |||
* @param socket the listen socket | * @param lsocket the listen socket | |||
*/ | */ | |||
void | void | |||
GNUNET_STREAM_listen_close (struct GNUNET_STREAM_ListenSocket *socket); | GNUNET_STREAM_listen_close (struct GNUNET_STREAM_ListenSocket *lsocket); | |||
/** | /** | |||
* Functions of this signature are called whenever writing operations | * Functions of this signature are called whenever writing operations | |||
* on a stream are executed | * on a stream are executed | |||
* | * | |||
* @param cls the closure from GNUNET_STREAM_write | * @param cls the closure from GNUNET_STREAM_write | |||
* @param status the status of the stream at the time this function is call ed | * @param status the status of the stream at the time this function is call ed | |||
* @param size the number of bytes written | * @param size the number of bytes written | |||
*/ | */ | |||
typedef void (*GNUNET_STREAM_CompletionContinuation) (void *cls, | typedef void (*GNUNET_STREAM_CompletionContinuation) (void *cls, | |||
skipping to change at line 210 | skipping to change at line 245 | |||
* Handle to cancel IO write operations. | * Handle to cancel IO write operations. | |||
*/ | */ | |||
struct GNUNET_STREAM_IOWriteHandle; | struct GNUNET_STREAM_IOWriteHandle; | |||
/** | /** | |||
* Handle to cancel IO read operations. | * Handle to cancel IO read operations. | |||
*/ | */ | |||
struct GNUNET_STREAM_IOReadHandle; | struct GNUNET_STREAM_IOReadHandle; | |||
/** | /** | |||
* Tries to write the given data to the stream | * Tries to write the given data to the stream. The maximum size of data th | |||
at | ||||
* can be written as part of a write operation is (64 * (64000 - sizeof (st | ||||
ruct | ||||
* GNUNET_STREAM_DataMessage))). If size is greater than this it is not an | ||||
API | ||||
* violation, however only the said number of maximum bytes will be written | ||||
. | ||||
* | * | |||
* @param socket the socket representing a stream | * @param socket the socket representing a stream | |||
* @param data the data buffer from where the data is written into the stre am | * @param data the data buffer from where the data is written into the stre am | |||
* @param size the number of bytes to be written from the data buffer | * @param size the number of bytes to be written from the data buffer | |||
* @param timeout the timeout period | * @param timeout the timeout period | |||
* @param write_cont the function to call upon writing some bytes into the | * @param write_cont the function to call upon writing some bytes into the | |||
stream | * stream | |||
* @param write_cont_cls the closure | * @param write_cont_cls the closure | |||
* @return handle to cancel the operation; NULL if a previous write is pend | * | |||
ing | * @return handle to cancel the operation; if a previous write is pending o | |||
r | ||||
* the stream has been shutdown for this operation then write_con | ||||
t is | ||||
* immediately called and NULL is returned. | ||||
*/ | */ | |||
struct GNUNET_STREAM_IOWriteHandle * | struct GNUNET_STREAM_IOWriteHandle * | |||
GNUNET_STREAM_write (struct GNUNET_STREAM_Socket *socket, | GNUNET_STREAM_write (struct GNUNET_STREAM_Socket *socket, | |||
const void *data, | const void *data, | |||
size_t size, | size_t size, | |||
struct GNUNET_TIME_Relative timeout, | struct GNUNET_TIME_Relative timeout, | |||
GNUNET_STREAM_CompletionContinuation write_cont, | GNUNET_STREAM_CompletionContinuation write_cont, | |||
void *write_cont_cls); | void *write_cont_cls); | |||
/** | /** | |||
* Functions of this signature are called whenever data is available from t he | * Functions of this signature are called whenever data is available from t he | |||
* stream. | * stream. | |||
* | * | |||
* @param cls the closure from GNUNET_STREAM_read | * @param cls the closure from GNUNET_STREAM_read | |||
* @param status the status of the stream at the time this function is call ed | * @param status the status of the stream at the time this function is call ed | |||
* @param data traffic from the other side | * @param data traffic from the other side | |||
* @param size the number of bytes available in data read | * @param size the number of bytes available in data read; will be 0 on tim eout | |||
* @return number of bytes of processed from 'data' (any data remaining sho uld be | * @return number of bytes of processed from 'data' (any data remaining sho uld be | |||
* given to the next time the read processor is called). | * given to the next time the read processor is called). | |||
*/ | */ | |||
typedef size_t (*GNUNET_STREAM_DataProcessor) (void *cls, | typedef size_t (*GNUNET_STREAM_DataProcessor) (void *cls, | |||
enum GNUNET_STREAM_Status st atus, | enum GNUNET_STREAM_Status st atus, | |||
const void *data, | const void *data, | |||
size_t size); | size_t size); | |||
/** | /** | |||
* Tries to read data from the stream | * Tries to read data from the stream. | |||
* | * | |||
* @param socket the socket representing a stream | * @param socket the socket representing a stream | |||
* @param timeout the timeout period | * @param timeout the timeout period | |||
* @param proc function to call with data (once only) | * @param proc function to call with data (once only) | |||
* @param proc_cls the closure for proc | * @param proc_cls the closure for proc | |||
* @return handle to cancel the operation | * | |||
* @return handle to cancel the operation; if the stream has been shutdown | ||||
for | ||||
* this type of opeartion then the DataProcessor is immediately | ||||
* called with GNUNET_STREAM_SHUTDOWN as status and NULL if retur | ||||
ned | ||||
*/ | */ | |||
struct GNUNET_STREAM_IOReadHandle * | struct GNUNET_STREAM_IOReadHandle * | |||
GNUNET_STREAM_read (struct GNUNET_STREAM_Socket *socket, | GNUNET_STREAM_read (struct GNUNET_STREAM_Socket *socket, | |||
struct GNUNET_TIME_Relative timeout, | struct GNUNET_TIME_Relative timeout, | |||
GNUNET_STREAM_DataProcessor proc, | GNUNET_STREAM_DataProcessor proc, | |||
void *proc_cls); | void *proc_cls); | |||
/** | /** | |||
* Cancel pending write operation. | * Cancels pending write operation. Also cancels packet retransmissions whi | |||
ch | ||||
* may have resulted otherwise. | ||||
* | ||||
* CAUTION: Normally a write operation is considered successful if the data | ||||
* given to it is sent and acknowledged by the receiver. As data is divided | ||||
* into packets, it is possible that not all packets are received by the | ||||
* receiver. Any missing packets are then retransmitted till the receiver | ||||
* acknowledges all packets or until a timeout . During this scenario if th | ||||
e | ||||
* write operation is cancelled all such retransmissions are also | ||||
* cancelled. This may leave the receiver's receive buffer incompletely fil | ||||
led | ||||
* as some missing packets are never retransmitted. So this operation shoul | ||||
d be | ||||
* used before shutting down transmission from our side or before closing t | ||||
he | ||||
* socket. | ||||
* | * | |||
* @param ioh handle to operation to cancel | * @param ioh handle to operation to cancel | |||
*/ | */ | |||
void | void | |||
GNUNET_STREAM_io_write_cancel (struct GNUNET_STREAM_IOWriteHandle *ioh); | GNUNET_STREAM_io_write_cancel (struct GNUNET_STREAM_IOWriteHandle *iowh); | |||
/** | /** | |||
* Cancel pending read operation. | * Cancel pending read operation. | |||
* | * | |||
* @param ioh handle to operation to cancel | * @param ioh handle to operation to cancel | |||
*/ | */ | |||
void | void | |||
GNUNET_STREAM_io_read_cancel (struct GNUNET_STREAM_IOReadHandle *ioh); | GNUNET_STREAM_io_read_cancel (struct GNUNET_STREAM_IOReadHandle *iorh); | |||
#if 0 | #if 0 | |||
{ | { | |||
#endif | #endif | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif /* STREAM_PROTOCOL_H */ | #endif /* STREAM_PROTOCOL_H */ | |||
End of changes. 17 change blocks. | ||||
19 lines changed or deleted | 88 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |