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
19 $Id: isakmp-pkt.h 377 2008-11-26 08:03:43Z Joerg Mayer $
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;
127 uint16_t extra_data_length;
131 extern void *xallocc(size_t x);
132 extern void *dup_data(const void *data, size_t x);
133 extern struct isakmp_packet *new_isakmp_packet(void);
134 extern struct isakmp_payload *new_isakmp_payload(uint8_t);
135 extern struct isakmp_payload *new_isakmp_data_payload(uint8_t type, const void *data,
137 extern struct isakmp_payload *dup_isakmp_payload(struct isakmp_payload *p);
138 //extern void free_isakmp_payload(struct isakmp_payload *p);
139 extern struct isakmp_attribute *new_isakmp_attribute(uint16_t, struct isakmp_attribute *);
140 extern struct isakmp_attribute *new_isakmp_attribute_16(uint16_t type, uint16_t data,
141 struct isakmp_attribute *next);
142 extern struct isakmp_attribute *dup_isakmp_attributes(struct isakmp_attribute *);
143 extern void free_isakmp_attributes(struct isakmp_attribute *);
144 extern void free_isakmp_packet(struct isakmp_packet *p);
145 extern void flatten_isakmp_payloads(struct isakmp_payload *p, uint8_t ** result, size_t * size);
146 extern void flatten_isakmp_payload(struct isakmp_payload *p, uint8_t ** result, size_t * size);
147 extern void flatten_isakmp_packet(struct isakmp_packet *p,
148 uint8_t ** result, size_t * size, size_t blksz);
149 extern struct isakmp_packet *parse_isakmp_packet(const uint8_t * data,
150 size_t data_len, int * reject);
151 extern void test_pack_unpack(void);