spiped 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/ext/spiped/extconf.rb +3 -0
  3. data/ext/spiped/spiped-source/BUILDING +46 -0
  4. data/ext/spiped/spiped-source/CHANGELOG +44 -0
  5. data/ext/spiped/spiped-source/COPYRIGHT +33 -0
  6. data/ext/spiped/spiped-source/Makefile +47 -0
  7. data/ext/spiped/spiped-source/Makefile.POSIX +27 -0
  8. data/ext/spiped/spiped-source/Makefile.inc +20 -0
  9. data/ext/spiped/spiped-source/Makefile.prog +23 -0
  10. data/ext/spiped/spiped-source/POSIX/README +10 -0
  11. data/ext/spiped/spiped-source/POSIX/posix-cflags.sh +10 -0
  12. data/ext/spiped/spiped-source/POSIX/posix-clock_realtime.c +3 -0
  13. data/ext/spiped/spiped-source/POSIX/posix-l.c +1 -0
  14. data/ext/spiped/spiped-source/POSIX/posix-l.sh +14 -0
  15. data/ext/spiped/spiped-source/POSIX/posix-msg_nosignal.c +3 -0
  16. data/ext/spiped/spiped-source/README +198 -0
  17. data/ext/spiped/spiped-source/STYLE +151 -0
  18. data/ext/spiped/spiped-source/lib/dnsthread/dnsthread.c +464 -0
  19. data/ext/spiped/spiped-source/lib/dnsthread/dnsthread.h +45 -0
  20. data/ext/spiped/spiped-source/libcperciva/alg/sha256.c +442 -0
  21. data/ext/spiped/spiped-source/libcperciva/alg/sha256.h +95 -0
  22. data/ext/spiped/spiped-source/libcperciva/cpusupport/Build/cpusupport-X86-AESNI.c +13 -0
  23. data/ext/spiped/spiped-source/libcperciva/cpusupport/Build/cpusupport-X86-CPUID.c +8 -0
  24. data/ext/spiped/spiped-source/libcperciva/cpusupport/Build/cpusupport.sh +37 -0
  25. data/ext/spiped/spiped-source/libcperciva/cpusupport/cpusupport.h +63 -0
  26. data/ext/spiped/spiped-source/libcperciva/cpusupport/cpusupport_x86_aesni.c +30 -0
  27. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes.c +166 -0
  28. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes.h +31 -0
  29. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes_aesni.c +229 -0
  30. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes_aesni.h +31 -0
  31. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aesctr.c +124 -0
  32. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aesctr.h +41 -0
  33. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh.c +293 -0
  34. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh.h +43 -0
  35. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh_group14.c +46 -0
  36. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh_group14.h +9 -0
  37. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_entropy.c +215 -0
  38. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_entropy.h +14 -0
  39. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_verify_bytes.c +21 -0
  40. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_verify_bytes.h +14 -0
  41. data/ext/spiped/spiped-source/libcperciva/datastruct/elasticarray.c +276 -0
  42. data/ext/spiped/spiped-source/libcperciva/datastruct/elasticarray.h +167 -0
  43. data/ext/spiped/spiped-source/libcperciva/datastruct/mpool.h +85 -0
  44. data/ext/spiped/spiped-source/libcperciva/datastruct/ptrheap.c +334 -0
  45. data/ext/spiped/spiped-source/libcperciva/datastruct/ptrheap.h +89 -0
  46. data/ext/spiped/spiped-source/libcperciva/datastruct/timerqueue.c +241 -0
  47. data/ext/spiped/spiped-source/libcperciva/datastruct/timerqueue.h +60 -0
  48. data/ext/spiped/spiped-source/libcperciva/events/events.c +203 -0
  49. data/ext/spiped/spiped-source/libcperciva/events/events.h +106 -0
  50. data/ext/spiped/spiped-source/libcperciva/events/events_immediate.c +149 -0
  51. data/ext/spiped/spiped-source/libcperciva/events/events_internal.h +95 -0
  52. data/ext/spiped/spiped-source/libcperciva/events/events_network.c +347 -0
  53. data/ext/spiped/spiped-source/libcperciva/events/events_network_selectstats.c +106 -0
  54. data/ext/spiped/spiped-source/libcperciva/events/events_timer.c +273 -0
  55. data/ext/spiped/spiped-source/libcperciva/network/network.h +95 -0
  56. data/ext/spiped/spiped-source/libcperciva/network/network_accept.c +103 -0
  57. data/ext/spiped/spiped-source/libcperciva/network/network_connect.c +258 -0
  58. data/ext/spiped/spiped-source/libcperciva/network/network_read.c +155 -0
  59. data/ext/spiped/spiped-source/libcperciva/network/network_write.c +188 -0
  60. data/ext/spiped/spiped-source/libcperciva/util/asprintf.c +49 -0
  61. data/ext/spiped/spiped-source/libcperciva/util/asprintf.h +16 -0
  62. data/ext/spiped/spiped-source/libcperciva/util/daemonize.c +134 -0
  63. data/ext/spiped/spiped-source/libcperciva/util/daemonize.h +10 -0
  64. data/ext/spiped/spiped-source/libcperciva/util/entropy.c +76 -0
  65. data/ext/spiped/spiped-source/libcperciva/util/entropy.h +13 -0
  66. data/ext/spiped/spiped-source/libcperciva/util/imalloc.h +33 -0
  67. data/ext/spiped/spiped-source/libcperciva/util/insecure_memzero.c +19 -0
  68. data/ext/spiped/spiped-source/libcperciva/util/insecure_memzero.h +33 -0
  69. data/ext/spiped/spiped-source/libcperciva/util/monoclock.c +52 -0
  70. data/ext/spiped/spiped-source/libcperciva/util/monoclock.h +14 -0
  71. data/ext/spiped/spiped-source/libcperciva/util/noeintr.c +54 -0
  72. data/ext/spiped/spiped-source/libcperciva/util/noeintr.h +14 -0
  73. data/ext/spiped/spiped-source/libcperciva/util/sock.c +472 -0
  74. data/ext/spiped/spiped-source/libcperciva/util/sock.h +56 -0
  75. data/ext/spiped/spiped-source/libcperciva/util/sock_internal.h +14 -0
  76. data/ext/spiped/spiped-source/libcperciva/util/sock_util.c +271 -0
  77. data/ext/spiped/spiped-source/libcperciva/util/sock_util.h +51 -0
  78. data/ext/spiped/spiped-source/libcperciva/util/sysendian.h +146 -0
  79. data/ext/spiped/spiped-source/libcperciva/util/warnp.c +76 -0
  80. data/ext/spiped/spiped-source/libcperciva/util/warnp.h +59 -0
  81. data/ext/spiped/spiped-source/proto/proto_conn.c +362 -0
  82. data/ext/spiped/spiped-source/proto/proto_conn.h +25 -0
  83. data/ext/spiped/spiped-source/proto/proto_crypt.c +396 -0
  84. data/ext/spiped/spiped-source/proto/proto_crypt.h +102 -0
  85. data/ext/spiped/spiped-source/proto/proto_handshake.c +330 -0
  86. data/ext/spiped/spiped-source/proto/proto_handshake.h +30 -0
  87. data/ext/spiped/spiped-source/proto/proto_pipe.c +202 -0
  88. data/ext/spiped/spiped-source/proto/proto_pipe.h +23 -0
  89. data/ext/spiped/spiped-source/spipe/Makefile +90 -0
  90. data/ext/spiped/spiped-source/spipe/README +24 -0
  91. data/ext/spiped/spiped-source/spipe/main.c +178 -0
  92. data/ext/spiped/spiped-source/spipe/pushbits.c +101 -0
  93. data/ext/spiped/spiped-source/spipe/pushbits.h +10 -0
  94. data/ext/spiped/spiped-source/spipe/spipe.1 +60 -0
  95. data/ext/spiped/spiped-source/spiped/Makefile +98 -0
  96. data/ext/spiped/spiped-source/spiped/README +62 -0
  97. data/ext/spiped/spiped-source/spiped/dispatch.c +214 -0
  98. data/ext/spiped/spiped-source/spiped/dispatch.h +27 -0
  99. data/ext/spiped/spiped-source/spiped/main.c +267 -0
  100. data/ext/spiped/spiped-source/spiped/spiped.1 +112 -0
  101. data/lib/spiped.rb +3 -0
  102. metadata +143 -0
@@ -0,0 +1,106 @@
1
+ #include <sys/time.h>
2
+
3
+ #include "monoclock.h"
4
+
5
+ #include "events.h"
6
+ #include "events_internal.h"
7
+
8
+ /* Time when inter-select duration clock started. */
9
+ static struct timeval st;
10
+ static int running = 0;
11
+
12
+ /* Statistics on inter-select durations. */
13
+ static double N = 0.0;
14
+ static double mu = 0.0;
15
+ static double M2 = 0.0;
16
+ static double max = 0.0;
17
+
18
+ /**
19
+ * events_network_selectstats_startclock(void):
20
+ * Start the inter-select duration clock: There is a selectable event.
21
+ */
22
+ void
23
+ events_network_selectstats_startclock(void)
24
+ {
25
+
26
+ /* If the clock is already running, return silently. */
27
+ if (running)
28
+ return;
29
+
30
+ /* Get the current time; return silently on error. */
31
+ if (monoclock_get(&st))
32
+ return;
33
+
34
+ /* The clock is now running. */
35
+ running = 1;
36
+ }
37
+
38
+ /**
39
+ * events_network_selectstats_stopclock(void):
40
+ * Stop the inter-select duration clock: There are no selectable events.
41
+ */
42
+ void
43
+ events_network_selectstats_stopclock(void)
44
+ {
45
+
46
+ /* The clock is no longer running. */
47
+ running = 0;
48
+ }
49
+
50
+ /**
51
+ * events_network_selectstats_select(void):
52
+ * Update inter-select duration statistics in relation to an upcoming
53
+ * select(2) call.
54
+ */
55
+ void
56
+ events_network_selectstats_select(void)
57
+ {
58
+ struct timeval tnow;
59
+ double t, d;
60
+
61
+ /* If the clock is not running, return silently. */
62
+ if (!running)
63
+ return;
64
+
65
+ /* If we can't get the current time, fail silently. */
66
+ if (monoclock_get(&tnow))
67
+ goto done;
68
+
69
+ /* Compute inter-select duration in seconds. */
70
+ t = (tnow.tv_sec - st.tv_sec) + (tnow.tv_usec - st.tv_usec) * 0.000001;
71
+
72
+ /* Adjust statistics. We track running mean, variance * N, and max. */
73
+ N += 1.0;
74
+ d = t - mu;
75
+ mu += d / N;
76
+ M2 += d * (t - mu);
77
+ if (max < t)
78
+ max = t;
79
+
80
+ done:
81
+ /* The clock is no longer running. */
82
+ running = 0;
83
+ }
84
+
85
+ /**
86
+ * events_network_selectstats(N, mu, va, max):
87
+ * Return statistics on the inter-select durations since the last time this
88
+ * function was called.
89
+ */
90
+ void
91
+ events_network_selectstats(double * _N, double * _mu, double * _va,
92
+ double * _max)
93
+ {
94
+
95
+ /* Copy statistics out. */
96
+ *_N = N;
97
+ *_mu = mu;
98
+ if (N > 1.0)
99
+ *_va = M2 / (N - 1.0);
100
+ else
101
+ *_va = 0.0;
102
+ *_max = max;
103
+
104
+ /* Zero statistics. */
105
+ N = mu = M2 = max = 0.0;
106
+ }
@@ -0,0 +1,273 @@
1
+ #include <sys/time.h>
2
+
3
+ #include <stdlib.h>
4
+ #include <string.h>
5
+
6
+ #include "monoclock.h"
7
+ #include "timerqueue.h"
8
+
9
+ #include "events_internal.h"
10
+ #include "events.h"
11
+
12
+ struct timerrec {
13
+ struct eventrec * r;
14
+ void * cookie;
15
+ struct timeval tv_orig;
16
+ };
17
+
18
+ static struct timerqueue * Q = NULL;
19
+
20
+ /* Set tv := <current time> + tdelta. */
21
+ static int
22
+ gettimeout(struct timeval * tv, struct timeval * tdelta)
23
+ {
24
+
25
+ if (monoclock_get(tv))
26
+ goto err0;
27
+ tv->tv_sec += tdelta->tv_sec;
28
+ if ((tv->tv_usec += tdelta->tv_usec) >= 1000000) {
29
+ tv->tv_usec -= 1000000;
30
+ tv->tv_sec += 1;
31
+ }
32
+
33
+ /* Success! */
34
+ return (0);
35
+
36
+ err0:
37
+ /* Failure! */
38
+ return (-1);
39
+ }
40
+
41
+ /**
42
+ * events_timer_register(func, cookie, timeo):
43
+ * Register ${func}(${cookie}) to be run ${timeo} in the future. Return a
44
+ * cookie which can be passed to events_timer_cancel or events_timer_reset.
45
+ */
46
+ void *
47
+ events_timer_register(int (*func)(void *), void * cookie,
48
+ const struct timeval * timeo)
49
+ {
50
+ struct eventrec * r;
51
+ struct timerrec * t;
52
+ struct timeval tv;
53
+
54
+ /* Create the timer queue if it doesn't exist yet. */
55
+ if (Q == NULL) {
56
+ if ((Q = timerqueue_init()) == NULL)
57
+ goto err0;
58
+ }
59
+
60
+ /* Bundle into an eventrec record. */
61
+ if ((r = events_mkrec(func, cookie)) == NULL)
62
+ goto err0;
63
+
64
+ /* Create a timer record. */
65
+ if ((t = malloc(sizeof(struct timerrec))) == NULL)
66
+ goto err1;
67
+ t->r = r;
68
+ memcpy(&t->tv_orig, timeo, sizeof(struct timeval));
69
+
70
+ /* Compute the absolute timeout. */
71
+ if (gettimeout(&tv, &t->tv_orig))
72
+ goto err2;
73
+
74
+ /* Add this to the timer queue. */
75
+ if ((t->cookie = timerqueue_add(Q, &tv, t)) == NULL)
76
+ goto err2;
77
+
78
+ /* Success! */
79
+ return (t);
80
+
81
+ err2:
82
+ free(t);
83
+ err1:
84
+ events_freerec(r);
85
+ err0:
86
+ /* Failure! */
87
+ return (NULL);
88
+ }
89
+
90
+ /**
91
+ * events_timer_register_double(func, cookie, timeo):
92
+ * As events_timer_register, but ${timeo} is a double-precision floating point
93
+ * value specifying a number of seconds.
94
+ */
95
+ void *
96
+ events_timer_register_double(int (*func)(void *), void * cookie,
97
+ double timeo)
98
+ {
99
+ struct timeval tv;
100
+
101
+ /* Convert timeo to a struct timeval. */
102
+ tv.tv_sec = timeo;
103
+ tv.tv_usec = (timeo - tv.tv_sec) * 1000000.0;
104
+
105
+ /* Schedule the timeout. */
106
+ return (events_timer_register(func, cookie, &tv));
107
+ }
108
+
109
+ /**
110
+ * events_timer_cancel(cookie):
111
+ * Cancel the timer for which the cookie ${cookie} was returned by
112
+ * events_timer_register.
113
+ */
114
+ void
115
+ events_timer_cancel(void * cookie)
116
+ {
117
+ struct timerrec * t = cookie;
118
+
119
+ /* Remove from the timer queue. */
120
+ timerqueue_delete(Q, t->cookie);
121
+
122
+ /* Free the eventrec and timer records. */
123
+ events_freerec(t->r);
124
+ free(t);
125
+ }
126
+
127
+ /**
128
+ * events_timer_reset(cookie):
129
+ * Reset the timer for which the cookie ${cookie} was returned by
130
+ * events_timer_register to its initial value.
131
+ */
132
+ int
133
+ events_timer_reset(void * cookie)
134
+ {
135
+ struct timerrec * t = cookie;
136
+ struct timeval tv;
137
+
138
+ /* Compute the new timeout. */
139
+ if (gettimeout(&tv, &t->tv_orig))
140
+ goto err0;
141
+
142
+ /* Adjust the timer. */
143
+ timerqueue_increase(Q, t->cookie, &tv);
144
+
145
+ /* Success! */
146
+ return (0);
147
+
148
+ err0:
149
+ /* Failure! */
150
+ return (-1);
151
+ }
152
+
153
+ /**
154
+ * events_timer_min(timeo):
155
+ * Return via ${timeo} a pointer to the minimum time which must be waited
156
+ * before a timer will expire; or to NULL if there are no timers. The caller
157
+ * is responsible for freeing the returned pointer.
158
+ */
159
+ int
160
+ events_timer_min(struct timeval ** timeo)
161
+ {
162
+ struct timeval tnow;
163
+ const struct timeval * tv;
164
+
165
+ /* If we have no queue, we have no timers; return NULL. */
166
+ if (Q == NULL) {
167
+ *timeo = NULL;
168
+ goto done;
169
+ }
170
+
171
+ /* Get the minimum timer from the queue. */
172
+ tv = timerqueue_getmin(Q);
173
+
174
+ /* If there are no timers, return NULL. */
175
+ if (tv == NULL) {
176
+ *timeo = NULL;
177
+ goto done;
178
+ }
179
+
180
+ /* Allocate space for holding the returned timeval. */
181
+ if ((*timeo = malloc(sizeof(struct timeval))) == NULL)
182
+ goto err0;
183
+
184
+ /* Get the current time... */
185
+ if (monoclock_get(&tnow))
186
+ goto err1;
187
+
188
+ /* ... and compare it to the minimum timer. */
189
+ if ((tnow.tv_sec > tv->tv_sec) ||
190
+ ((tnow.tv_sec == tv->tv_sec) && (tnow.tv_usec > tv->tv_usec))) {
191
+ /* The timer has already expired, so return zero. */
192
+ (*timeo)->tv_sec = 0;
193
+ (*timeo)->tv_usec = 0;
194
+ } else {
195
+ /* Compute the difference. */
196
+ (*timeo)->tv_sec = tv->tv_sec - tnow.tv_sec;
197
+ (*timeo)->tv_usec = tv->tv_usec - tnow.tv_usec;
198
+ if (tv->tv_usec < tnow.tv_usec) {
199
+ (*timeo)->tv_usec += 1000000;
200
+ (*timeo)->tv_sec -= 1;
201
+ }
202
+ }
203
+
204
+ done:
205
+ /* Success! */
206
+ return (0);
207
+
208
+ err1:
209
+ free(*timeo);
210
+ err0:
211
+ /* Failure! */
212
+ return (-1);
213
+ }
214
+
215
+ /**
216
+ * events_timer_get(r):
217
+ * Return via ${r} a pointer to an eventrec structure corresponding to an
218
+ * expired timer, and delete said timer; or to NULL if there are no expired
219
+ * timers. The caller is responsible for freeing the returned pointer.
220
+ */
221
+ int
222
+ events_timer_get(struct eventrec ** r)
223
+ {
224
+ struct timeval tnow;
225
+ struct timerrec * t;
226
+
227
+ /* If we have no queue, we have no timers; return NULL. */
228
+ if (Q == NULL) {
229
+ *r = NULL;
230
+ goto done;
231
+ }
232
+
233
+ /* Get current time. */
234
+ if (monoclock_get(&tnow))
235
+ goto err0;
236
+
237
+ /* Get an expired timer, if there is one. */
238
+ t = timerqueue_getptr(Q, &tnow);
239
+
240
+ /* If there is an expired timer... */
241
+ if (t != NULL) {
242
+ /* ... pass back the eventrec and free the timer. */
243
+ *r = t->r;
244
+ free(t);
245
+ } else {
246
+ /* Otherwise, return NULL. */
247
+ *r = NULL;
248
+ }
249
+
250
+ done:
251
+ /* Success! */
252
+ return (0);
253
+
254
+ err0:
255
+ /* Failure! */
256
+ return (-1);
257
+ }
258
+
259
+ /**
260
+ * events_timer_shutdown(void):
261
+ * Clean up and free memory. This call is not necessary on program exit and
262
+ * is only expected to be useful when checking for memory leaks.
263
+ */
264
+ void
265
+ events_timer_shutdown(void)
266
+ {
267
+
268
+ /* If we have a queue and it is empty, free it. */
269
+ if ((Q != NULL) && (timerqueue_getmin(Q) == NULL)) {
270
+ timerqueue_free(Q);
271
+ Q = NULL;
272
+ }
273
+ }
@@ -0,0 +1,95 @@
1
+ #ifndef _NETWORK_H_
2
+ #define _NETWORK_H_
3
+
4
+ #include <sys/select.h>
5
+
6
+ #include <stddef.h>
7
+ #include <stdint.h>
8
+ #include <unistd.h>
9
+
10
+ /* Opaque address structure. */
11
+ struct sock_addr;
12
+
13
+ /**
14
+ * network_accept(fd, callback, cookie):
15
+ * Asynchronously accept a connection on the socket ${fd}, which must be
16
+ * already marked as listening and non-blocking. When a connection has been
17
+ * accepted or an error occurs, invoke ${callback}(${cookie}, s) where s is
18
+ * the accepted connection or -1 on error. Return a cookie which can be
19
+ * passed to network_accept_cancel in order to cancel the accept.
20
+ */
21
+ void * network_accept(int, int (*)(void *, int), void *);
22
+
23
+ /**
24
+ * network_accept_cancel(cookie);
25
+ * Cancel the connection accept for which the cookie ${cookie} was returned
26
+ * by network_accept. Do not invoke the callback associated with the accept.
27
+ */
28
+ void network_accept_cancel(void *);
29
+
30
+ /**
31
+ * network_connect(sas, callback, cookie):
32
+ * Iterate through the addresses in ${sas}, attempting to create and connect
33
+ * a non-blocking socket. Once connected, invoke ${callback}(${cookie}, s)
34
+ * where s is the connected socket; upon fatal error or if there are no
35
+ * addresses remaining to attempt, invoke ${callback}(${cookie}, -1). Return
36
+ * a cookie which can be passed to network_connect_cancel in order to cancel
37
+ * the connection attempt.
38
+ */
39
+ void * network_connect(struct sock_addr * const *,
40
+ int (*)(void *, int), void *);
41
+
42
+ /**
43
+ * network_connect_timeo(sas, timeo, callback, cookie):
44
+ * Behave as network_connect, but wait a duration of at most ${timeo} for
45
+ * each address which is being attempted.
46
+ */
47
+ void * network_connect_timeo(struct sock_addr * const *, const struct timeval *,
48
+ int (*)(void *, int), void *);
49
+
50
+ /**
51
+ * network_connect_cancel(cookie):
52
+ * Cancel the connection attempt for which ${cookie} was returned by
53
+ * network_connect. Do not invoke the associated callback.
54
+ */
55
+ void network_connect_cancel(void *);
56
+
57
+ /**
58
+ * network_read(fd, buf, buflen, minread, callback, cookie):
59
+ * Asynchronously read up to ${buflen} bytes of data from ${fd} into ${buf}.
60
+ * When at least ${minread} bytes have been read or on error, invoke
61
+ * ${callback}(${cookie}, lenread), where lenread is 0 on EOF or -1 on error,
62
+ * and the number of bytes read (between ${minread} and ${buflen} inclusive)
63
+ * otherwise. Return a cookie which can be passed to network_read_cancel in
64
+ * order to cancel the read.
65
+ */
66
+ void * network_read(int, uint8_t *, size_t, size_t,
67
+ int (*)(void *, ssize_t), void *);
68
+
69
+ /**
70
+ * network_read_cancel(cookie):
71
+ * Cancel the buffer read for which the cookie ${cookie} was returned by
72
+ * network_read. Do not invoke the callback associated with the read.
73
+ */
74
+ void network_read_cancel(void *);
75
+
76
+ /**
77
+ * network_write(fd, buf, buflen, minwrite, callback, cookie):
78
+ * Asynchronously write up to ${buflen} bytes of data from ${buf} to ${fd}.
79
+ * When at least ${minwrite} bytes have been written or on error, invoke
80
+ * ${callback}(${cookie}, lenwrit), where lenwrit is -1 on error and the
81
+ * number of bytes written (between ${minwrite} and ${buflen} inclusive)
82
+ * otherwise. Return a cookie which can be passed to network_write_cancel in
83
+ * order to cancel the write.
84
+ */
85
+ void * network_write(int, const uint8_t *, size_t, size_t,
86
+ int (*)(void *, ssize_t), void *);
87
+
88
+ /**
89
+ * network_write_cancel(cookie):
90
+ * Cancel the buffer write for which the cookie ${cookie} was returned by
91
+ * network_write. Do not invoke the callback associated with the write.
92
+ */
93
+ void network_write_cancel(void *);
94
+
95
+ #endif /* !_NETWORK_H_ */