1 /* ISAKMP packing and unpacking routines.
2 Copyright (C) 2002 Geoffrey Keating
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef __ISAKMP_PKT_H__
20 #define __ISAKMP_PKT_H__
21 #if defined(__linux__)
24 #include <sys/types.h>
28 struct isakmp_attribute
{
29 struct isakmp_attribute
*next
;
46 struct isakmp_payload
{
47 struct isakmp_payload
*next
;
48 enum isakmp_payload_enum type
;
53 struct isakmp_payload
*proposals
;
60 struct isakmp_payload
*transforms
;
65 struct isakmp_attribute
*attributes
;
70 } ke
, hash
, sig
, nonce
, vid
, natd
;
102 struct isakmp_attribute
*attributes
;
107 struct isakmp_packet
{
108 uint8_t i_cookie
[ISAKMP_COOKIE_LENGTH
];
109 uint8_t r_cookie
[ISAKMP_COOKIE_LENGTH
];
110 uint8_t isakmp_version
;
111 uint8_t exchange_type
;
114 struct isakmp_payload
*payload
;
117 extern void *xallocc(size_t x
);
118 extern struct isakmp_packet
*new_isakmp_packet(void);
119 extern struct isakmp_payload
*new_isakmp_payload(uint8_t);
120 extern struct isakmp_payload
*new_isakmp_data_payload(uint8_t type
, const void *data
,
122 extern struct isakmp_attribute
*new_isakmp_attribute(uint16_t, struct isakmp_attribute
*);
123 extern struct isakmp_attribute
*new_isakmp_attribute_16(uint16_t type
, uint16_t data
,
124 struct isakmp_attribute
*next
);
125 extern void free_isakmp_packet(struct isakmp_packet
*p
);
126 extern void flatten_isakmp_payload(struct isakmp_payload
*p
, uint8_t ** result
, size_t * size
);
127 extern void flatten_isakmp_packet(struct isakmp_packet
*p
,
128 uint8_t ** result
, size_t * size
, size_t blksz
);
129 extern struct isakmp_packet
*parse_isakmp_packet(const uint8_t * data
,
130 size_t data_len
, int * reject
);
131 extern const char *isakmp_notify_to_error(uint16_t notify
);
132 extern void test_pack_unpack(void);