Add an interactive mode in lookip tool, demonstrate lasting connections
[strongswan.git] / src / libcharon / plugins / lookip / lookip_msg.h
1 /*
2 * Copyright (C) 2012 Martin Willi
3 * Copyright (C) 2012 revosec AG
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup lookip_msg lookip_msg
18 * @{ @ingroup lookip
19 */
20
21 #ifndef LOOKIP_MSG_H_
22 #define LOOKIP_MSG_H_
23
24 #define LOOKIP_SOCKET IPSEC_PIDDIR "/charon.lkp"
25
26 typedef struct lookip_request_t lookip_request_t;
27 typedef struct lookip_response_t lookip_response_t;
28
29 /**
30 * Message type.
31 *
32 * The client can send a batch of request messages, containing DUMP, LOOKUP or
33 * REGISTER_* messages. The server immediately starts sending responses for
34 * these messages, using ENTRY or NOTIFY_* messages.
35 * A client MUST send an END message to complete a batch. The server will
36 * send any remaining responses, but will not accept new requests and closes
37 * the connection when complete.
38 */
39 enum {
40 /** request a dump of all entries */
41 LOOKIP_DUMP = 1,
42 /** lookup a specific virtual IP */
43 LOOKIP_LOOKUP,
44 /** reply message for DUMP and LOOKUP */
45 LOOKIP_ENTRY,
46 /** reply message for LOOKUP if no such IP found */
47 LOOKIP_NOT_FOUND,
48 /** register for notifications about new virtual IPs */
49 LOOKIP_REGISTER_UP,
50 /** register for notifications about virtual IPs released */
51 LOOKIP_REGISTER_DOWN,
52 /** notify reply message for REGISTER_UP */
53 LOOKIP_NOTIFY_UP,
54 /** notify reply message for REGISTER_DOWN */
55 LOOKIP_NOTIFY_DOWN,
56 /** end of request batch */
57 LOOKIP_END,
58 };
59
60 /**
61 * Request message sent from client.
62 *
63 * Valid request message types are DUMP, LOOKUP, REGISTER_UP/DOWN and END.
64 *
65 * The vip field is used only in LOOKUP requests, but ignored otherwise.
66 */
67 struct lookip_request_t {
68 /** request message type */
69 int type;
70 /** null terminated string representation of virtual IP */
71 char vip[40];
72 };
73
74 /**
75 * Response message sent to client.
76 *
77 * Valid response message types are ENTRY, NOT_FOUND and NOTIFY_UP/DOWN.
78 *
79 * All fields are set in all messages, except in NOT_FOUND: Only vip is set.
80 */
81 struct lookip_response_t {
82 /** response message type */
83 int type;
84 /** null terminated string representation of virtual IP */
85 char vip[40];
86 /** null terminated string representation of outer IP */
87 char ip[40];
88 /** null terminated peer identity */
89 char id[128];
90 /** null connection name */
91 char name[44];
92 };
93
94 #endif /** LOOKIP_MSG_H_ @}*/