1 /* demultiplex incoming IKE messages
2 * Copyright (C) 1998-2002 D. Hugh Redelmeier.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * RCSID $Id: demux.h,v 1.21 2002/03/09 01:26:22 dhr Exp $
17 struct state; /* forward declaration of tag */
18 extern void init_demux(void);
20 #define send_packet(st,wh) _send_packet(st,wh,TRUE)
21 extern bool _send_packet(struct state *st, const char *where, bool verbose);
23 extern bool send_packet(struct state *st, const char *where);
25 extern void comm_handle(const struct iface *ifp);
27 extern u_int8_t reply_buffer[MAX_OUTPUT_UDP_SIZE];
29 /* State transition function infrastructure
31 * com_handle parses a message, decides what state object it applies to,
32 * and calls the appropriate state transition function (STF).
33 * These declarations define the interface to these functions.
35 * Each STF must be able to be restarted up to any failure point:
36 * a later message will cause the state to be re-entered. This
37 * explains the use of the replace macro and the care in handling
38 * MP_INT members of struct state.
41 struct payload_digest {
43 union payload payload;
44 struct payload_digest *next; /* of same kind */
48 * Note: raw_packet and packet_pbs are "owners" of space on heap.
52 struct msg_digest *next; /* for free list */
53 chunk_t raw_packet; /* if encrypted, received packet before decryption */
54 const struct iface *iface; /* interface on which message arrived */
55 struct sockaddr_in sin; /* where message came from */
56 ip_address sender; /* where message came from */
57 u_int16_t sender_port; /* host order */
58 pb_stream packet_pbs; /* whole packet */
59 pb_stream message_pbs; /* message to be processed */
60 struct isakmp_hdr hdr; /* message's header */
61 bool encrypted; /* was it encrypted? */
62 enum state_kind from_state; /* state we started in */
63 const struct state_microcode *smc; /* microcode for initial state */
64 struct state *st; /* current state object */
65 pb_stream reply; /* room for reply */
66 pb_stream rbody; /* room for reply body (after header) */
67 notification_t note; /* reason for failure */
69 bool dpd; /* Peer supports DPD */
75 *chain[ISAKMP_NEXT_ROOF];
77 unsigned short nat_traversal_vid;
81 extern void release_md(struct msg_digest *md);
83 /* status for state-transition-function
84 * Note: STF_FAIL + notification_t means fail with that notification
88 STF_IGNORE, /* don't respond */
89 STF_SUSPEND, /* unfinished -- don't release resources */
91 STF_INTERNAL_ERROR, /* discard everything, we failed */
92 #ifdef DODGE_DH_MISSING_ZERO_BUG
93 STF_DROP_DOOMED_EXCHANGE, /* we're responder -- don't respond */
94 STF_REPLACE_DOOMED_EXCHANGE, /* we're initiator -- reinitiate */
96 STF_FAIL /* discard everything, something failed. notification_t added. */
99 typedef stf_status state_transition_fn(struct msg_digest *md);
101 extern void complete_state_transition(struct msg_digest **mdp, stf_status result);
103 extern void free_md_pool(void);