Defined on-the-wire format used on lookip socket
[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 = 2,
44 /** reply message for DUMP and LOOKUP */
45 LOOKIP_ENTRY = 3,
46 /** register for notifications about new virtual IPs */
47 LOOKIP_REGISTER_UP = 4,
48 /** register for notifications about virtual IPs released */
49 LOOKIP_REGISTER_DOWN = 5,
50 /** notify reply message for REGISTER_UP */
51 LOOKIP_NOTIFY_UP = 6,
52 /** notify reply message for REGISTER_DOWN */
53 LOOKIP_NOTIFY_DOWN = 7,
54 /** end of request batch */
55 LOOKIP_END = 8,
56 };
57
58 /**
59 * Request message sent from client.
60 *
61 * Valid request message types are DUMP, LOOKUP, REGISTER_UP/DOWN and END.
62 *
63 * The vip field is used only in LOOKUP requests, but ignored otherwise.
64 */
65 struct lookip_request_t {
66 /** request message type */
67 int type;
68 /** null terminated string representation of virtual IP */
69 char vip[40];
70 };
71
72 /**
73 * Response message sent to client.
74 *
75 * Valid response message types are ENTRY and NOTIFY_UP/DOWN.
76 */
77 struct lookip_response_t {
78 /** response message type */
79 int type;
80 /** null terminated string representation of virtual IP */
81 char vip[40];
82 /** null terminated string representation of outer IP */
83 char ip[40];
84 /** null terminated peer identity */
85 char id[128];
86 /** null connection name */
87 char name[44];
88 };
89
90 #endif /** LOOKIP_MSG_H_ @}*/