1 /* ISAKMP packing and unpacking routines.
2 Copyright (C) 2002 Geoffrey Keating
3 Copyright (C) 2003-2005 Maurice Massar
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef __ISAKMP_PKT_H__
23 #define __ISAKMP_PKT_H__
24 #if defined(__linux__)
27 #include <sys/types.h>
31 struct isakmp_attribute
{
32 struct isakmp_attribute
*next
;
50 struct in_addr addr
, mask
;
51 uint16_t protocol
, sport
, dport
;
57 struct isakmp_payload
{
58 struct isakmp_payload
*next
;
59 enum isakmp_payload_enum type
;
64 struct isakmp_payload
*proposals
;
71 struct isakmp_payload
*transforms
;
76 struct isakmp_attribute
*attributes
;
81 } ke
, hash
, sig
, nonce
, vid
, natd
;
100 uint16_t data_length
;
102 struct isakmp_attribute
*attributes
; /* sometimes, data is an attributes array */
114 struct isakmp_attribute
*attributes
;
119 struct isakmp_packet
{
120 uint8_t i_cookie
[ISAKMP_COOKIE_LENGTH
];
121 uint8_t r_cookie
[ISAKMP_COOKIE_LENGTH
];
122 uint8_t isakmp_version
;
123 uint8_t exchange_type
;
126 struct isakmp_payload
*payload
;
129 extern void *xallocc(size_t x
);
130 extern struct isakmp_packet
*new_isakmp_packet(void);
131 extern struct isakmp_payload
*new_isakmp_payload(uint8_t);
132 extern struct isakmp_payload
*new_isakmp_data_payload(uint8_t type
, const void *data
,
134 extern struct isakmp_attribute
*new_isakmp_attribute(uint16_t, struct isakmp_attribute
*);
135 extern struct isakmp_attribute
*new_isakmp_attribute_16(uint16_t type
, uint16_t data
,
136 struct isakmp_attribute
*next
);
137 extern void free_isakmp_packet(struct isakmp_packet
*p
);
138 extern void flatten_isakmp_payloads(struct isakmp_payload
*p
, uint8_t ** result
, size_t * size
);
139 extern void flatten_isakmp_payload(struct isakmp_payload
*p
, uint8_t ** result
, size_t * size
);
140 extern void flatten_isakmp_packet(struct isakmp_packet
*p
,
141 uint8_t ** result
, size_t * size
, size_t blksz
);
142 extern struct isakmp_packet
*parse_isakmp_packet(const uint8_t * data
,
143 size_t data_len
, int * reject
);
144 extern void test_pack_unpack(void);