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 #if defined(__linux__)
22 #include <sys/types.h>
26 struct isakmp_attribute
{
27 struct isakmp_attribute
*next
;
46 struct isakmp_payload
*next
;
47 enum isakmp_payload_enum type
;
52 struct isakmp_payload
*proposals
;
59 struct isakmp_payload
*transforms
;
64 struct isakmp_attribute
*attributes
;
69 } ke
, hash
, sig
, nonce
, vid
;
101 struct isakmp_attribute
*attributes
;
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
*
121 new_isakmp_data_payload(uint8_t type
, const void *data
, size_t data_length
);
122 extern struct isakmp_attribute
*
123 new_isakmp_attribute(uint16_t, struct isakmp_attribute
*);
124 extern struct isakmp_attribute
*
125 new_isakmp_attribute_16 (uint16_t type
, uint16_t data
,
126 struct isakmp_attribute
*next
);
127 extern void free_isakmp_packet(struct isakmp_packet
*p
);
128 extern void flatten_isakmp_payload (struct isakmp_payload
*p
,
129 uint8_t **result
, size_t *size
);
130 extern void flatten_isakmp_packet (struct isakmp_packet
*p
,
131 uint8_t **result
, size_t *size
, size_t blksz
);
132 extern struct isakmp_packet
* parse_isakmp_packet (const uint8_t *data
,
135 extern const char * isakmp_notify_to_error (uint16_t notify
);
136 extern void test_pack_unpack(void);