ObjFW  Diff

Differences From Artifact [e2ee8e466d]:

To Artifact [ec4a2962e7]:


23
24
25
26
27
28
29








30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52
53
54
55
56
57
OF_ASSUME_NONNULL_BEGIN

/** @file */

@class OFSCTPSocket;
@class OFString;









#ifdef OF_HAVE_BLOCKS
/**
 * @brief A block which is called when the socket connected.
 *
 * @param exception An exception which occurred while connecting the socket or
 *		    `nil` on success
 */
typedef void (^OFSCTPSocketAsyncConnectBlock)(id _Nullable exception);

/**
 * @brief A block which is called when a packet has been received.
 *
 * @param length The length of the packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message

 * @param exception An exception which occurred while receiving or `nil` on
 *		    success
 * @return A bool whether the same block should be used for the next receive
 */
typedef bool (^OFSCTPSocketAsyncReceiveBlock)(size_t length, uint16_t streamID,
    uint32_t PPID, id _Nullable exception);

/**
 * @brief A block which is called when a packet has been sent.
 *
 * @param exception An exception which occurred while reading or `nil` on
 *		    success
 * @return The data to repeat the send with or nil if it should not repeat







>
>
>
>
>
>
>
>















>





|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
OF_ASSUME_NONNULL_BEGIN

/** @file */

@class OFSCTPSocket;
@class OFString;

/**
 * @brief Flags for an SCTP packet.
 */
typedef enum {
	/** The packet is sent / received out of order. */
	OFSCTPPacketUnordered = 1
} OFSCTPPacketFlags;

#ifdef OF_HAVE_BLOCKS
/**
 * @brief A block which is called when the socket connected.
 *
 * @param exception An exception which occurred while connecting the socket or
 *		    `nil` on success
 */
typedef void (^OFSCTPSocketAsyncConnectBlock)(id _Nullable exception);

/**
 * @brief A block which is called when a packet has been received.
 *
 * @param length The length of the packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message
 * @param flags Flags for the packet
 * @param exception An exception which occurred while receiving or `nil` on
 *		    success
 * @return A bool whether the same block should be used for the next receive
 */
typedef bool (^OFSCTPSocketAsyncReceiveBlock)(size_t length, uint16_t streamID,
    uint32_t PPID, OFSCTPPacketFlags flags, id _Nullable exception);

/**
 * @brief A block which is called when a packet has been sent.
 *
 * @param exception An exception which occurred while reading or `nil` on
 *		    success
 * @return The data to repeat the send with or nil if it should not repeat
85
86
87
88
89
90
91

92
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108
109

110
111
112
113
114
115
116

117
118
119
120
121
122
123
 * @brief This method is called when a packet has been received.
 *
 * @param socket The sequenced packet socket which received a packet
 * @param buffer The buffer the packet has been written to
 * @param length The length of the packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message

 * @param exception An exception that occurred while receiving, or nil on
 *		    success
 * @return A bool whether the same block should be used for the next receive
 */
-	  (bool)socket: (OFSCTPSocket *)socket
  didReceiveIntoBuffer: (void *)buffer
		length: (size_t)length
	      streamID: (uint16_t)streamID
		  PPID: (uint32_t)PPID

	     exception: (nullable id)exception;

/**
 * @brief This method is called when a packet has been sent.
 *
 * @param socket The sequenced packet socket which sent a packet
 * @param data The data which was sent
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message

 * @param exception An exception that occurred while sending, or nil on success
 * @return The data to repeat the send with or nil if it should not repeat
 */
- (nullable OFData *)socket: (OFSCTPSocket *)socket
		didSendData: (OFData *)data
		   streamID: (uint16_t)streamID
		       PPID: (uint32_t)PPID

		  exception: (nullable id)exception;
@end

/**
 * @class OFSCTPSocket OFSCTPSocket.h ObjFW/OFSCTPSocket.h
 *
 * @brief A class which provides methods to create and use SCTP sockets in







>









>









>







>







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
 * @brief This method is called when a packet has been received.
 *
 * @param socket The sequenced packet socket which received a packet
 * @param buffer The buffer the packet has been written to
 * @param length The length of the packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message
 * @param flags Flags for the packet
 * @param exception An exception that occurred while receiving, or nil on
 *		    success
 * @return A bool whether the same block should be used for the next receive
 */
-	  (bool)socket: (OFSCTPSocket *)socket
  didReceiveIntoBuffer: (void *)buffer
		length: (size_t)length
	      streamID: (uint16_t)streamID
		  PPID: (uint32_t)PPID
		 flags: (OFSCTPPacketFlags)flags
	     exception: (nullable id)exception;

/**
 * @brief This method is called when a packet has been sent.
 *
 * @param socket The sequenced packet socket which sent a packet
 * @param data The data which was sent
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message
 * @param flags Flags for the packet
 * @param exception An exception that occurred while sending, or nil on success
 * @return The data to repeat the send with or nil if it should not repeat
 */
- (nullable OFData *)socket: (OFSCTPSocket *)socket
		didSendData: (OFData *)data
		   streamID: (uint16_t)streamID
		       PPID: (uint32_t)PPID
		      flags: (OFSCTPPacketFlags)flags
		  exception: (nullable id)exception;
@end

/**
 * @class OFSCTPSocket OFSCTPSocket.h ObjFW/OFSCTPSocket.h
 *
 * @brief A class which provides methods to create and use SCTP sockets in
223
224
225
226
227
228
229

230
231
232
233
234
235
236
237

238
239
240
241
242
243
244
 *
 * If the buffer is too small, the packet is truncated.
 *
 * @param buffer The buffer to write the packet to
 * @param length The length of the buffer
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message

 * @return The length of the received packet
 * @throw OFReadFailedException Receiving failed
 * @throw OFNotOpenException The socket is not open
 */
- (size_t)receiveIntoBuffer: (void *)buffer
		     length: (size_t)length
		   streamID: (nullable uint16_t *)streamID
		       PPID: (nullable uint32_t *)PPID;


/**
 * @brief Asynchronously receives a packet with stream ID and PPID and stores
 *	  it into the specified buffer.
 *
 * If the buffer is too small, the packet is truncated.
 *







>







|
>







236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
 *
 * If the buffer is too small, the packet is truncated.
 *
 * @param buffer The buffer to write the packet to
 * @param length The length of the buffer
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message
 * @param flags Flags for the packet
 * @return The length of the received packet
 * @throw OFReadFailedException Receiving failed
 * @throw OFNotOpenException The socket is not open
 */
- (size_t)receiveIntoBuffer: (void *)buffer
		     length: (size_t)length
		   streamID: (nullable uint16_t *)streamID
		       PPID: (nullable uint32_t *)PPID
		      flags: (nullable OFSCTPPacketFlags *)flags;

/**
 * @brief Asynchronously receives a packet with stream ID and PPID and stores
 *	  it into the specified buffer.
 *
 * If the buffer is too small, the packet is truncated.
 *
307
308
309
310
311
312
313

314
315
316
317
318
319
320

321
322
323
324
325
326
327

328
329
330
331

332
333
334
335
336
337
338

339
340
341
342
343
344

345
346
347
348
349
350
351
352
353

354
355
356
357
358
359
360

361
362
363
364
365
366
367
368

369
370
371
372
373
374
375
376
377

378
379
380
381
382
383
/**
 * @brief Sends the specified packet on the specified stream.
 *
 * @param buffer The buffer to send as a packet
 * @param length The length of the buffer
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message

 * @throw OFWriteFailedException Sending failed
 * @throw OFNotOpenException The socket is not open
 */
- (void)sendBuffer: (const void *)buffer
	    length: (size_t)length
	  streamID: (uint16_t)streamID
	      PPID: (uint32_t)PPID;


/**
 * @brief Asynchronously sends the specified packet on the specified stream.
 *
 * @param data The data to send as a packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message

 */
- (void)asyncSendData: (OFData *)data
	     streamID: (uint16_t)streamID
		 PPID: (uint32_t)PPID;


/**
 * @brief Asynchronously sends the specified packet on the specified stream.
 *
 * @param data The data to send as a packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message

 * @param runLoopMode The run loop mode in which to perform the asynchronous
 *		      send
 */
- (void)asyncSendData: (OFData *)data
	     streamID: (uint16_t)streamID
		 PPID: (uint32_t)PPID

	  runLoopMode: (OFRunLoopMode)runLoopMode;

#ifdef OF_HAVE_BLOCKS
/**
 * @brief Asynchronously sends the specified packet on the specified stream.
 *
 * @param data The data to send as a packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message

 * @param block The block to call when the packet has been sent. It should
 *		return the data for the next send with the same callback or nil
 *		if it should not repeat.
 */
- (void)asyncSendData: (OFData *)data
	     streamID: (uint16_t)streamID
		 PPID: (uint32_t)PPID

		block: (OFSCTPSocketAsyncSendDataBlock)block;

/**
 * @brief Asynchronously sends the specified packet on the specified stream.
 *
 * @param data The data to send as a packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message

 * @param runLoopMode The run loop mode in which to perform the asynchronous
 *		      send
 * @param block The block to call when the packet has been sent. It should
 *		return the data for the next send with the same callback or nil
 *		if it should not repeat.
 */
- (void)asyncSendData: (OFData *)data
	     streamID: (uint16_t)streamID
		 PPID: (uint32_t)PPID

	  runLoopMode: (OFRunLoopMode)runLoopMode
		block: (OFSCTPSocketAsyncSendDataBlock)block;
#endif
@end

OF_ASSUME_NONNULL_END







>






|
>







>



|
>







>






>









>







>








>









>






322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
/**
 * @brief Sends the specified packet on the specified stream.
 *
 * @param buffer The buffer to send as a packet
 * @param length The length of the buffer
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message
 * @param flags Flags for the packet
 * @throw OFWriteFailedException Sending failed
 * @throw OFNotOpenException The socket is not open
 */
- (void)sendBuffer: (const void *)buffer
	    length: (size_t)length
	  streamID: (uint16_t)streamID
	      PPID: (uint32_t)PPID
	     flags: (OFSCTPPacketFlags)flags;

/**
 * @brief Asynchronously sends the specified packet on the specified stream.
 *
 * @param data The data to send as a packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message
 * @param flags Flags for the packet
 */
- (void)asyncSendData: (OFData *)data
	     streamID: (uint16_t)streamID
		 PPID: (uint32_t)PPID
		flags: (OFSCTPPacketFlags)flags;

/**
 * @brief Asynchronously sends the specified packet on the specified stream.
 *
 * @param data The data to send as a packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message
 * @param flags Flags for the packet
 * @param runLoopMode The run loop mode in which to perform the asynchronous
 *		      send
 */
- (void)asyncSendData: (OFData *)data
	     streamID: (uint16_t)streamID
		 PPID: (uint32_t)PPID
		flags: (OFSCTPPacketFlags)flags
	  runLoopMode: (OFRunLoopMode)runLoopMode;

#ifdef OF_HAVE_BLOCKS
/**
 * @brief Asynchronously sends the specified packet on the specified stream.
 *
 * @param data The data to send as a packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message
 * @param flags Flags for the packet
 * @param block The block to call when the packet has been sent. It should
 *		return the data for the next send with the same callback or nil
 *		if it should not repeat.
 */
- (void)asyncSendData: (OFData *)data
	     streamID: (uint16_t)streamID
		 PPID: (uint32_t)PPID
		flags: (OFSCTPPacketFlags)flags
		block: (OFSCTPSocketAsyncSendDataBlock)block;

/**
 * @brief Asynchronously sends the specified packet on the specified stream.
 *
 * @param data The data to send as a packet
 * @param streamID The stream ID for the message
 * @param PPID The Payload Protocol Identifier for the message
 * @param flags Flags for the packet
 * @param runLoopMode The run loop mode in which to perform the asynchronous
 *		      send
 * @param block The block to call when the packet has been sent. It should
 *		return the data for the next send with the same callback or nil
 *		if it should not repeat.
 */
- (void)asyncSendData: (OFData *)data
	     streamID: (uint16_t)streamID
		 PPID: (uint32_t)PPID
		flags: (OFSCTPPacketFlags)flags
	  runLoopMode: (OFRunLoopMode)runLoopMode
		block: (OFSCTPSocketAsyncSendDataBlock)block;
#endif
@end

OF_ASSUME_NONNULL_END