Commit | Line | Data |
---|---|---|
410c8acf | 1 | /* -*-c-*- |
2 | * | |
3cdc3f3a | 3 | * $Id$ |
410c8acf | 4 | * |
5 | * Main header file for TrIPE | |
6 | * | |
7 | * (c) 2001 Straylight/Edgeware | |
8 | */ | |
9 | ||
10 | /*----- Licensing notice --------------------------------------------------* | |
11 | * | |
12 | * This file is part of Trivial IP Encryption (TrIPE). | |
13 | * | |
14 | * TrIPE is free software; you can redistribute it and/or modify | |
15 | * it under the terms of the GNU General Public License as published by | |
16 | * the Free Software Foundation; either version 2 of the License, or | |
17 | * (at your option) any later version. | |
18 | * | |
19 | * TrIPE is distributed in the hope that it will be useful, | |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | * GNU General Public License for more details. | |
23 | * | |
24 | * You should have received a copy of the GNU General Public License | |
25 | * along with TrIPE; if not, write to the Free Software Foundation, | |
26 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
27 | */ | |
28 | ||
410c8acf | 29 | #ifndef TRIPE_H |
30 | #define TRIPE_H | |
31 | ||
32 | #ifdef __cplusplus | |
33 | extern "C" { | |
34 | #endif | |
35 | ||
36 | /*----- Header files ------------------------------------------------------*/ | |
37 | ||
73189848 | 38 | #include "config.h" |
39 | ||
410c8acf | 40 | #include <assert.h> |
41 | #include <ctype.h> | |
42 | #include <errno.h> | |
b9066fbb | 43 | #include <limits.h> |
410c8acf | 44 | #include <signal.h> |
45 | #include <stdarg.h> | |
46 | #include <stddef.h> | |
47 | #include <stdio.h> | |
48 | #include <stdlib.h> | |
49 | #include <string.h> | |
50 | #include <time.h> | |
51 | ||
52 | #include <sys/types.h> | |
53 | #include <sys/time.h> | |
54 | #include <unistd.h> | |
55 | #include <fcntl.h> | |
56 | #include <sys/stat.h> | |
57 | ||
58 | #include <sys/socket.h> | |
59 | #include <sys/un.h> | |
60 | #include <netinet/in.h> | |
61 | #include <arpa/inet.h> | |
62 | #include <netdb.h> | |
63 | ||
64 | #include <pwd.h> | |
65 | #include <grp.h> | |
66 | ||
67 | #include <mLib/alloc.h> | |
68 | #include <mLib/arena.h> | |
37941236 | 69 | #include <mLib/base64.h> |
410c8acf | 70 | #include <mLib/bres.h> |
71 | #include <mLib/dstr.h> | |
72 | #include <mLib/env.h> | |
73 | #include <mLib/fdflags.h> | |
74 | #include <mLib/fwatch.h> | |
75 | #include <mLib/mdwopt.h> | |
76 | #include <mLib/quis.h> | |
77 | #include <mLib/report.h> | |
78 | #include <mLib/sel.h> | |
79 | #include <mLib/selbuf.h> | |
80 | #include <mLib/sig.h> | |
81 | #include <mLib/str.h> | |
82 | #include <mLib/sub.h> | |
83 | #include <mLib/trace.h> | |
0ba8de86 | 84 | #include <mLib/tv.h> |
410c8acf | 85 | |
165db1a8 | 86 | #include <catacomb/buf.h> |
87 | ||
410c8acf | 88 | #include <catacomb/gcipher.h> |
89 | #include <catacomb/gmac.h> | |
90 | #include <catacomb/grand.h> | |
91 | #include <catacomb/key.h> | |
92 | #include <catacomb/paranoia.h> | |
93 | ||
410c8acf | 94 | #include <catacomb/noise.h> |
95 | #include <catacomb/rand.h> | |
410c8acf | 96 | |
97 | #include <catacomb/mp.h> | |
410c8acf | 98 | #include <catacomb/mprand.h> |
99 | #include <catacomb/dh.h> | |
52c03a2a | 100 | #include <catacomb/ec.h> |
101 | #include <catacomb/ec-keys.h> | |
102 | #include <catacomb/group.h> | |
410c8acf | 103 | |
165db1a8 | 104 | #include "tripe-protocol.h" |
410c8acf | 105 | #include "util.h" |
106 | ||
107 | #undef sun | |
108 | ||
109 | /*----- Magic numbers -----------------------------------------------------*/ | |
110 | ||
410c8acf | 111 | /* --- Trace flags --- */ |
112 | ||
113 | #define T_TUNNEL 1u | |
114 | #define T_PEER 2u | |
115 | #define T_PACKET 4u | |
116 | #define T_ADMIN 8u | |
117 | #define T_CRYPTO 16u | |
118 | #define T_KEYSET 32u | |
119 | #define T_KEYEXCH 64u | |
120 | #define T_KEYMGMT 128u | |
37941236 | 121 | #define T_CHAL 256u |
410c8acf | 122 | |
37941236 | 123 | #define T_ALL 511u |
410c8acf | 124 | |
125 | /* --- Units --- */ | |
126 | ||
127 | #define SEC(n) (n##u) | |
128 | #define MIN(n) (n##u * 60u) | |
129 | #define MEG(n) (n##ul * 1024ul * 1024ul) | |
130 | ||
131 | /* --- Other things --- */ | |
132 | ||
133 | #define PKBUFSZ 65536 | |
134 | ||
832a2ab6 | 135 | /*----- Cipher selections -------------------------------------------------*/ |
136 | ||
b5c45da1 | 137 | typedef struct algswitch { |
138 | const gccipher *c; /* Symmetric encryption scheme */ | |
139 | const gccipher *mgf; /* Mask-generation function */ | |
140 | const gchash *h; /* Hash function */ | |
141 | const gcmac *m; /* Message authentication code */ | |
142 | size_t hashsz; /* Hash output size */ | |
143 | size_t tagsz; /* Length to truncate MAC tags */ | |
144 | size_t cksz, mksz; /* Key lengths for @c@ and @m@ */ | |
145 | } algswitch; | |
832a2ab6 | 146 | |
b5c45da1 | 147 | extern algswitch algs; |
832a2ab6 | 148 | |
b5c45da1 | 149 | #define MAXHASHSZ 64 /* Largest possible hash size */ |
832a2ab6 | 150 | |
b5c45da1 | 151 | #define HASH_STRING(h, s) GH_HASH((h), (s), sizeof(s)) |
410c8acf | 152 | |
aeeb5611 | 153 | /*----- Data structures ---------------------------------------------------*/ |
410c8acf | 154 | |
155 | /* --- Socket addresses --- * | |
156 | * | |
157 | * A magic union of supported socket addresses. | |
158 | */ | |
159 | ||
160 | typedef union addr { | |
161 | struct sockaddr sa; | |
162 | struct sockaddr_in sin; | |
163 | } addr; | |
164 | ||
37941236 | 165 | /* --- Sequence number checking --- */ |
166 | ||
167 | typedef struct seqwin { | |
168 | uint32 seq; /* First acceptable input sequence */ | |
169 | uint32 win; /* Window of acceptable numbers */ | |
170 | } seqwin; | |
171 | ||
172 | #define SEQ_WINSZ 32 /* Bits in sequence number window */ | |
173 | ||
410c8acf | 174 | /* --- A symmetric keyset --- * |
175 | * | |
176 | * A keyset contains a set of symmetric keys for encrypting and decrypting | |
177 | * packets. Keysets are stored in a list, sorted in reverse order of | |
178 | * creation, so that the most recent keyset (the one most likely to be used) | |
179 | * is first. | |
180 | * | |
181 | * Each keyset has a time limit and a data limit. The keyset is destroyed | |
182 | * when either it has existed for too long, or it has been used to encrypt | |
183 | * too much data. New key exchanges are triggered when keys are close to | |
184 | * expiry. | |
185 | */ | |
186 | ||
187 | typedef struct keyset { | |
188 | struct keyset *next; /* Next active keyset in the list */ | |
832a2ab6 | 189 | unsigned ref; /* Reference count for keyset */ |
9466fafa | 190 | struct peer *p; /* Pointer to peer structure */ |
410c8acf | 191 | time_t t_exp; /* Expiry time for this keyset */ |
192 | unsigned long sz_exp; /* Data limit for the keyset */ | |
832a2ab6 | 193 | T( unsigned seq; ) /* Sequence number for tracing */ |
194 | unsigned f; /* Various useful flags */ | |
195 | gcipher *cin, *cout; /* Keyset ciphers for encryption */ | |
b5c45da1 | 196 | size_t tagsz; /* Length to truncate MAC tags */ |
832a2ab6 | 197 | gmac *min, *mout; /* Keyset MACs for integrity */ |
1484d822 | 198 | uint32 oseq; /* Outbound sequence number */ |
37941236 | 199 | seqwin iseq; /* Inbound sequence number */ |
410c8acf | 200 | } keyset; |
201 | ||
832a2ab6 | 202 | #define KSF_LISTEN 1u /* Don't encrypt packets yet */ |
203 | #define KSF_LINK 2u /* Key is in a linked list */ | |
204 | ||
410c8acf | 205 | /* --- Key exchange --- * |
206 | * | |
207 | * TrIPE uses the Wrestlers Protocol for its key exchange. The Wrestlers | |
208 | * Protocol has a number of desirable features (e.g., perfect forward | |
209 | * secrecy, and zero-knowledge authentication) which make it attractive for | |
210 | * use in TrIPE. The Wrestlers Protocol was designed by Mark Wooding and | |
211 | * Clive Jones. | |
212 | */ | |
213 | ||
832a2ab6 | 214 | #define KX_NCHAL 16u |
215 | #define KX_THRESH 4u | |
216 | ||
217 | typedef struct kxchal { | |
218 | struct keyexch *kx; /* Pointer back to key exchange */ | |
52c03a2a | 219 | ge *c; /* Responder's challenge */ |
220 | ge *r; /* My reply to the challenge */ | |
832a2ab6 | 221 | keyset *ks; /* Pointer to temporary keyset */ |
222 | unsigned f; /* Various useful flags */ | |
223 | sel_timer t; /* Response timer for challenge */ | |
b5c45da1 | 224 | octet hc[MAXHASHSZ]; /* Hash of his challenge */ |
1d27afe6 | 225 | mp *ck; /* The check value */ |
b5c45da1 | 226 | octet hswrq_in[MAXHASHSZ]; /* Inbound switch request message */ |
227 | octet hswok_in[MAXHASHSZ]; /* Inbound switch confirmation */ | |
228 | octet hswrq_out[MAXHASHSZ]; /* Outbound switch request message */ | |
229 | octet hswok_out[MAXHASHSZ]; /* Outbound switch confirmation */ | |
832a2ab6 | 230 | } kxchal; |
231 | ||
410c8acf | 232 | typedef struct keyexch { |
410c8acf | 233 | struct peer *p; /* Pointer back to the peer */ |
832a2ab6 | 234 | keyset **ks; /* Peer's list of keysets */ |
410c8acf | 235 | unsigned f; /* Various useful flags */ |
832a2ab6 | 236 | unsigned s; /* Current state in exchange */ |
410c8acf | 237 | sel_timer t; /* Timer for next exchange */ |
52c03a2a | 238 | ge *kpub; /* Peer's public key */ |
00e64b67 | 239 | time_t texp_kpub; /* Expiry time for public key */ |
832a2ab6 | 240 | mp *alpha; /* My temporary secret */ |
52c03a2a | 241 | ge *c; /* My challenge */ |
242 | ge *rx; /* The expected response */ | |
832a2ab6 | 243 | unsigned nr; /* Number of extant responses */ |
410c8acf | 244 | time_t t_valid; /* When this exchange goes bad */ |
b5c45da1 | 245 | octet hc[MAXHASHSZ]; /* Hash of my challenge */ |
832a2ab6 | 246 | kxchal *r[KX_NCHAL]; /* Array of challenges */ |
410c8acf | 247 | } keyexch; |
248 | ||
249 | #define KXF_TIMER 1u /* Waiting for a timer to go off */ | |
00e64b67 | 250 | #define KXF_DEAD 2u /* The key-exchanger isn't up */ |
251 | #define KXF_PUBKEY 4u /* Key exchanger has a public key */ | |
832a2ab6 | 252 | |
253 | enum { | |
254 | KXS_DEAD, /* Uninitialized state (magical) */ | |
255 | KXS_CHAL, /* Main answer-challenges state */ | |
256 | KXS_COMMIT, /* Committed: send switch request */ | |
257 | KXS_SWITCH /* Switched: send confirmation */ | |
258 | }; | |
410c8acf | 259 | |
260 | /* --- Tunnel structure --- * | |
261 | * | |
262 | * Used to maintain system-specific information about the tunnel interface. | |
263 | */ | |
264 | ||
42da2a58 | 265 | typedef struct tunnel tunnel; |
266 | struct peer; | |
110d564e | 267 | |
42da2a58 | 268 | typedef struct tunnel_ops { |
269 | const char *name; /* Name of this tunnel driver */ | |
270 | void (*init)(void); /* Initializes the system */ | |
271 | tunnel *(*create)(struct peer */*p*/); /* Initializes a new tunnel */ | |
272 | const char *(*ifname)(tunnel */*t*/); /* Returns tunnel's interface name */ | |
273 | void (*inject)(tunnel */*t*/, buf */*b*/); /* Sends packet through if */ | |
274 | void (*destroy)(tunnel */*t*/); /* Destroys a tunnel */ | |
275 | } tunnel_ops; | |
b9066fbb | 276 | |
42da2a58 | 277 | #ifndef TUN_INTERNALS |
278 | struct tunnel { const tunnel_ops *ops; }; | |
410c8acf | 279 | #endif |
410c8acf | 280 | |
832a2ab6 | 281 | /* --- Peer statistics --- * |
282 | * | |
283 | * Contains various interesting and not-so-interesting statistics about a | |
284 | * peer. This is updated by various parts of the code. The format of the | |
285 | * structure isn't considered private, and @p_stats@ returns a pointer to the | |
286 | * statistics block for a given peer. | |
287 | */ | |
288 | ||
289 | typedef struct stats { | |
290 | unsigned long sz_in, sz_out; /* Size of all data in and out */ | |
291 | unsigned long sz_kxin, sz_kxout; /* Size of key exchange messages */ | |
292 | unsigned long sz_ipin, sz_ipout; /* Size of encapsulated IP packets */ | |
3cdc3f3a | 293 | time_t t_start, t_last, t_kx; /* Time peer created, last pk, kx */ |
832a2ab6 | 294 | unsigned long n_reject; /* Number of rejected packets */ |
295 | unsigned long n_in, n_out; /* Number of packets in and out */ | |
296 | unsigned long n_kxin, n_kxout; /* Number of key exchange packets */ | |
297 | unsigned long n_ipin, n_ipout; /* Number of encrypted packets */ | |
298 | } stats; | |
299 | ||
410c8acf | 300 | /* --- Peer structure --- * |
301 | * | |
302 | * The main structure which glues everything else together. | |
303 | */ | |
304 | ||
0ba8de86 | 305 | typedef struct peerspec { |
306 | char *name; /* Peer's name */ | |
307 | const tunnel_ops *tops; /* Tunnel operations */ | |
308 | unsigned long t_ka; /* Keep alive interval */ | |
309 | addr sa; /* Socket address to speak to */ | |
310 | size_t sasz; /* Socket address size */ | |
311 | } peerspec; | |
312 | ||
410c8acf | 313 | typedef struct peer { |
314 | struct peer *next, *prev; /* Links to next and previous */ | |
0ba8de86 | 315 | struct ping *pings; /* Pings we're waiting for */ |
316 | peerspec spec; /* Specifications for this peer */ | |
42da2a58 | 317 | tunnel *t; /* Tunnel for local packets */ |
410c8acf | 318 | keyset *ks; /* List head for keysets */ |
410c8acf | 319 | buf b; /* Buffer for sending packets */ |
832a2ab6 | 320 | stats st; /* Statistics */ |
321 | keyexch kx; /* Key exchange protocol block */ | |
0ba8de86 | 322 | sel_timer tka; /* Timer for keepalives */ |
410c8acf | 323 | } peer; |
324 | ||
0ba8de86 | 325 | typedef struct ping { |
326 | struct ping *next, *prev; /* Links to next and previous */ | |
327 | peer *p; /* Peer so we can free it */ | |
328 | unsigned msg; /* Kind of response expected */ | |
329 | uint32 id; /* Id so we can recognize response */ | |
330 | octet magic[32]; /* Some random data */ | |
331 | sel_timer t; /* Timeout for ping */ | |
332 | void (*func)(int /*rc*/, void */*arg*/); /* Function to call when done */ | |
333 | void *arg; /* Argument for callback */ | |
334 | } ping; | |
335 | ||
336 | enum { | |
337 | PING_NONOTIFY = -1, | |
338 | PING_OK = 0, | |
339 | PING_TIMEOUT, | |
340 | PING_PEERDIED, | |
341 | PING_MAX | |
342 | }; | |
343 | ||
410c8acf | 344 | /* --- Admin structure --- */ |
345 | ||
fd3cf232 | 346 | #define OBUFSZ 16384u |
347 | ||
348 | typedef struct obuf { | |
349 | struct obuf *next; /* Next buffer in list */ | |
350 | char *p_in, *p_out; /* Pointers into the buffer */ | |
351 | char buf[OBUFSZ]; /* The actual buffer */ | |
352 | } obuf; | |
353 | ||
de014da6 | 354 | typedef struct oqueue { |
355 | obuf *hd, *tl; /* Head and tail pointers */ | |
356 | } oqueue; | |
357 | ||
358 | struct admin; | |
359 | ||
360 | typedef struct admin_bgop { | |
361 | struct admin_bgop *next, *prev; /* Links to next and previous */ | |
362 | struct admin *a; /* Owner job */ | |
363 | char *tag; /* Tag string for messages */ | |
364 | void (*cancel)(struct admin_bgop *); /* Destructor function */ | |
365 | } admin_bgop; | |
366 | ||
37941236 | 367 | typedef struct admin_resop { |
de014da6 | 368 | admin_bgop bg; /* Background operation header */ |
37941236 | 369 | char *addr; /* Hostname to be resolved */ |
de014da6 | 370 | bres_client r; /* Background resolver task */ |
371 | sel_timer t; /* Timer for resolver */ | |
37941236 | 372 | addr sa; /* Socket address */ |
373 | size_t sasz; /* Socket address size */ | |
374 | void (*func)(struct admin_resop *, int); /* Handler */ | |
375 | } admin_resop; | |
376 | ||
377 | enum { ARES_OK, ARES_FAIL }; | |
378 | ||
379 | typedef struct admin_addop { | |
380 | admin_resop r; /* Name resolution header */ | |
381 | peerspec peer; /* Peer pending creation */ | |
de014da6 | 382 | } admin_addop; |
383 | ||
37941236 | 384 | typedef struct admin_greetop { |
385 | admin_resop r; /* Name resolution header */ | |
386 | void *c; /* Challenge block */ | |
387 | size_t sz; /* Length of challenge */ | |
388 | } admin_greetop; | |
389 | ||
de014da6 | 390 | typedef struct admin_pingop { |
391 | admin_bgop bg; /* Background operation header */ | |
392 | ping ping; /* Ping pending response */ | |
393 | struct timeval pingtime; /* Time last ping was sent */ | |
394 | } admin_pingop; | |
395 | ||
410c8acf | 396 | typedef struct admin { |
397 | struct admin *next, *prev; /* Links to next and previous */ | |
fd3cf232 | 398 | unsigned f; /* Various useful flags */ |
060ca767 | 399 | unsigned ref; /* Reference counter */ |
410c8acf | 400 | #ifndef NTRACE |
401 | unsigned seq; /* Sequence number for tracing */ | |
402 | #endif | |
de014da6 | 403 | oqueue out; /* Output buffer list */ |
404 | oqueue delay; /* Delayed output buffer list */ | |
405 | admin_bgop *bg; /* Backgrounded operations */ | |
fd3cf232 | 406 | selbuf b; /* Line buffer for commands */ |
407 | sel_file w; /* Selector for write buffering */ | |
410c8acf | 408 | } admin; |
409 | ||
fd3cf232 | 410 | #define AF_DEAD 1u /* Destroy this admin block */ |
060ca767 | 411 | #define AF_CLOSE 2u /* Client closed connection */ |
3cdc3f3a | 412 | #define AF_NOTE 4u /* Catch notifications */ |
de014da6 | 413 | #define AF_WARN 8u /* Catch warning messages */ |
3cdc3f3a | 414 | #ifndef NTRACE |
de014da6 | 415 | #define AF_TRACE 16u /* Catch tracing */ |
3cdc3f3a | 416 | #endif |
3cdc3f3a | 417 | |
418 | #ifndef NTRACE | |
419 | # define AF_ALLMSGS (AF_NOTE | AF_TRACE | AF_WARN) | |
420 | #else | |
421 | # define AF_ALLMSGS (AF_NOTE | AF_WARN) | |
422 | #endif | |
fd3cf232 | 423 | |
410c8acf | 424 | /*----- Global variables --------------------------------------------------*/ |
425 | ||
426 | extern sel_state sel; /* Global I/O event state */ | |
52c03a2a | 427 | extern group *gg; /* The group we work in */ |
428 | extern mp *kpriv; /* Our private key */ | |
832a2ab6 | 429 | extern octet buf_i[PKBUFSZ], buf_o[PKBUFSZ], buf_t[PKBUFSZ]; |
42da2a58 | 430 | extern const tunnel_ops *tunnels[]; /* Table of tunnels (0-term) */ |
431 | extern const tunnel_ops *tun_default; /* Default tunnel to use */ | |
410c8acf | 432 | |
433 | #ifndef NTRACE | |
434 | extern const trace_opt tr_opts[]; /* Trace options array */ | |
435 | extern unsigned tr_flags; /* Trace options flags */ | |
436 | #endif | |
437 | ||
8d0c7a83 | 438 | /*----- Other macros ------------------------------------------------------*/ |
439 | ||
440 | #define TIMER noise_timer(RAND_GLOBAL) | |
441 | ||
410c8acf | 442 | /*----- Key management ----------------------------------------------------*/ |
443 | ||
de014da6 | 444 | /* --- @km_reload@ --- * |
410c8acf | 445 | * |
446 | * Arguments: --- | |
447 | * | |
448 | * Returns: Zero if OK, nonzero to force reloading of keys. | |
449 | * | |
de014da6 | 450 | * Use: Checks the keyrings to see if they need reloading. |
410c8acf | 451 | */ |
452 | ||
de014da6 | 453 | extern int km_reload(void); |
410c8acf | 454 | |
455 | /* --- @km_init@ --- * | |
456 | * | |
457 | * Arguments: @const char *kr_priv@ = private keyring file | |
458 | * @const char *kr_pub@ = public keyring file | |
459 | * @const char *tag@ = tag to load | |
460 | * | |
461 | * Returns: --- | |
462 | * | |
463 | * Use: Initializes, and loads the private key. | |
464 | */ | |
465 | ||
466 | extern void km_init(const char */*kr_priv*/, const char */*kr_pub*/, | |
467 | const char */*tag*/); | |
468 | ||
469 | /* --- @km_getpubkey@ --- * | |
470 | * | |
471 | * Arguments: @const char *tag@ = public key tag to load | |
52c03a2a | 472 | * @ge *kpub@ = where to put the public key |
00e64b67 | 473 | * @time_t *t_exp@ = where to put the expiry time |
410c8acf | 474 | * |
475 | * Returns: Zero if OK, nonzero if it failed. | |
476 | * | |
477 | * Use: Fetches a public key from the keyring. | |
478 | */ | |
479 | ||
52c03a2a | 480 | extern int km_getpubkey(const char */*tag*/, ge */*kpub*/, |
00e64b67 | 481 | time_t */*t_exp*/); |
410c8acf | 482 | |
483 | /*----- Key exchange ------------------------------------------------------*/ | |
484 | ||
485 | /* --- @kx_start@ --- * | |
486 | * | |
487 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
de014da6 | 488 | * @int forcep@ = nonzero to ignore the quiet timer |
410c8acf | 489 | * |
490 | * Returns: --- | |
491 | * | |
492 | * Use: Stimulates a key exchange. If a key exchage is in progress, | |
493 | * a new challenge is sent (unless the quiet timer forbids | |
494 | * this); if no exchange is in progress, one is commenced. | |
495 | */ | |
496 | ||
de014da6 | 497 | extern void kx_start(keyexch */*kx*/, int /*forcep*/); |
410c8acf | 498 | |
832a2ab6 | 499 | /* --- @kx_message@ --- * |
410c8acf | 500 | * |
501 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
832a2ab6 | 502 | * @unsigned msg@ = the message code |
503 | * @buf *b@ = pointer to buffer containing the packet | |
410c8acf | 504 | * |
505 | * Returns: --- | |
506 | * | |
832a2ab6 | 507 | * Use: Reads a packet containing key exchange messages and handles |
508 | * it. | |
410c8acf | 509 | */ |
510 | ||
832a2ab6 | 511 | extern void kx_message(keyexch */*kx*/, unsigned /*msg*/, buf */*b*/); |
410c8acf | 512 | |
513 | /* --- @kx_free@ --- * | |
514 | * | |
515 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
516 | * | |
517 | * Returns: --- | |
518 | * | |
519 | * Use: Frees everything in a key exchange context. | |
520 | */ | |
521 | ||
522 | extern void kx_free(keyexch */*kx*/); | |
523 | ||
524 | /* --- @kx_newkeys@ --- * | |
525 | * | |
526 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
527 | * | |
528 | * Returns: --- | |
529 | * | |
530 | * Use: Informs the key exchange module that its keys may have | |
531 | * changed. If fetching the new keys fails, the peer will be | |
532 | * destroyed, we log messages and struggle along with the old | |
533 | * keys. | |
534 | */ | |
535 | ||
536 | extern void kx_newkeys(keyexch */*kx*/); | |
537 | ||
538 | /* --- @kx_init@ --- * | |
539 | * | |
540 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
541 | * @peer *p@ = pointer to peer context | |
542 | * @keyset **ks@ = pointer to keyset list | |
543 | * | |
544 | * Returns: Zero if OK, nonzero if it failed. | |
545 | * | |
546 | * Use: Initializes a key exchange module. The module currently | |
547 | * contains no keys, and will attempt to initiate a key | |
548 | * exchange. | |
549 | */ | |
550 | ||
551 | extern int kx_init(keyexch */*kx*/, peer */*p*/, keyset **/*ks*/); | |
552 | ||
553 | /*----- Keysets and symmetric cryptography --------------------------------*/ | |
554 | ||
832a2ab6 | 555 | /* --- @ks_drop@ --- * |
556 | * | |
557 | * Arguments: @keyset *ks@ = pointer to a keyset | |
558 | * | |
559 | * Returns: --- | |
560 | * | |
561 | * Use: Decrements a keyset's reference counter. If the counter hits | |
562 | * zero, the keyset is freed. | |
563 | */ | |
564 | ||
565 | extern void ks_drop(keyset */*ks*/); | |
566 | ||
567 | /* --- @ks_gen@ --- * | |
568 | * | |
569 | * Arguments: @const void *k@ = pointer to key material | |
570 | * @size_t x, y, z@ = offsets into key material (see below) | |
9466fafa | 571 | * @peer *p@ = pointer to peer information |
832a2ab6 | 572 | * |
573 | * Returns: A pointer to the new keyset. | |
574 | * | |
575 | * Use: Derives a new keyset from the given key material. The | |
576 | * offsets @x@, @y@ and @z@ separate the key material into three | |
577 | * parts. Between the @k@ and @k + x@ is `my' contribution to | |
578 | * the key material; between @k + x@ and @k + y@ is `your' | |
579 | * contribution; and between @k + y@ and @k + z@ is a shared | |
580 | * value we made together. These are used to construct two | |
581 | * pairs of symmetric keys. Each pair consists of an encryption | |
582 | * key and a message authentication key. One pair is used for | |
583 | * outgoing messages, the other for incoming messages. | |
584 | * | |
585 | * The new key is marked so that it won't be selected for output | |
586 | * by @ksl_encrypt@. You can still encrypt data with it by | |
587 | * calling @ks_encrypt@ directly. | |
588 | */ | |
589 | ||
590 | extern keyset *ks_gen(const void */*k*/, | |
9466fafa | 591 | size_t /*x*/, size_t /*y*/, size_t /*z*/, |
592 | peer */*p*/); | |
832a2ab6 | 593 | |
594 | /* --- @ks_tregen@ --- * | |
595 | * | |
596 | * Arguments: @keyset *ks@ = pointer to a keyset | |
597 | * | |
598 | * Returns: The time at which moves ought to be made to replace this key. | |
599 | */ | |
600 | ||
601 | extern time_t ks_tregen(keyset */*ks*/); | |
602 | ||
603 | /* --- @ks_activate@ --- * | |
604 | * | |
605 | * Arguments: @keyset *ks@ = pointer to a keyset | |
606 | * | |
607 | * Returns: --- | |
608 | * | |
609 | * Use: Activates a keyset, so that it can be used for encrypting | |
610 | * outgoing messages. | |
611 | */ | |
612 | ||
613 | extern void ks_activate(keyset */*ks*/); | |
614 | ||
615 | /* --- @ks_encrypt@ --- * | |
616 | * | |
617 | * Arguments: @keyset *ks@ = pointer to a keyset | |
7ed14135 | 618 | * @unsigned ty@ = message type |
832a2ab6 | 619 | * @buf *b@ = pointer to input buffer |
620 | * @buf *bb@ = pointer to output buffer | |
621 | * | |
622 | * Returns: Zero if OK, nonzero if the key needs replacing. If the | |
623 | * encryption failed, the output buffer is broken and zero is | |
624 | * returned. | |
625 | * | |
626 | * Use: Encrypts a block of data using the key. Note that the `key | |
627 | * ought to be replaced' notification is only ever given once | |
628 | * for each key. Also note that this call forces a keyset to be | |
629 | * used even if it's marked as not for data output. | |
630 | */ | |
631 | ||
7ed14135 | 632 | extern int ks_encrypt(keyset */*ks*/, unsigned /*ty*/, |
633 | buf */*b*/, buf */*bb*/); | |
832a2ab6 | 634 | |
635 | /* --- @ks_decrypt@ --- * | |
636 | * | |
637 | * Arguments: @keyset *ks@ = pointer to a keyset | |
7ed14135 | 638 | * @unsigned ty@ = expected type code |
832a2ab6 | 639 | * @buf *b@ = pointer to an input buffer |
640 | * @buf *bb@ = pointer to an output buffer | |
641 | * | |
642 | * Returns: Zero on success, or nonzero if there was some problem. | |
643 | * | |
644 | * Use: Attempts to decrypt a message using a given key. Note that | |
645 | * requesting decryption with a key directly won't clear a | |
646 | * marking that it's not for encryption. | |
647 | */ | |
648 | ||
7ed14135 | 649 | extern int ks_decrypt(keyset */*ks*/, unsigned /*ty*/, |
650 | buf */*b*/, buf */*bb*/); | |
832a2ab6 | 651 | |
652 | /* --- @ksl_free@ --- * | |
410c8acf | 653 | * |
654 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
655 | * | |
656 | * Returns: --- | |
657 | * | |
832a2ab6 | 658 | * Use: Frees (releases references to) all of the keys in a keyset. |
410c8acf | 659 | */ |
660 | ||
832a2ab6 | 661 | extern void ksl_free(keyset **/*ksroot*/); |
410c8acf | 662 | |
832a2ab6 | 663 | /* --- @ksl_link@ --- * |
410c8acf | 664 | * |
665 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
832a2ab6 | 666 | * @keyset *ks@ = pointer to a keyset |
410c8acf | 667 | * |
668 | * Returns: --- | |
669 | * | |
832a2ab6 | 670 | * Use: Links a keyset into a list. A keyset can only be on one list |
671 | * at a time. Bad things happen otherwise. | |
410c8acf | 672 | */ |
673 | ||
832a2ab6 | 674 | extern void ksl_link(keyset **/*ksroot*/, keyset */*ks*/); |
410c8acf | 675 | |
832a2ab6 | 676 | /* --- @ksl_prune@ --- * |
410c8acf | 677 | * |
678 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
410c8acf | 679 | * |
832a2ab6 | 680 | * Returns: --- |
410c8acf | 681 | * |
832a2ab6 | 682 | * Use: Prunes the keyset list by removing keys which mustn't be used |
683 | * any more. | |
410c8acf | 684 | */ |
685 | ||
832a2ab6 | 686 | extern void ksl_prune(keyset **/*ksroot*/); |
410c8acf | 687 | |
832a2ab6 | 688 | /* --- @ksl_encrypt@ --- * |
410c8acf | 689 | * |
690 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
7ed14135 | 691 | * @unsigned ty@ = message type |
410c8acf | 692 | * @buf *b@ = pointer to input buffer |
693 | * @buf *bb@ = pointer to output buffer | |
694 | * | |
695 | * Returns: Nonzero if a new key is needed. | |
696 | * | |
697 | * Use: Encrypts a packet. | |
698 | */ | |
699 | ||
7ed14135 | 700 | extern int ksl_encrypt(keyset **/*ksroot*/, unsigned /*ty*/, |
701 | buf */*b*/, buf */*bb*/); | |
410c8acf | 702 | |
832a2ab6 | 703 | /* --- @ksl_decrypt@ --- * |
410c8acf | 704 | * |
705 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
7ed14135 | 706 | * @unsigned ty@ = expected type code |
410c8acf | 707 | * @buf *b@ = pointer to input buffer |
708 | * @buf *bb@ = pointer to output buffer | |
709 | * | |
710 | * Returns: Nonzero if the packet couldn't be decrypted. | |
711 | * | |
712 | * Use: Decrypts a packet. | |
713 | */ | |
714 | ||
7ed14135 | 715 | extern int ksl_decrypt(keyset **/*ksroot*/, unsigned /*ty*/, |
716 | buf */*b*/, buf */*bb*/); | |
410c8acf | 717 | |
37941236 | 718 | /*----- Challenges --------------------------------------------------------*/ |
719 | ||
720 | /* --- @c_new@ --- * | |
721 | * | |
722 | * Arguments: @buf *b@ = where to put the challenge | |
723 | * | |
724 | * Returns: Zero if OK, nonzero on error. | |
725 | * | |
726 | * Use: Issues a new challenge. | |
727 | */ | |
728 | ||
729 | extern int c_new(buf */*b*/); | |
730 | ||
731 | /* --- @c_check@ --- * | |
732 | * | |
733 | * Arguments: @buf *b@ = where to find the challenge | |
734 | * | |
735 | * Returns: Zero if OK, nonzero if it didn't work. | |
736 | * | |
737 | * Use: Checks a challenge. On failure, the buffer is broken. | |
738 | */ | |
739 | ||
740 | extern int c_check(buf */*b*/); | |
741 | ||
410c8acf | 742 | /*----- Administration interface ------------------------------------------*/ |
743 | ||
f43df819 MW |
744 | #define A_END ((char *)0) |
745 | ||
410c8acf | 746 | /* --- @a_warn@ --- * |
747 | * | |
748 | * Arguments: @const char *fmt@ = pointer to format string | |
749 | * @...@ = other arguments | |
750 | * | |
751 | * Returns: --- | |
752 | * | |
753 | * Use: Informs all admin connections of a warning. | |
754 | */ | |
755 | ||
756 | extern void a_warn(const char */*fmt*/, ...); | |
757 | ||
3cdc3f3a | 758 | /* --- @a_notify@ --- * |
759 | * | |
760 | * Arguments: @const char *fmt@ = pointer to format string | |
761 | * @...@ = other arguments | |
762 | * | |
763 | * Returns: --- | |
764 | * | |
765 | * Use: Sends a notification to interested admin connections. | |
766 | */ | |
767 | ||
768 | extern void a_notify(const char */*fmt*/, ...); | |
769 | ||
410c8acf | 770 | /* --- @a_create@ --- * |
771 | * | |
772 | * Arguments: @int fd_in, fd_out@ = file descriptors to use | |
3cdc3f3a | 773 | * @unsigned f@ = initial flags to set |
410c8acf | 774 | * |
775 | * Returns: --- | |
776 | * | |
777 | * Use: Creates a new admin connection. | |
778 | */ | |
779 | ||
3cdc3f3a | 780 | extern void a_create(int /*fd_in*/, int /*fd_out*/, unsigned /*f*/); |
410c8acf | 781 | |
782 | /* --- @a_quit@ --- * | |
783 | * | |
784 | * Arguments: --- | |
785 | * | |
786 | * Returns: --- | |
787 | * | |
788 | * Use: Shuts things down nicely. | |
789 | */ | |
790 | ||
791 | extern void a_quit(void); | |
792 | ||
793 | /* --- @a_daemon@ --- * | |
794 | * | |
795 | * Arguments: --- | |
796 | * | |
797 | * Returns: --- | |
798 | * | |
799 | * Use: Informs the admin module that it's a daemon. | |
800 | */ | |
801 | ||
802 | extern void a_daemon(void); | |
803 | ||
804 | /* --- @a_init@ --- * | |
805 | * | |
806 | * Arguments: @const char *sock@ = socket name to create | |
807 | * | |
808 | * Returns: --- | |
809 | * | |
810 | * Use: Creates the admin listening socket. | |
811 | */ | |
812 | ||
813 | extern void a_init(const char */*sock*/); | |
814 | ||
815 | /*----- Peer management ---------------------------------------------------*/ | |
816 | ||
817 | /* --- @p_txstart@ --- * | |
818 | * | |
819 | * Arguments: @peer *p@ = pointer to peer block | |
820 | * @unsigned msg@ = message type code | |
821 | * | |
822 | * Returns: A pointer to a buffer to write to. | |
823 | * | |
824 | * Use: Starts sending to a peer. Only one send can happen at a | |
825 | * time. | |
826 | */ | |
827 | ||
828 | extern buf *p_txstart(peer */*p*/, unsigned /*msg*/); | |
829 | ||
830 | /* --- @p_txend@ --- * | |
831 | * | |
832 | * Arguments: @peer *p@ = pointer to peer block | |
833 | * | |
834 | * Returns: --- | |
835 | * | |
836 | * Use: Sends a packet to the peer. | |
837 | */ | |
838 | ||
839 | extern void p_txend(peer */*p*/); | |
840 | ||
0ba8de86 | 841 | /* --- @p_pingsend@ --- * |
842 | * | |
843 | * Arguments: @peer *p@ = destination peer | |
844 | * @ping *pg@ = structure to fill in | |
845 | * @unsigned type@ = message type | |
846 | * @unsigned long timeout@ = how long to wait before giving up | |
847 | * @void (*func)(int, void *)@ = callback function | |
848 | * @void *arg@ = argument for callback | |
849 | * | |
850 | * Returns: Zero if successful, nonzero if it failed. | |
851 | * | |
852 | * Use: Sends a ping to a peer. Call @func@ with a nonzero argument | |
853 | * if we get an answer within the timeout, or zero if no answer. | |
854 | */ | |
855 | ||
856 | extern int p_pingsend(peer */*p*/, ping */*pg*/, unsigned /*type*/, | |
857 | unsigned long /*timeout*/, | |
858 | void (*/*func*/)(int, void *), void */*arg*/); | |
859 | ||
860 | /* --- @p_pingdone@ --- * | |
861 | * | |
862 | * Arguments: @ping *p@ = ping structure | |
863 | * @int rc@ = return code to pass on | |
864 | * | |
865 | * Returns: --- | |
866 | * | |
867 | * Use: Disposes of a ping structure, maybe sending a notification. | |
868 | */ | |
869 | ||
870 | extern void p_pingdone(ping */*p*/, int /*rc*/); | |
871 | ||
37941236 | 872 | /* --- @p_greet@ --- * |
873 | * | |
874 | * Arguments: @peer *p@ = peer to send to | |
875 | * @const void *c@ = pointer to challenge | |
876 | * @size_t sz@ = size of challenge | |
877 | * | |
878 | * Returns: --- | |
879 | * | |
880 | * Use: Sends a greeting packet. | |
881 | */ | |
882 | ||
883 | extern void p_greet(peer */*p*/, const void */*c*/, size_t /*sz*/); | |
884 | ||
410c8acf | 885 | /* --- @p_tun@ --- * |
886 | * | |
887 | * Arguments: @peer *p@ = pointer to peer block | |
888 | * @buf *b@ = buffer containing incoming packet | |
889 | * | |
890 | * Returns: --- | |
891 | * | |
892 | * Use: Handles a packet which needs to be sent to a peer. | |
893 | */ | |
894 | ||
895 | extern void p_tun(peer */*p*/, buf */*b*/); | |
896 | ||
de014da6 | 897 | /* --- @p_keyreload@ --- * |
898 | * | |
899 | * Arguments: --- | |
900 | * | |
901 | * Returns: --- | |
902 | * | |
903 | * Use: Forces a check of the daemon's keyring files. | |
904 | */ | |
905 | ||
906 | extern void p_keyreload(void); | |
907 | ||
410c8acf | 908 | /* --- @p_interval@ --- * |
909 | * | |
910 | * Arguments: --- | |
911 | * | |
912 | * Returns: --- | |
913 | * | |
914 | * Use: Called periodically to do tidying. | |
915 | */ | |
916 | ||
917 | extern void p_interval(void); | |
918 | ||
832a2ab6 | 919 | /* --- @p_stats@ --- * |
920 | * | |
921 | * Arguments: @peer *p@ = pointer to a peer block | |
922 | * | |
923 | * Returns: A pointer to the peer's statistics. | |
924 | */ | |
925 | ||
926 | extern stats *p_stats(peer */*p*/); | |
927 | ||
410c8acf | 928 | /* --- @p_ifname@ --- * |
929 | * | |
930 | * Arguments: @peer *p@ = pointer to a peer block | |
931 | * | |
932 | * Returns: A pointer to the peer's interface name. | |
933 | */ | |
934 | ||
935 | extern const char *p_ifname(peer */*p*/); | |
936 | ||
937 | /* --- @p_addr@ --- * | |
938 | * | |
939 | * Arguments: @peer *p@ = pointer to a peer block | |
940 | * | |
941 | * Returns: A pointer to the peer's address. | |
942 | */ | |
943 | ||
944 | extern const addr *p_addr(peer */*p*/); | |
945 | ||
946 | /* --- @p_init@ --- * | |
947 | * | |
767b36e2 | 948 | * Arguments: @struct in_addr addr@ = address to bind to |
949 | * @unsigned port@ = port number to listen to | |
410c8acf | 950 | * |
951 | * Returns: --- | |
952 | * | |
953 | * Use: Initializes the peer system; creates the socket. | |
954 | */ | |
955 | ||
767b36e2 | 956 | extern void p_init(struct in_addr /*addr*/, unsigned /*port*/); |
410c8acf | 957 | |
958 | /* --- @p_port@ --- * | |
959 | * | |
960 | * Arguments: --- | |
961 | * | |
962 | * Returns: Port number used for socket. | |
963 | */ | |
964 | ||
965 | unsigned p_port(void); | |
966 | ||
967 | /* --- @p_create@ --- * | |
968 | * | |
0ba8de86 | 969 | * Arguments: @peerspec *spec@ = information about this peer |
410c8acf | 970 | * |
971 | * Returns: Pointer to the peer block, or null if it failed. | |
972 | * | |
973 | * Use: Creates a new named peer block. No peer is actually attached | |
974 | * by this point. | |
975 | */ | |
976 | ||
0ba8de86 | 977 | extern peer *p_create(peerspec */*spec*/); |
410c8acf | 978 | |
979 | /* --- @p_name@ --- * | |
980 | * | |
981 | * Arguments: @peer *p@ = pointer to a peer block | |
982 | * | |
983 | * Returns: A pointer to the peer's name. | |
060ca767 | 984 | * |
985 | * Use: Equivalent to @p_spec(p)->name@. | |
410c8acf | 986 | */ |
987 | ||
988 | extern const char *p_name(peer */*p*/); | |
989 | ||
060ca767 | 990 | /* --- @p_spec@ --- * |
991 | * | |
992 | * Arguments: @peer *p@ = pointer to a peer block | |
993 | * | |
994 | * Returns: Pointer to the peer's specification | |
995 | */ | |
996 | ||
997 | extern const peerspec *p_spec(peer */*p*/); | |
998 | ||
410c8acf | 999 | /* --- @p_find@ --- * |
1000 | * | |
1001 | * Arguments: @const char *name@ = name to look up | |
1002 | * | |
1003 | * Returns: Pointer to the peer block, or null if not found. | |
1004 | * | |
1005 | * Use: Finds a peer by name. | |
1006 | */ | |
1007 | ||
1008 | extern peer *p_find(const char */*name*/); | |
1009 | ||
1010 | /* --- @p_destroy@ --- * | |
1011 | * | |
1012 | * Arguments: @peer *p@ = pointer to a peer | |
1013 | * | |
1014 | * Returns: --- | |
1015 | * | |
1016 | * Use: Destroys a peer. | |
1017 | */ | |
1018 | ||
1019 | extern void p_destroy(peer */*p*/); | |
1020 | ||
1021 | /* --- @p_first@, @p_next@ --- * | |
1022 | * | |
1023 | * Arguments: @peer *p@ = a peer block | |
1024 | * | |
1025 | * Returns: @peer_first@ returns the first peer in some ordering; | |
1026 | * @peer_next@ returns the peer following a given one in the | |
1027 | * same ordering. Null is returned for the end of the list. | |
1028 | */ | |
1029 | ||
1030 | extern peer *p_first(void); | |
1031 | extern peer *p_next(peer */*p*/); | |
1032 | ||
42da2a58 | 1033 | /*----- Tunnel drivers ----------------------------------------------------*/ |
410c8acf | 1034 | |
42da2a58 | 1035 | #ifdef TUN_LINUX |
1036 | extern const tunnel_ops tun_linux; | |
1037 | #endif | |
410c8acf | 1038 | |
42da2a58 | 1039 | #ifdef TUN_UNET |
1040 | extern const tunnel_ops tun_unet; | |
1041 | #endif | |
410c8acf | 1042 | |
42da2a58 | 1043 | #ifdef TUN_BSD |
1044 | extern const tunnel_ops tun_bsd; | |
1045 | #endif | |
410c8acf | 1046 | |
42da2a58 | 1047 | extern const tunnel_ops tun_slip; |
410c8acf | 1048 | |
410c8acf | 1049 | /*----- Other handy utilities ---------------------------------------------*/ |
1050 | ||
1051 | /* --- @mpstr@ --- * | |
1052 | * | |
1053 | * Arguments: @mp *m@ = a multiprecision integer | |
1054 | * | |
1055 | * Returns: A pointer to the integer's textual representation. | |
1056 | * | |
1057 | * Use: Converts a multiprecision integer to a string. Corrupts | |
832a2ab6 | 1058 | * @buf_t@. |
410c8acf | 1059 | */ |
1060 | ||
1061 | extern const char *mpstr(mp */*m*/); | |
1062 | ||
52c03a2a | 1063 | /* --- @gestr@ --- * |
1064 | * | |
1065 | * Arguments: @group *g@ = a group | |
1066 | * @ge *x@ = a group element | |
1067 | * | |
1068 | * Returns: A pointer to the element's textual representation. | |
1069 | * | |
1070 | * Use: Converts a group element to a string. Corrupts | |
1071 | * @buf_t@. | |
1072 | */ | |
1073 | ||
1074 | extern const char *gestr(group */*g*/, ge */*x*/); | |
1075 | ||
832a2ab6 | 1076 | /* --- @timestr@ --- * |
1077 | * | |
1078 | * Arguments: @time_t t@ = a time to convert | |
1079 | * | |
1080 | * Returns: A pointer to a textual representation of the time. | |
1081 | * | |
1082 | * Use: Converts a time to a textual representation. Corrupts | |
1083 | * @buf_t@. | |
1084 | */ | |
1085 | ||
1086 | extern const char *timestr(time_t /*t*/); | |
1087 | ||
42da2a58 | 1088 | /* --- @mystrieq@ --- * |
1089 | * | |
1090 | * Arguments: @const char *x, *y@ = two strings | |
1091 | * | |
1092 | * Returns: True if @x@ and @y are equal, up to case. | |
1093 | */ | |
1094 | ||
1095 | extern int mystrieq(const char */*x*/, const char */*y*/); | |
1096 | ||
37941236 | 1097 | /* --- @seq_reset@ --- * |
1098 | * | |
1099 | * Arguments: @seqwin *s@ = sequence-checking window | |
1100 | * | |
1101 | * Returns: --- | |
1102 | * | |
1103 | * Use: Resets a sequence number window. | |
1104 | */ | |
1105 | ||
1106 | extern void seq_reset(seqwin */*s*/); | |
1107 | ||
1108 | /* --- @seq_check@ --- * | |
1109 | * | |
1110 | * Arguments: @seqwin *s@ = sequence-checking window | |
1111 | * @uint32 q@ = sequence number to check | |
f43df819 | 1112 | * @const char *service@ = service to report message from |
37941236 | 1113 | * |
1114 | * Returns: A @SEQ_@ code. | |
1115 | * | |
1116 | * Use: Checks a sequence number against the window, updating things | |
1117 | * as necessary. | |
1118 | */ | |
1119 | ||
f43df819 | 1120 | extern int seq_check(seqwin */*s*/, uint32 /*q*/, const char */*service*/); |
37941236 | 1121 | |
410c8acf | 1122 | /*----- That's all, folks -------------------------------------------------*/ |
1123 | ||
1124 | #ifdef __cplusplus | |
1125 | } | |
1126 | #endif | |
1127 | ||
1128 | #endif |