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 |
832a2ab6 | 215 | |
216 | typedef struct kxchal { | |
217 | struct keyexch *kx; /* Pointer back to key exchange */ | |
52c03a2a | 218 | ge *c; /* Responder's challenge */ |
219 | ge *r; /* My reply to the challenge */ | |
832a2ab6 | 220 | keyset *ks; /* Pointer to temporary keyset */ |
221 | unsigned f; /* Various useful flags */ | |
222 | sel_timer t; /* Response timer for challenge */ | |
b5c45da1 | 223 | octet hc[MAXHASHSZ]; /* Hash of his challenge */ |
de7bd20b | 224 | octet ck[MAXHASHSZ]; /* His magical check value */ |
b5c45da1 | 225 | octet hswrq_in[MAXHASHSZ]; /* Inbound switch request message */ |
226 | octet hswok_in[MAXHASHSZ]; /* Inbound switch confirmation */ | |
227 | octet hswrq_out[MAXHASHSZ]; /* Outbound switch request message */ | |
228 | octet hswok_out[MAXHASHSZ]; /* Outbound switch confirmation */ | |
832a2ab6 | 229 | } kxchal; |
230 | ||
410c8acf | 231 | typedef struct keyexch { |
410c8acf | 232 | struct peer *p; /* Pointer back to the peer */ |
832a2ab6 | 233 | keyset **ks; /* Peer's list of keysets */ |
410c8acf | 234 | unsigned f; /* Various useful flags */ |
832a2ab6 | 235 | unsigned s; /* Current state in exchange */ |
410c8acf | 236 | sel_timer t; /* Timer for next exchange */ |
52c03a2a | 237 | ge *kpub; /* Peer's public key */ |
00e64b67 | 238 | time_t texp_kpub; /* Expiry time for public key */ |
832a2ab6 | 239 | mp *alpha; /* My temporary secret */ |
52c03a2a | 240 | ge *c; /* My challenge */ |
241 | ge *rx; /* The expected response */ | |
832a2ab6 | 242 | unsigned nr; /* Number of extant responses */ |
410c8acf | 243 | time_t t_valid; /* When this exchange goes bad */ |
b5c45da1 | 244 | octet hc[MAXHASHSZ]; /* Hash of my challenge */ |
832a2ab6 | 245 | kxchal *r[KX_NCHAL]; /* Array of challenges */ |
410c8acf | 246 | } keyexch; |
247 | ||
248 | #define KXF_TIMER 1u /* Waiting for a timer to go off */ | |
00e64b67 | 249 | #define KXF_DEAD 2u /* The key-exchanger isn't up */ |
250 | #define KXF_PUBKEY 4u /* Key exchanger has a public key */ | |
832a2ab6 | 251 | |
252 | enum { | |
253 | KXS_DEAD, /* Uninitialized state (magical) */ | |
254 | KXS_CHAL, /* Main answer-challenges state */ | |
255 | KXS_COMMIT, /* Committed: send switch request */ | |
256 | KXS_SWITCH /* Switched: send confirmation */ | |
257 | }; | |
410c8acf | 258 | |
259 | /* --- Tunnel structure --- * | |
260 | * | |
261 | * Used to maintain system-specific information about the tunnel interface. | |
262 | */ | |
263 | ||
42da2a58 | 264 | typedef struct tunnel tunnel; |
265 | struct peer; | |
110d564e | 266 | |
42da2a58 | 267 | typedef struct tunnel_ops { |
268 | const char *name; /* Name of this tunnel driver */ | |
269 | void (*init)(void); /* Initializes the system */ | |
270 | tunnel *(*create)(struct peer */*p*/); /* Initializes a new tunnel */ | |
271 | const char *(*ifname)(tunnel */*t*/); /* Returns tunnel's interface name */ | |
272 | void (*inject)(tunnel */*t*/, buf */*b*/); /* Sends packet through if */ | |
273 | void (*destroy)(tunnel */*t*/); /* Destroys a tunnel */ | |
274 | } tunnel_ops; | |
b9066fbb | 275 | |
42da2a58 | 276 | #ifndef TUN_INTERNALS |
277 | struct tunnel { const tunnel_ops *ops; }; | |
410c8acf | 278 | #endif |
410c8acf | 279 | |
832a2ab6 | 280 | /* --- Peer statistics --- * |
281 | * | |
282 | * Contains various interesting and not-so-interesting statistics about a | |
283 | * peer. This is updated by various parts of the code. The format of the | |
284 | * structure isn't considered private, and @p_stats@ returns a pointer to the | |
285 | * statistics block for a given peer. | |
286 | */ | |
287 | ||
288 | typedef struct stats { | |
289 | unsigned long sz_in, sz_out; /* Size of all data in and out */ | |
290 | unsigned long sz_kxin, sz_kxout; /* Size of key exchange messages */ | |
291 | unsigned long sz_ipin, sz_ipout; /* Size of encapsulated IP packets */ | |
3cdc3f3a | 292 | time_t t_start, t_last, t_kx; /* Time peer created, last pk, kx */ |
832a2ab6 | 293 | unsigned long n_reject; /* Number of rejected packets */ |
294 | unsigned long n_in, n_out; /* Number of packets in and out */ | |
295 | unsigned long n_kxin, n_kxout; /* Number of key exchange packets */ | |
296 | unsigned long n_ipin, n_ipout; /* Number of encrypted packets */ | |
297 | } stats; | |
298 | ||
410c8acf | 299 | /* --- Peer structure --- * |
300 | * | |
301 | * The main structure which glues everything else together. | |
302 | */ | |
303 | ||
0ba8de86 | 304 | typedef struct peerspec { |
305 | char *name; /* Peer's name */ | |
306 | const tunnel_ops *tops; /* Tunnel operations */ | |
307 | unsigned long t_ka; /* Keep alive interval */ | |
308 | addr sa; /* Socket address to speak to */ | |
309 | size_t sasz; /* Socket address size */ | |
310 | } peerspec; | |
311 | ||
410c8acf | 312 | typedef struct peer { |
313 | struct peer *next, *prev; /* Links to next and previous */ | |
0ba8de86 | 314 | struct ping *pings; /* Pings we're waiting for */ |
315 | peerspec spec; /* Specifications for this peer */ | |
42da2a58 | 316 | tunnel *t; /* Tunnel for local packets */ |
410c8acf | 317 | keyset *ks; /* List head for keysets */ |
410c8acf | 318 | buf b; /* Buffer for sending packets */ |
832a2ab6 | 319 | stats st; /* Statistics */ |
320 | keyexch kx; /* Key exchange protocol block */ | |
0ba8de86 | 321 | sel_timer tka; /* Timer for keepalives */ |
410c8acf | 322 | } peer; |
323 | ||
0ba8de86 | 324 | typedef struct ping { |
325 | struct ping *next, *prev; /* Links to next and previous */ | |
326 | peer *p; /* Peer so we can free it */ | |
327 | unsigned msg; /* Kind of response expected */ | |
328 | uint32 id; /* Id so we can recognize response */ | |
329 | octet magic[32]; /* Some random data */ | |
330 | sel_timer t; /* Timeout for ping */ | |
331 | void (*func)(int /*rc*/, void */*arg*/); /* Function to call when done */ | |
332 | void *arg; /* Argument for callback */ | |
333 | } ping; | |
334 | ||
335 | enum { | |
336 | PING_NONOTIFY = -1, | |
337 | PING_OK = 0, | |
338 | PING_TIMEOUT, | |
339 | PING_PEERDIED, | |
340 | PING_MAX | |
341 | }; | |
342 | ||
410c8acf | 343 | /* --- Admin structure --- */ |
344 | ||
fd3cf232 | 345 | #define OBUFSZ 16384u |
346 | ||
347 | typedef struct obuf { | |
348 | struct obuf *next; /* Next buffer in list */ | |
349 | char *p_in, *p_out; /* Pointers into the buffer */ | |
350 | char buf[OBUFSZ]; /* The actual buffer */ | |
351 | } obuf; | |
352 | ||
de014da6 | 353 | typedef struct oqueue { |
354 | obuf *hd, *tl; /* Head and tail pointers */ | |
355 | } oqueue; | |
356 | ||
357 | struct admin; | |
358 | ||
359 | typedef struct admin_bgop { | |
360 | struct admin_bgop *next, *prev; /* Links to next and previous */ | |
361 | struct admin *a; /* Owner job */ | |
362 | char *tag; /* Tag string for messages */ | |
363 | void (*cancel)(struct admin_bgop *); /* Destructor function */ | |
364 | } admin_bgop; | |
365 | ||
37941236 | 366 | typedef struct admin_resop { |
de014da6 | 367 | admin_bgop bg; /* Background operation header */ |
37941236 | 368 | char *addr; /* Hostname to be resolved */ |
de014da6 | 369 | bres_client r; /* Background resolver task */ |
370 | sel_timer t; /* Timer for resolver */ | |
37941236 | 371 | addr sa; /* Socket address */ |
372 | size_t sasz; /* Socket address size */ | |
373 | void (*func)(struct admin_resop *, int); /* Handler */ | |
374 | } admin_resop; | |
375 | ||
376 | enum { ARES_OK, ARES_FAIL }; | |
377 | ||
378 | typedef struct admin_addop { | |
379 | admin_resop r; /* Name resolution header */ | |
380 | peerspec peer; /* Peer pending creation */ | |
de014da6 | 381 | } admin_addop; |
382 | ||
37941236 | 383 | typedef struct admin_greetop { |
384 | admin_resop r; /* Name resolution header */ | |
385 | void *c; /* Challenge block */ | |
386 | size_t sz; /* Length of challenge */ | |
387 | } admin_greetop; | |
388 | ||
de014da6 | 389 | typedef struct admin_pingop { |
390 | admin_bgop bg; /* Background operation header */ | |
391 | ping ping; /* Ping pending response */ | |
392 | struct timeval pingtime; /* Time last ping was sent */ | |
393 | } admin_pingop; | |
394 | ||
410c8acf | 395 | typedef struct admin { |
396 | struct admin *next, *prev; /* Links to next and previous */ | |
fd3cf232 | 397 | unsigned f; /* Various useful flags */ |
060ca767 | 398 | unsigned ref; /* Reference counter */ |
410c8acf | 399 | #ifndef NTRACE |
400 | unsigned seq; /* Sequence number for tracing */ | |
401 | #endif | |
de014da6 | 402 | oqueue out; /* Output buffer list */ |
403 | oqueue delay; /* Delayed output buffer list */ | |
404 | admin_bgop *bg; /* Backgrounded operations */ | |
fd3cf232 | 405 | selbuf b; /* Line buffer for commands */ |
406 | sel_file w; /* Selector for write buffering */ | |
410c8acf | 407 | } admin; |
408 | ||
fd3cf232 | 409 | #define AF_DEAD 1u /* Destroy this admin block */ |
060ca767 | 410 | #define AF_CLOSE 2u /* Client closed connection */ |
3cdc3f3a | 411 | #define AF_NOTE 4u /* Catch notifications */ |
de014da6 | 412 | #define AF_WARN 8u /* Catch warning messages */ |
3cdc3f3a | 413 | #ifndef NTRACE |
de014da6 | 414 | #define AF_TRACE 16u /* Catch tracing */ |
3cdc3f3a | 415 | #endif |
3cdc3f3a | 416 | |
417 | #ifndef NTRACE | |
418 | # define AF_ALLMSGS (AF_NOTE | AF_TRACE | AF_WARN) | |
419 | #else | |
420 | # define AF_ALLMSGS (AF_NOTE | AF_WARN) | |
421 | #endif | |
fd3cf232 | 422 | |
410c8acf | 423 | /*----- Global variables --------------------------------------------------*/ |
424 | ||
425 | extern sel_state sel; /* Global I/O event state */ | |
52c03a2a | 426 | extern group *gg; /* The group we work in */ |
de7bd20b | 427 | extern size_t indexsz; /* Size of exponent for the group */ |
52c03a2a | 428 | extern mp *kpriv; /* Our private key */ |
9317aa92 | 429 | extern ge *kpub; /* Our public key */ |
832a2ab6 | 430 | extern octet buf_i[PKBUFSZ], buf_o[PKBUFSZ], buf_t[PKBUFSZ]; |
42da2a58 | 431 | extern const tunnel_ops *tunnels[]; /* Table of tunnels (0-term) */ |
432 | extern const tunnel_ops *tun_default; /* Default tunnel to use */ | |
410c8acf | 433 | |
434 | #ifndef NTRACE | |
435 | extern const trace_opt tr_opts[]; /* Trace options array */ | |
436 | extern unsigned tr_flags; /* Trace options flags */ | |
437 | #endif | |
438 | ||
8d0c7a83 | 439 | /*----- Other macros ------------------------------------------------------*/ |
440 | ||
441 | #define TIMER noise_timer(RAND_GLOBAL) | |
442 | ||
410c8acf | 443 | /*----- Key management ----------------------------------------------------*/ |
444 | ||
de014da6 | 445 | /* --- @km_reload@ --- * |
410c8acf | 446 | * |
447 | * Arguments: --- | |
448 | * | |
449 | * Returns: Zero if OK, nonzero to force reloading of keys. | |
450 | * | |
de014da6 | 451 | * Use: Checks the keyrings to see if they need reloading. |
410c8acf | 452 | */ |
453 | ||
de014da6 | 454 | extern int km_reload(void); |
410c8acf | 455 | |
456 | /* --- @km_init@ --- * | |
457 | * | |
458 | * Arguments: @const char *kr_priv@ = private keyring file | |
459 | * @const char *kr_pub@ = public keyring file | |
460 | * @const char *tag@ = tag to load | |
461 | * | |
462 | * Returns: --- | |
463 | * | |
464 | * Use: Initializes, and loads the private key. | |
465 | */ | |
466 | ||
467 | extern void km_init(const char */*kr_priv*/, const char */*kr_pub*/, | |
468 | const char */*tag*/); | |
469 | ||
470 | /* --- @km_getpubkey@ --- * | |
471 | * | |
472 | * Arguments: @const char *tag@ = public key tag to load | |
52c03a2a | 473 | * @ge *kpub@ = where to put the public key |
00e64b67 | 474 | * @time_t *t_exp@ = where to put the expiry time |
410c8acf | 475 | * |
476 | * Returns: Zero if OK, nonzero if it failed. | |
477 | * | |
478 | * Use: Fetches a public key from the keyring. | |
479 | */ | |
480 | ||
52c03a2a | 481 | extern int km_getpubkey(const char */*tag*/, ge */*kpub*/, |
00e64b67 | 482 | time_t */*t_exp*/); |
410c8acf | 483 | |
484 | /*----- Key exchange ------------------------------------------------------*/ | |
485 | ||
486 | /* --- @kx_start@ --- * | |
487 | * | |
488 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
de014da6 | 489 | * @int forcep@ = nonzero to ignore the quiet timer |
410c8acf | 490 | * |
491 | * Returns: --- | |
492 | * | |
493 | * Use: Stimulates a key exchange. If a key exchage is in progress, | |
494 | * a new challenge is sent (unless the quiet timer forbids | |
495 | * this); if no exchange is in progress, one is commenced. | |
496 | */ | |
497 | ||
de014da6 | 498 | extern void kx_start(keyexch */*kx*/, int /*forcep*/); |
410c8acf | 499 | |
832a2ab6 | 500 | /* --- @kx_message@ --- * |
410c8acf | 501 | * |
502 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
832a2ab6 | 503 | * @unsigned msg@ = the message code |
504 | * @buf *b@ = pointer to buffer containing the packet | |
410c8acf | 505 | * |
506 | * Returns: --- | |
507 | * | |
832a2ab6 | 508 | * Use: Reads a packet containing key exchange messages and handles |
509 | * it. | |
410c8acf | 510 | */ |
511 | ||
832a2ab6 | 512 | extern void kx_message(keyexch */*kx*/, unsigned /*msg*/, buf */*b*/); |
410c8acf | 513 | |
514 | /* --- @kx_free@ --- * | |
515 | * | |
516 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
517 | * | |
518 | * Returns: --- | |
519 | * | |
520 | * Use: Frees everything in a key exchange context. | |
521 | */ | |
522 | ||
523 | extern void kx_free(keyexch */*kx*/); | |
524 | ||
525 | /* --- @kx_newkeys@ --- * | |
526 | * | |
527 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
528 | * | |
529 | * Returns: --- | |
530 | * | |
531 | * Use: Informs the key exchange module that its keys may have | |
532 | * changed. If fetching the new keys fails, the peer will be | |
533 | * destroyed, we log messages and struggle along with the old | |
534 | * keys. | |
535 | */ | |
536 | ||
537 | extern void kx_newkeys(keyexch */*kx*/); | |
538 | ||
539 | /* --- @kx_init@ --- * | |
540 | * | |
541 | * Arguments: @keyexch *kx@ = pointer to key exchange context | |
542 | * @peer *p@ = pointer to peer context | |
543 | * @keyset **ks@ = pointer to keyset list | |
544 | * | |
545 | * Returns: Zero if OK, nonzero if it failed. | |
546 | * | |
547 | * Use: Initializes a key exchange module. The module currently | |
548 | * contains no keys, and will attempt to initiate a key | |
549 | * exchange. | |
550 | */ | |
551 | ||
552 | extern int kx_init(keyexch */*kx*/, peer */*p*/, keyset **/*ks*/); | |
553 | ||
554 | /*----- Keysets and symmetric cryptography --------------------------------*/ | |
555 | ||
832a2ab6 | 556 | /* --- @ks_drop@ --- * |
557 | * | |
558 | * Arguments: @keyset *ks@ = pointer to a keyset | |
559 | * | |
560 | * Returns: --- | |
561 | * | |
562 | * Use: Decrements a keyset's reference counter. If the counter hits | |
563 | * zero, the keyset is freed. | |
564 | */ | |
565 | ||
566 | extern void ks_drop(keyset */*ks*/); | |
567 | ||
568 | /* --- @ks_gen@ --- * | |
569 | * | |
570 | * Arguments: @const void *k@ = pointer to key material | |
571 | * @size_t x, y, z@ = offsets into key material (see below) | |
9466fafa | 572 | * @peer *p@ = pointer to peer information |
832a2ab6 | 573 | * |
574 | * Returns: A pointer to the new keyset. | |
575 | * | |
576 | * Use: Derives a new keyset from the given key material. The | |
577 | * offsets @x@, @y@ and @z@ separate the key material into three | |
578 | * parts. Between the @k@ and @k + x@ is `my' contribution to | |
579 | * the key material; between @k + x@ and @k + y@ is `your' | |
580 | * contribution; and between @k + y@ and @k + z@ is a shared | |
581 | * value we made together. These are used to construct two | |
582 | * pairs of symmetric keys. Each pair consists of an encryption | |
583 | * key and a message authentication key. One pair is used for | |
584 | * outgoing messages, the other for incoming messages. | |
585 | * | |
586 | * The new key is marked so that it won't be selected for output | |
587 | * by @ksl_encrypt@. You can still encrypt data with it by | |
588 | * calling @ks_encrypt@ directly. | |
589 | */ | |
590 | ||
591 | extern keyset *ks_gen(const void */*k*/, | |
9466fafa | 592 | size_t /*x*/, size_t /*y*/, size_t /*z*/, |
593 | peer */*p*/); | |
832a2ab6 | 594 | |
595 | /* --- @ks_tregen@ --- * | |
596 | * | |
597 | * Arguments: @keyset *ks@ = pointer to a keyset | |
598 | * | |
599 | * Returns: The time at which moves ought to be made to replace this key. | |
600 | */ | |
601 | ||
602 | extern time_t ks_tregen(keyset */*ks*/); | |
603 | ||
604 | /* --- @ks_activate@ --- * | |
605 | * | |
606 | * Arguments: @keyset *ks@ = pointer to a keyset | |
607 | * | |
608 | * Returns: --- | |
609 | * | |
610 | * Use: Activates a keyset, so that it can be used for encrypting | |
611 | * outgoing messages. | |
612 | */ | |
613 | ||
614 | extern void ks_activate(keyset */*ks*/); | |
615 | ||
616 | /* --- @ks_encrypt@ --- * | |
617 | * | |
618 | * Arguments: @keyset *ks@ = pointer to a keyset | |
7ed14135 | 619 | * @unsigned ty@ = message type |
832a2ab6 | 620 | * @buf *b@ = pointer to input buffer |
621 | * @buf *bb@ = pointer to output buffer | |
622 | * | |
623 | * Returns: Zero if OK, nonzero if the key needs replacing. If the | |
624 | * encryption failed, the output buffer is broken and zero is | |
625 | * returned. | |
626 | * | |
627 | * Use: Encrypts a block of data using the key. Note that the `key | |
628 | * ought to be replaced' notification is only ever given once | |
629 | * for each key. Also note that this call forces a keyset to be | |
630 | * used even if it's marked as not for data output. | |
631 | */ | |
632 | ||
7ed14135 | 633 | extern int ks_encrypt(keyset */*ks*/, unsigned /*ty*/, |
634 | buf */*b*/, buf */*bb*/); | |
832a2ab6 | 635 | |
636 | /* --- @ks_decrypt@ --- * | |
637 | * | |
638 | * Arguments: @keyset *ks@ = pointer to a keyset | |
7ed14135 | 639 | * @unsigned ty@ = expected type code |
832a2ab6 | 640 | * @buf *b@ = pointer to an input buffer |
641 | * @buf *bb@ = pointer to an output buffer | |
642 | * | |
643 | * Returns: Zero on success, or nonzero if there was some problem. | |
644 | * | |
645 | * Use: Attempts to decrypt a message using a given key. Note that | |
646 | * requesting decryption with a key directly won't clear a | |
647 | * marking that it's not for encryption. | |
648 | */ | |
649 | ||
7ed14135 | 650 | extern int ks_decrypt(keyset */*ks*/, unsigned /*ty*/, |
651 | buf */*b*/, buf */*bb*/); | |
832a2ab6 | 652 | |
653 | /* --- @ksl_free@ --- * | |
410c8acf | 654 | * |
655 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
656 | * | |
657 | * Returns: --- | |
658 | * | |
832a2ab6 | 659 | * Use: Frees (releases references to) all of the keys in a keyset. |
410c8acf | 660 | */ |
661 | ||
832a2ab6 | 662 | extern void ksl_free(keyset **/*ksroot*/); |
410c8acf | 663 | |
832a2ab6 | 664 | /* --- @ksl_link@ --- * |
410c8acf | 665 | * |
666 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
832a2ab6 | 667 | * @keyset *ks@ = pointer to a keyset |
410c8acf | 668 | * |
669 | * Returns: --- | |
670 | * | |
832a2ab6 | 671 | * Use: Links a keyset into a list. A keyset can only be on one list |
672 | * at a time. Bad things happen otherwise. | |
410c8acf | 673 | */ |
674 | ||
832a2ab6 | 675 | extern void ksl_link(keyset **/*ksroot*/, keyset */*ks*/); |
410c8acf | 676 | |
832a2ab6 | 677 | /* --- @ksl_prune@ --- * |
410c8acf | 678 | * |
679 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
410c8acf | 680 | * |
832a2ab6 | 681 | * Returns: --- |
410c8acf | 682 | * |
832a2ab6 | 683 | * Use: Prunes the keyset list by removing keys which mustn't be used |
684 | * any more. | |
410c8acf | 685 | */ |
686 | ||
832a2ab6 | 687 | extern void ksl_prune(keyset **/*ksroot*/); |
410c8acf | 688 | |
832a2ab6 | 689 | /* --- @ksl_encrypt@ --- * |
410c8acf | 690 | * |
691 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
7ed14135 | 692 | * @unsigned ty@ = message type |
410c8acf | 693 | * @buf *b@ = pointer to input buffer |
694 | * @buf *bb@ = pointer to output buffer | |
695 | * | |
696 | * Returns: Nonzero if a new key is needed. | |
697 | * | |
698 | * Use: Encrypts a packet. | |
699 | */ | |
700 | ||
7ed14135 | 701 | extern int ksl_encrypt(keyset **/*ksroot*/, unsigned /*ty*/, |
702 | buf */*b*/, buf */*bb*/); | |
410c8acf | 703 | |
832a2ab6 | 704 | /* --- @ksl_decrypt@ --- * |
410c8acf | 705 | * |
706 | * Arguments: @keyset **ksroot@ = pointer to keyset list head | |
7ed14135 | 707 | * @unsigned ty@ = expected type code |
410c8acf | 708 | * @buf *b@ = pointer to input buffer |
709 | * @buf *bb@ = pointer to output buffer | |
710 | * | |
711 | * Returns: Nonzero if the packet couldn't be decrypted. | |
712 | * | |
713 | * Use: Decrypts a packet. | |
714 | */ | |
715 | ||
7ed14135 | 716 | extern int ksl_decrypt(keyset **/*ksroot*/, unsigned /*ty*/, |
717 | buf */*b*/, buf */*bb*/); | |
410c8acf | 718 | |
37941236 | 719 | /*----- Challenges --------------------------------------------------------*/ |
720 | ||
721 | /* --- @c_new@ --- * | |
722 | * | |
723 | * Arguments: @buf *b@ = where to put the challenge | |
724 | * | |
725 | * Returns: Zero if OK, nonzero on error. | |
726 | * | |
727 | * Use: Issues a new challenge. | |
728 | */ | |
729 | ||
730 | extern int c_new(buf */*b*/); | |
731 | ||
732 | /* --- @c_check@ --- * | |
733 | * | |
734 | * Arguments: @buf *b@ = where to find the challenge | |
735 | * | |
736 | * Returns: Zero if OK, nonzero if it didn't work. | |
737 | * | |
738 | * Use: Checks a challenge. On failure, the buffer is broken. | |
739 | */ | |
740 | ||
741 | extern int c_check(buf */*b*/); | |
742 | ||
410c8acf | 743 | /*----- Administration interface ------------------------------------------*/ |
744 | ||
f43df819 MW |
745 | #define A_END ((char *)0) |
746 | ||
410c8acf | 747 | /* --- @a_warn@ --- * |
748 | * | |
749 | * Arguments: @const char *fmt@ = pointer to format string | |
750 | * @...@ = other arguments | |
751 | * | |
752 | * Returns: --- | |
753 | * | |
754 | * Use: Informs all admin connections of a warning. | |
755 | */ | |
756 | ||
757 | extern void a_warn(const char */*fmt*/, ...); | |
758 | ||
3cdc3f3a | 759 | /* --- @a_notify@ --- * |
760 | * | |
761 | * Arguments: @const char *fmt@ = pointer to format string | |
762 | * @...@ = other arguments | |
763 | * | |
764 | * Returns: --- | |
765 | * | |
766 | * Use: Sends a notification to interested admin connections. | |
767 | */ | |
768 | ||
769 | extern void a_notify(const char */*fmt*/, ...); | |
770 | ||
410c8acf | 771 | /* --- @a_create@ --- * |
772 | * | |
773 | * Arguments: @int fd_in, fd_out@ = file descriptors to use | |
3cdc3f3a | 774 | * @unsigned f@ = initial flags to set |
410c8acf | 775 | * |
776 | * Returns: --- | |
777 | * | |
778 | * Use: Creates a new admin connection. | |
779 | */ | |
780 | ||
3cdc3f3a | 781 | extern void a_create(int /*fd_in*/, int /*fd_out*/, unsigned /*f*/); |
410c8acf | 782 | |
783 | /* --- @a_quit@ --- * | |
784 | * | |
785 | * Arguments: --- | |
786 | * | |
787 | * Returns: --- | |
788 | * | |
789 | * Use: Shuts things down nicely. | |
790 | */ | |
791 | ||
792 | extern void a_quit(void); | |
793 | ||
794 | /* --- @a_daemon@ --- * | |
795 | * | |
796 | * Arguments: --- | |
797 | * | |
798 | * Returns: --- | |
799 | * | |
800 | * Use: Informs the admin module that it's a daemon. | |
801 | */ | |
802 | ||
803 | extern void a_daemon(void); | |
804 | ||
805 | /* --- @a_init@ --- * | |
806 | * | |
807 | * Arguments: @const char *sock@ = socket name to create | |
808 | * | |
809 | * Returns: --- | |
810 | * | |
811 | * Use: Creates the admin listening socket. | |
812 | */ | |
813 | ||
814 | extern void a_init(const char */*sock*/); | |
815 | ||
816 | /*----- Peer management ---------------------------------------------------*/ | |
817 | ||
818 | /* --- @p_txstart@ --- * | |
819 | * | |
820 | * Arguments: @peer *p@ = pointer to peer block | |
821 | * @unsigned msg@ = message type code | |
822 | * | |
823 | * Returns: A pointer to a buffer to write to. | |
824 | * | |
825 | * Use: Starts sending to a peer. Only one send can happen at a | |
826 | * time. | |
827 | */ | |
828 | ||
829 | extern buf *p_txstart(peer */*p*/, unsigned /*msg*/); | |
830 | ||
831 | /* --- @p_txend@ --- * | |
832 | * | |
833 | * Arguments: @peer *p@ = pointer to peer block | |
834 | * | |
835 | * Returns: --- | |
836 | * | |
837 | * Use: Sends a packet to the peer. | |
838 | */ | |
839 | ||
840 | extern void p_txend(peer */*p*/); | |
841 | ||
0ba8de86 | 842 | /* --- @p_pingsend@ --- * |
843 | * | |
844 | * Arguments: @peer *p@ = destination peer | |
845 | * @ping *pg@ = structure to fill in | |
846 | * @unsigned type@ = message type | |
847 | * @unsigned long timeout@ = how long to wait before giving up | |
848 | * @void (*func)(int, void *)@ = callback function | |
849 | * @void *arg@ = argument for callback | |
850 | * | |
851 | * Returns: Zero if successful, nonzero if it failed. | |
852 | * | |
853 | * Use: Sends a ping to a peer. Call @func@ with a nonzero argument | |
854 | * if we get an answer within the timeout, or zero if no answer. | |
855 | */ | |
856 | ||
857 | extern int p_pingsend(peer */*p*/, ping */*pg*/, unsigned /*type*/, | |
858 | unsigned long /*timeout*/, | |
859 | void (*/*func*/)(int, void *), void */*arg*/); | |
860 | ||
861 | /* --- @p_pingdone@ --- * | |
862 | * | |
863 | * Arguments: @ping *p@ = ping structure | |
864 | * @int rc@ = return code to pass on | |
865 | * | |
866 | * Returns: --- | |
867 | * | |
868 | * Use: Disposes of a ping structure, maybe sending a notification. | |
869 | */ | |
870 | ||
871 | extern void p_pingdone(ping */*p*/, int /*rc*/); | |
872 | ||
37941236 | 873 | /* --- @p_greet@ --- * |
874 | * | |
875 | * Arguments: @peer *p@ = peer to send to | |
876 | * @const void *c@ = pointer to challenge | |
877 | * @size_t sz@ = size of challenge | |
878 | * | |
879 | * Returns: --- | |
880 | * | |
881 | * Use: Sends a greeting packet. | |
882 | */ | |
883 | ||
884 | extern void p_greet(peer */*p*/, const void */*c*/, size_t /*sz*/); | |
885 | ||
410c8acf | 886 | /* --- @p_tun@ --- * |
887 | * | |
888 | * Arguments: @peer *p@ = pointer to peer block | |
889 | * @buf *b@ = buffer containing incoming packet | |
890 | * | |
891 | * Returns: --- | |
892 | * | |
893 | * Use: Handles a packet which needs to be sent to a peer. | |
894 | */ | |
895 | ||
896 | extern void p_tun(peer */*p*/, buf */*b*/); | |
897 | ||
de014da6 | 898 | /* --- @p_keyreload@ --- * |
899 | * | |
900 | * Arguments: --- | |
901 | * | |
902 | * Returns: --- | |
903 | * | |
904 | * Use: Forces a check of the daemon's keyring files. | |
905 | */ | |
906 | ||
907 | extern void p_keyreload(void); | |
908 | ||
410c8acf | 909 | /* --- @p_interval@ --- * |
910 | * | |
911 | * Arguments: --- | |
912 | * | |
913 | * Returns: --- | |
914 | * | |
915 | * Use: Called periodically to do tidying. | |
916 | */ | |
917 | ||
918 | extern void p_interval(void); | |
919 | ||
832a2ab6 | 920 | /* --- @p_stats@ --- * |
921 | * | |
922 | * Arguments: @peer *p@ = pointer to a peer block | |
923 | * | |
924 | * Returns: A pointer to the peer's statistics. | |
925 | */ | |
926 | ||
927 | extern stats *p_stats(peer */*p*/); | |
928 | ||
410c8acf | 929 | /* --- @p_ifname@ --- * |
930 | * | |
931 | * Arguments: @peer *p@ = pointer to a peer block | |
932 | * | |
933 | * Returns: A pointer to the peer's interface name. | |
934 | */ | |
935 | ||
936 | extern const char *p_ifname(peer */*p*/); | |
937 | ||
938 | /* --- @p_addr@ --- * | |
939 | * | |
940 | * Arguments: @peer *p@ = pointer to a peer block | |
941 | * | |
942 | * Returns: A pointer to the peer's address. | |
943 | */ | |
944 | ||
945 | extern const addr *p_addr(peer */*p*/); | |
946 | ||
947 | /* --- @p_init@ --- * | |
948 | * | |
767b36e2 | 949 | * Arguments: @struct in_addr addr@ = address to bind to |
950 | * @unsigned port@ = port number to listen to | |
410c8acf | 951 | * |
952 | * Returns: --- | |
953 | * | |
954 | * Use: Initializes the peer system; creates the socket. | |
955 | */ | |
956 | ||
767b36e2 | 957 | extern void p_init(struct in_addr /*addr*/, unsigned /*port*/); |
410c8acf | 958 | |
959 | /* --- @p_port@ --- * | |
960 | * | |
961 | * Arguments: --- | |
962 | * | |
963 | * Returns: Port number used for socket. | |
964 | */ | |
965 | ||
966 | unsigned p_port(void); | |
967 | ||
968 | /* --- @p_create@ --- * | |
969 | * | |
0ba8de86 | 970 | * Arguments: @peerspec *spec@ = information about this peer |
410c8acf | 971 | * |
972 | * Returns: Pointer to the peer block, or null if it failed. | |
973 | * | |
974 | * Use: Creates a new named peer block. No peer is actually attached | |
975 | * by this point. | |
976 | */ | |
977 | ||
0ba8de86 | 978 | extern peer *p_create(peerspec */*spec*/); |
410c8acf | 979 | |
980 | /* --- @p_name@ --- * | |
981 | * | |
982 | * Arguments: @peer *p@ = pointer to a peer block | |
983 | * | |
984 | * Returns: A pointer to the peer's name. | |
060ca767 | 985 | * |
986 | * Use: Equivalent to @p_spec(p)->name@. | |
410c8acf | 987 | */ |
988 | ||
989 | extern const char *p_name(peer */*p*/); | |
990 | ||
060ca767 | 991 | /* --- @p_spec@ --- * |
992 | * | |
993 | * Arguments: @peer *p@ = pointer to a peer block | |
994 | * | |
995 | * Returns: Pointer to the peer's specification | |
996 | */ | |
997 | ||
998 | extern const peerspec *p_spec(peer */*p*/); | |
999 | ||
410c8acf | 1000 | /* --- @p_find@ --- * |
1001 | * | |
1002 | * Arguments: @const char *name@ = name to look up | |
1003 | * | |
1004 | * Returns: Pointer to the peer block, or null if not found. | |
1005 | * | |
1006 | * Use: Finds a peer by name. | |
1007 | */ | |
1008 | ||
1009 | extern peer *p_find(const char */*name*/); | |
1010 | ||
1011 | /* --- @p_destroy@ --- * | |
1012 | * | |
1013 | * Arguments: @peer *p@ = pointer to a peer | |
1014 | * | |
1015 | * Returns: --- | |
1016 | * | |
1017 | * Use: Destroys a peer. | |
1018 | */ | |
1019 | ||
1020 | extern void p_destroy(peer */*p*/); | |
1021 | ||
1022 | /* --- @p_first@, @p_next@ --- * | |
1023 | * | |
1024 | * Arguments: @peer *p@ = a peer block | |
1025 | * | |
1026 | * Returns: @peer_first@ returns the first peer in some ordering; | |
1027 | * @peer_next@ returns the peer following a given one in the | |
1028 | * same ordering. Null is returned for the end of the list. | |
1029 | */ | |
1030 | ||
1031 | extern peer *p_first(void); | |
1032 | extern peer *p_next(peer */*p*/); | |
1033 | ||
42da2a58 | 1034 | /*----- Tunnel drivers ----------------------------------------------------*/ |
410c8acf | 1035 | |
42da2a58 | 1036 | #ifdef TUN_LINUX |
1037 | extern const tunnel_ops tun_linux; | |
1038 | #endif | |
410c8acf | 1039 | |
42da2a58 | 1040 | #ifdef TUN_UNET |
1041 | extern const tunnel_ops tun_unet; | |
1042 | #endif | |
410c8acf | 1043 | |
42da2a58 | 1044 | #ifdef TUN_BSD |
1045 | extern const tunnel_ops tun_bsd; | |
1046 | #endif | |
410c8acf | 1047 | |
42da2a58 | 1048 | extern const tunnel_ops tun_slip; |
410c8acf | 1049 | |
410c8acf | 1050 | /*----- Other handy utilities ---------------------------------------------*/ |
1051 | ||
1052 | /* --- @mpstr@ --- * | |
1053 | * | |
1054 | * Arguments: @mp *m@ = a multiprecision integer | |
1055 | * | |
1056 | * Returns: A pointer to the integer's textual representation. | |
1057 | * | |
1058 | * Use: Converts a multiprecision integer to a string. Corrupts | |
832a2ab6 | 1059 | * @buf_t@. |
410c8acf | 1060 | */ |
1061 | ||
1062 | extern const char *mpstr(mp */*m*/); | |
1063 | ||
52c03a2a | 1064 | /* --- @gestr@ --- * |
1065 | * | |
1066 | * Arguments: @group *g@ = a group | |
1067 | * @ge *x@ = a group element | |
1068 | * | |
1069 | * Returns: A pointer to the element's textual representation. | |
1070 | * | |
1071 | * Use: Converts a group element to a string. Corrupts | |
1072 | * @buf_t@. | |
1073 | */ | |
1074 | ||
1075 | extern const char *gestr(group */*g*/, ge */*x*/); | |
1076 | ||
832a2ab6 | 1077 | /* --- @timestr@ --- * |
1078 | * | |
1079 | * Arguments: @time_t t@ = a time to convert | |
1080 | * | |
1081 | * Returns: A pointer to a textual representation of the time. | |
1082 | * | |
1083 | * Use: Converts a time to a textual representation. Corrupts | |
1084 | * @buf_t@. | |
1085 | */ | |
1086 | ||
1087 | extern const char *timestr(time_t /*t*/); | |
1088 | ||
42da2a58 | 1089 | /* --- @mystrieq@ --- * |
1090 | * | |
1091 | * Arguments: @const char *x, *y@ = two strings | |
1092 | * | |
1093 | * Returns: True if @x@ and @y are equal, up to case. | |
1094 | */ | |
1095 | ||
1096 | extern int mystrieq(const char */*x*/, const char */*y*/); | |
1097 | ||
37941236 | 1098 | /* --- @seq_reset@ --- * |
1099 | * | |
1100 | * Arguments: @seqwin *s@ = sequence-checking window | |
1101 | * | |
1102 | * Returns: --- | |
1103 | * | |
1104 | * Use: Resets a sequence number window. | |
1105 | */ | |
1106 | ||
1107 | extern void seq_reset(seqwin */*s*/); | |
1108 | ||
1109 | /* --- @seq_check@ --- * | |
1110 | * | |
1111 | * Arguments: @seqwin *s@ = sequence-checking window | |
1112 | * @uint32 q@ = sequence number to check | |
f43df819 | 1113 | * @const char *service@ = service to report message from |
37941236 | 1114 | * |
1115 | * Returns: A @SEQ_@ code. | |
1116 | * | |
1117 | * Use: Checks a sequence number against the window, updating things | |
1118 | * as necessary. | |
1119 | */ | |
1120 | ||
f43df819 | 1121 | extern int seq_check(seqwin */*s*/, uint32 /*q*/, const char */*service*/); |
37941236 | 1122 | |
410c8acf | 1123 | /*----- That's all, folks -------------------------------------------------*/ |
1124 | ||
1125 | #ifdef __cplusplus | |
1126 | } | |
1127 | #endif | |
1128 | ||
1129 | #endif |