2 * RFC2367 PF_KEYv2 Key management API message parser
3 * Copyright (C) 1999, 2000, 2001 Richard Guy Briggs.
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>.
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
15 * RCSID $Id: pfkey_v2_parse.c,v 1.4 2004/06/13 20:35:07 as Exp $
19 * Template from klips/net/ipsec/ipsec/ipsec_parser.c.
22 char pfkey_v2_parse_c_version
[] = "$Id: pfkey_v2_parse.c,v 1.4 2004/06/13 20:35:07 as Exp $";
25 * Some ugly stuff to allow consistent debugging code for use in the
26 * kernel and in user space
31 # include <linux/kernel.h> /* for printk */
33 #include "freeswan/ipsec_kversion.h" /* for malloc switch */
36 # include <linux/slab.h> /* kmalloc() */
37 # else /* MALLOC_SLAB */
38 # include <linux/malloc.h> /* kmalloc() */
39 # endif /* MALLOC_SLAB */
40 # include <linux/errno.h> /* error codes */
41 # include <linux/types.h> /* size_t */
42 # include <linux/interrupt.h> /* mark_bh */
44 # include <linux/netdevice.h> /* struct device, and other headers */
45 # include <linux/etherdevice.h> /* eth_type_trans */
46 # include <linux/ip.h> /* struct iphdr */
47 # if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
48 # include <linux/ipv6.h> /* struct ipv6hdr */
49 # endif /* if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
50 extern int debug_pfkey
;
54 #include "ipsec_encap.h"
56 #else /* __KERNEL__ */
58 # include <sys/types.h>
59 # include <linux/types.h>
60 # include <linux/errno.h>
62 # include <freeswan.h>
63 # include <constants.h>
64 # include <defs.h> /* for PRINTF_LIKE */
65 # include <log.h> /* for debugging and DBG_log */
70 # define DEBUGGING(level, args...) { DBG_log("pfkey_lib_debug:" args); }
72 # define DEBUGGING(level, args...) if(pfkey_lib_debug & level) { printf("pfkey_lib_debug:" args); } else { ; }
75 #endif /* __KERNEL__ */
82 extern int sysctl_ipsec_debug_verbose;
83 # define DEBUGGING(level, args...) \
85 ((debug_pfkey & level & (PF_KEY_DEBUG_PARSE_STRUCT | PF_KEY_DEBUG_PARSE_PROBLEM)) \
86 || (sysctl_ipsec_debug_verbose && (debug_pfkey & level & PF_KEY_DEBUG_PARSE_FLOW))) \
87 , "klips_debug:" args)
88 #endif /* __KERNEL__ */
89 #include "ipsec_sa.h" /* IPSEC_SAREF_NULL, IPSEC_SA_REF_TABLE_IDX_WIDTH */
92 #define SENDERR(_x) do { error = -(_x); goto errlab; } while (0)
98 } static satype_tbl[] = {
100 { IPPROTO_ESP, SADB_SATYPE_ESP, "ESP" },
101 { IPPROTO_AH, SADB_SATYPE_AH, "AH" },
102 { IPPROTO_IPIP, SADB_X_SATYPE_IPIP, "IPIP" },
103 #ifdef CONFIG_IPSEC_IPCOMP
104 { IPPROTO_COMP, SADB_X_SATYPE_COMP, "COMP" },
105 #endif /* CONFIG_IPSEC_IPCOMP */
106 { IPPROTO_INT, SADB_X_SATYPE_INT, "INT" },
107 #else /* __KERNEL__ */
108 { SA_ESP, SADB_SATYPE_ESP, "ESP" },
109 { SA_AH, SADB_SATYPE_AH, "AH" },
110 { SA_IPIP, SADB_X_SATYPE_IPIP, "IPIP" },
111 { SA_COMP, SADB_X_SATYPE_COMP, "COMP" },
112 { SA_INT, SADB_X_SATYPE_INT, "INT" },
113 #endif /* __KERNEL__ */
118 satype2proto(uint8_t satype)
122 while(satype_tbl[i].satype != satype && satype_tbl[i].satype != 0) {
125 return satype_tbl[i].proto;
129 proto2satype(uint8_t proto)
133 while(satype_tbl[i].proto != proto && satype_tbl[i].proto != 0) {
136 return satype_tbl[i].satype;
140 satype2name(uint8_t satype)
144 while(satype_tbl[i].satype != satype && satype_tbl[i].satype != 0) {
147 return satype_tbl[i].name;
151 proto2name(uint8_t proto)
155 while(satype_tbl[i].proto != proto && satype_tbl[i].proto != 0) {
158 return satype_tbl[i].name;
161 /* Default extension parsers taken from the KLIPS code */
164 pfkey_sa_parse(struct sadb_ext *pfkey_ext)
167 struct sadb_sa *pfkey_sa = (struct sadb_sa *)pfkey_ext;
172 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
173 "pfkey_sa_parse: entry\n");
174 /* sanity checks... */
176 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
178 "NULL pointer passed in.\n");
183 /* check if this structure is short, and if so, fix it up.
184 * XXX this is NOT the way to do things.
186 if(pfkey_sa->sadb_sa_len == sizeof(struct sadb_sa_v1)/IPSEC_PFKEYv2_ALIGN) {
188 /* yes, so clear out a temporary structure, and copy first */
189 memset(&sav2, 0, sizeof(sav2));
190 memcpy(&sav2, pfkey_sa, sizeof(struct sadb_sa_v1));
191 sav2.sadb_x_sa_ref=-1;
192 sav2.sadb_sa_len = sizeof(struct sadb_sa) / IPSEC_PFKEYv2_ALIGN;
199 if(pfkey_sa->sadb_sa_len != sizeof(struct sadb_sa) / IPSEC_PFKEYv2_ALIGN) {
200 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
202 "length wrong pfkey_sa->sadb_sa_len=%d sizeof(struct sadb_sa)=%d.\n",
203 pfkey_sa->sadb_sa_len,
204 (int)sizeof(struct sadb_sa));
208 if(pfkey_sa->sadb_sa_encrypt > SADB_EALG_MAX) {
209 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
211 "pfkey_sa->sadb_sa_encrypt=%d > SADB_EALG_MAX=%d.\n",
212 pfkey_sa->sadb_sa_encrypt,
217 if(pfkey_sa->sadb_sa_auth > SADB_AALG_MAX) {
218 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
220 "pfkey_sa->sadb_sa_auth=%d > SADB_AALG_MAX=%d.\n",
221 pfkey_sa->sadb_sa_auth,
226 if(pfkey_sa->sadb_sa_state > SADB_SASTATE_MAX) {
227 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
229 "state=%d exceeds MAX=%d.\n",
230 pfkey_sa->sadb_sa_state,
235 if(pfkey_sa->sadb_sa_state == SADB_SASTATE_DEAD) {
236 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
238 "state=%d is DEAD=%d.\n",
239 pfkey_sa->sadb_sa_state,
244 if(pfkey_sa->sadb_sa_replay > 64) {
245 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
247 "replay window size: %d -- must be 0 <= size <= 64\n",
248 pfkey_sa->sadb_sa_replay);
252 if(! ((pfkey_sa->sadb_sa_exttype == SADB_EXT_SA) ||
253 (pfkey_sa->sadb_sa_exttype == SADB_X_EXT_SA2)))
255 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
257 "unknown exttype=%d, expecting SADB_EXT_SA=%d or SADB_X_EXT_SA2=%d.\n",
258 pfkey_sa->sadb_sa_exttype,
264 if((IPSEC_SAREF_NULL != pfkey_sa->sadb_x_sa_ref) && (pfkey_sa->sadb_x_sa_ref >= (1 << IPSEC_SA_REF_TABLE_IDX_WIDTH))) {
265 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
267 "SAref=%d must be (SAref == IPSEC_SAREF_NULL(%d) || SAref < IPSEC_SA_REF_TABLE_NUM_ENTRIES(%d)).\n",
268 pfkey_sa->sadb_x_sa_ref,
270 IPSEC_SA_REF_TABLE_NUM_ENTRIES);
274 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
276 "successfully found len=%d exttype=%d(%s) spi=%08lx replay=%d state=%d auth=%d encrypt=%d flags=%d ref=%d.\n",
277 pfkey_sa->sadb_sa_len,
278 pfkey_sa->sadb_sa_exttype,
279 pfkey_v2_sadb_ext_string(pfkey_sa->sadb_sa_exttype),
280 (long unsigned int)ntohl(pfkey_sa->sadb_sa_spi),
281 pfkey_sa->sadb_sa_replay,
282 pfkey_sa->sadb_sa_state,
283 pfkey_sa->sadb_sa_auth,
284 pfkey_sa->sadb_sa_encrypt,
285 pfkey_sa->sadb_sa_flags,
286 pfkey_sa->sadb_x_sa_ref);
293 pfkey_lifetime_parse(struct sadb_ext *pfkey_ext)
296 struct sadb_lifetime *pfkey_lifetime = (struct sadb_lifetime *)pfkey_ext;
298 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
299 "pfkey_lifetime_parse:enter\n");
300 /* sanity checks... */
301 if(!pfkey_lifetime) {
302 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
303 "pfkey_lifetime_parse: "
304 "NULL pointer passed in.\n");
308 if(pfkey_lifetime->sadb_lifetime_len !=
309 sizeof(struct sadb_lifetime) / IPSEC_PFKEYv2_ALIGN) {
310 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
311 "pfkey_lifetime_parse: "
312 "length wrong pfkey_lifetime->sadb_lifetime_len=%d sizeof(struct sadb_lifetime)=%d.\n",
313 pfkey_lifetime->sadb_lifetime_len,
314 (int)sizeof(struct sadb_lifetime));
318 if((pfkey_lifetime->sadb_lifetime_exttype != SADB_EXT_LIFETIME_HARD) &&
319 (pfkey_lifetime->sadb_lifetime_exttype != SADB_EXT_LIFETIME_SOFT) &&
320 (pfkey_lifetime->sadb_lifetime_exttype != SADB_EXT_LIFETIME_CURRENT)) {
321 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
322 "pfkey_lifetime_parse: "
323 "unexpected ext_type=%d.\n",
324 pfkey_lifetime->sadb_lifetime_exttype);
328 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
329 "pfkey_lifetime_parse: "
330 "life_type=%d(%s) alloc=%u bytes=%u add=%u use=%u pkts=%u.\n",
331 pfkey_lifetime->sadb_lifetime_exttype,
332 pfkey_v2_sadb_ext_string(pfkey_lifetime->sadb_lifetime_exttype),
333 pfkey_lifetime->sadb_lifetime_allocations,
334 (unsigned)pfkey_lifetime->sadb_lifetime_bytes,
335 (unsigned)pfkey_lifetime->sadb_lifetime_addtime,
336 (unsigned)pfkey_lifetime->sadb_lifetime_usetime,
337 pfkey_lifetime->sadb_x_lifetime_packets);
343 pfkey_address_parse(struct sadb_ext *pfkey_ext)
347 struct sadb_address *pfkey_address = (struct sadb_address *)pfkey_ext;
348 struct sockaddr* s = (struct sockaddr*)((char*)pfkey_address + sizeof(*pfkey_address));
349 char ipaddr_txt[ADDRTOT_BUF];
351 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
352 "pfkey_address_parse:enter\n");
353 /* sanity checks... */
355 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
356 "pfkey_address_parse: "
357 "NULL pointer passed in.\n");
361 if(pfkey_address->sadb_address_len <
362 (sizeof(struct sadb_address) + sizeof(struct sockaddr))/
363 IPSEC_PFKEYv2_ALIGN) {
364 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
365 "pfkey_address_parse: "
366 "size wrong 1 ext_len=%d, adr_ext_len=%d, saddr_len=%d.\n",
367 pfkey_address->sadb_address_len,
368 (int)sizeof(struct sadb_address),
369 (int)sizeof(struct sockaddr));
373 if(pfkey_address->sadb_address_reserved) {
374 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
375 "pfkey_address_parse: "
376 "res=%d, must be zero.\n",
377 pfkey_address->sadb_address_reserved);
381 switch(pfkey_address->sadb_address_exttype) {
382 case SADB_EXT_ADDRESS_SRC:
383 case SADB_EXT_ADDRESS_DST:
384 case SADB_EXT_ADDRESS_PROXY:
385 case SADB_X_EXT_ADDRESS_DST2:
386 case SADB_X_EXT_ADDRESS_SRC_FLOW:
387 case SADB_X_EXT_ADDRESS_DST_FLOW:
388 case SADB_X_EXT_ADDRESS_SRC_MASK:
389 case SADB_X_EXT_ADDRESS_DST_MASK:
391 case SADB_X_EXT_NAT_T_OA:
395 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
396 "pfkey_address_parse: "
397 "unexpected ext_type=%d.\n",
398 pfkey_address->sadb_address_exttype);
402 switch(s->sa_family) {
404 saddr_len = sizeof(struct sockaddr_in);
405 sprintf(ipaddr_txt, "%d.%d.%d.%d"
406 , (((struct sockaddr_in*)s)->sin_addr.s_addr >> 0) & 0xFF
407 , (((struct sockaddr_in*)s)->sin_addr.s_addr >> 8) & 0xFF
408 , (((struct sockaddr_in*)s)->sin_addr.s_addr >> 16) & 0xFF
409 , (((struct sockaddr_in*)s)->sin_addr.s_addr >> 24) & 0xFF);
410 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
411 "pfkey_address_parse: "
412 "found exttype=%u(%s) family=%d(AF_INET) address=%s proto=%u port=%u.\n",
413 pfkey_address->sadb_address_exttype,
414 pfkey_v2_sadb_ext_string(pfkey_address->sadb_address_exttype),
417 pfkey_address->sadb_address_proto,
418 ntohs(((struct sockaddr_in*)s)->sin_port));
421 saddr_len = sizeof(struct sockaddr_in6);
422 sprintf(ipaddr_txt, "%x:%x:%x:%x:%x:%x:%x:%x"
423 , ntohs(((struct sockaddr_in6*)s)->sin6_addr.s6_addr16[0])
424 , ntohs(((struct sockaddr_in6*)s)->sin6_addr.s6_addr16[1])
425 , ntohs(((struct sockaddr_in6*)s)->sin6_addr.s6_addr16[2])
426 , ntohs(((struct sockaddr_in6*)s)->sin6_addr.s6_addr16[3])
427 , ntohs(((struct sockaddr_in6*)s)->sin6_addr.s6_addr16[4])
428 , ntohs(((struct sockaddr_in6*)s)->sin6_addr.s6_addr16[5])
429 , ntohs(((struct sockaddr_in6*)s)->sin6_addr.s6_addr16[6])
430 , ntohs(((struct sockaddr_in6*)s)->sin6_addr.s6_addr16[7]));
431 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
432 "pfkey_address_parse: "
433 "found exttype=%u(%s) family=%d(AF_INET6) address=%s proto=%u port=%u.\n",
434 pfkey_address->sadb_address_exttype,
435 pfkey_v2_sadb_ext_string(pfkey_address->sadb_address_exttype),
438 pfkey_address->sadb_address_proto,
439 ((struct sockaddr_in6*)s)->sin6_port);
442 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
443 "pfkey_address_parse: "
444 "s->sa_family=%d not supported.\n",
446 SENDERR(EPFNOSUPPORT);
449 if(pfkey_address->sadb_address_len !=
450 DIVUP(sizeof(struct sadb_address) + saddr_len, IPSEC_PFKEYv2_ALIGN)) {
451 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
452 "pfkey_address_parse: "
453 "size wrong 2 ext_len=%d, adr_ext_len=%d, saddr_len=%d.\n",
454 pfkey_address->sadb_address_len,
455 (int)sizeof(struct sadb_address),
460 if(pfkey_address->sadb_address_prefixlen != 0) {
461 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
462 "pfkey_address_parse: "
463 "address prefixes not supported yet.\n");
464 SENDERR(EAFNOSUPPORT); /* not supported yet */
467 /* XXX check if port!=0 */
469 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
470 "pfkey_address_parse: successful.\n");
476 pfkey_key_parse(struct sadb_ext *pfkey_ext)
479 struct sadb_key *pfkey_key = (struct sadb_key *)pfkey_ext;
481 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW,
482 "pfkey_key_parse:enter\n");
483 /* sanity checks... */
486 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
488 "NULL pointer passed in.\n");
492 if(pfkey_key->sadb_key_len < sizeof(struct sadb_key) / IPSEC_PFKEYv2_ALIGN) {
493 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
495 "size wrong ext_len=%d, key_ext_len=%d.\n",
496 pfkey_key->sadb_key_len,
497 (int)sizeof(struct sadb_key));
501 if(!pfkey_key->sadb_key_bits) {
502 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
504 "key length set to zero, must be non-zero.\n");
508 if(pfkey_key->sadb_key_len !=
509 DIVUP(sizeof(struct sadb_key) * OCTETBITS + pfkey_key->sadb_key_bits,
511 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
513 "key length=%d does not agree with extension length=%d.\n",
514 pfkey_key->sadb_key_bits,
515 pfkey_key->sadb_key_len);
519 if(pfkey_key->sadb_key_reserved) {
520 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
522 "res=%d, must be zero.\n",
523 pfkey_key->sadb_key_reserved);
527 if(! ( (pfkey_key->sadb_key_exttype == SADB_EXT_KEY_AUTH) ||
528 (pfkey_key->sadb_key_exttype == SADB_EXT_KEY_ENCRYPT))) {
529 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
531 "expecting extension type AUTH or ENCRYPT, got %d.\n",
532 pfkey_key->sadb_key_exttype);
536 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT,
538 "success, found len=%d exttype=%d(%s) bits=%d reserved=%d.\n",
539 pfkey_key->sadb_key_len,
540 pfkey_key->sadb_key_exttype,
541 pfkey_v2_sadb_ext_string(pfkey_key->sadb_key_exttype),
542 pfkey_key->sadb_key_bits,
543 pfkey_key->sadb_key_reserved);
550 pfkey_ident_parse(struct sadb_ext *pfkey_ext)
553 struct sadb_ident *pfkey_ident = (struct sadb_ident *)pfkey_ext;
555 /* sanity checks... */
556 if(pfkey_ident->sadb_ident_len < sizeof(struct sadb_ident) / IPSEC_PFKEYv2_ALIGN) {
557 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
558 "pfkey_ident_parse: "
559 "size wrong ext_len=%d, key_ext_len=%d.\n",
560 pfkey_ident->sadb_ident_len,
561 (int)sizeof(struct sadb_ident));
565 if(pfkey_ident->sadb_ident_type > SADB_IDENTTYPE_MAX) {
566 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
567 "pfkey_ident_parse: "
568 "ident_type=%d out of range, must be less than %d.\n",
569 pfkey_ident->sadb_ident_type,
574 if(pfkey_ident->sadb_ident_reserved) {
575 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
576 "pfkey_ident_parse: "
577 "res=%d, must be zero.\n",
578 pfkey_ident->sadb_ident_reserved);
582 /* string terminator/padding must be zero */
583 if(pfkey_ident->sadb_ident_len > sizeof(struct sadb_ident) / IPSEC_PFKEYv2_ALIGN) {
584 if(*((char*)pfkey_ident + pfkey_ident->sadb_ident_len * IPSEC_PFKEYv2_ALIGN - 1)) {
585 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
586 "pfkey_ident_parse: "
587 "string padding must be zero, last is 0x%02x.\n",
588 *((char*)pfkey_ident +
589 pfkey_ident->sadb_ident_len * IPSEC_PFKEYv2_ALIGN - 1));
594 if( ! ((pfkey_ident->sadb_ident_exttype == SADB_EXT_IDENTITY_SRC) ||
595 (pfkey_ident->sadb_ident_exttype == SADB_EXT_IDENTITY_DST))) {
596 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
598 "expecting extension type IDENTITY_SRC or IDENTITY_DST, got %d.\n",
599 pfkey_ident->sadb_ident_exttype);
608 pfkey_sens_parse(struct sadb_ext *pfkey_ext)
611 struct sadb_sens *pfkey_sens = (struct sadb_sens *)pfkey_ext;
613 /* sanity checks... */
614 if(pfkey_sens->sadb_sens_len < sizeof(struct sadb_sens) / IPSEC_PFKEYv2_ALIGN) {
615 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
617 "size wrong ext_len=%d, key_ext_len=%d.\n",
618 pfkey_sens->sadb_sens_len,
619 (int)sizeof(struct sadb_sens));
623 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM,
625 "Sorry, I can't parse exttype=%d yet.\n",
626 pfkey_ext->sadb_ext_type);
628 SENDERR(EINVAL); /* don't process these yet */
636 pfkey_prop_parse(struct sadb_ext
*pfkey_ext
)
640 struct sadb_prop
*pfkey_prop
= (struct sadb_prop
*)pfkey_ext
;
641 struct sadb_comb
*pfkey_comb
= (struct sadb_comb
*)((char*)pfkey_ext
+ sizeof(struct sadb_prop
));
643 /* sanity checks... */
644 if((pfkey_prop
->sadb_prop_len
< sizeof(struct sadb_prop
) / IPSEC_PFKEYv2_ALIGN
) ||
645 (((pfkey_prop
->sadb_prop_len
* IPSEC_PFKEYv2_ALIGN
) - sizeof(struct sadb_prop
)) % sizeof(struct sadb_comb
))) {
646 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
648 "size wrong ext_len=%d, prop_ext_len=%d comb_ext_len=%d.\n",
649 pfkey_prop
->sadb_prop_len
,
650 (int)sizeof(struct sadb_prop
),
651 (int)sizeof(struct sadb_comb
));
655 if(pfkey_prop
->sadb_prop_replay
> 64) {
656 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
658 "replay window size: %d -- must be 0 <= size <= 64\n",
659 pfkey_prop
->sadb_prop_replay
);
664 if(pfkey_prop
->sadb_prop_reserved
[i
]) {
665 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
667 "res[%d]=%d, must be zero.\n",
668 i
, pfkey_prop
->sadb_prop_reserved
[i
]);
673 num_comb
= ((pfkey_prop
->sadb_prop_len
* IPSEC_PFKEYv2_ALIGN
) - sizeof(struct sadb_prop
)) / sizeof(struct sadb_comb
);
675 for(i
= 0; i
< num_comb
; i
++) {
676 if(pfkey_comb
->sadb_comb_auth
> SADB_AALG_MAX
) {
677 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
679 "pfkey_comb[%d]->sadb_comb_auth=%d > SADB_AALG_MAX=%d.\n",
681 pfkey_comb
->sadb_comb_auth
,
686 if(pfkey_comb
->sadb_comb_auth
) {
687 if(!pfkey_comb
->sadb_comb_auth_minbits
) {
688 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
690 "pfkey_comb[%d]->sadb_comb_auth_minbits=0, fatal.\n",
694 if(!pfkey_comb
->sadb_comb_auth_maxbits
) {
695 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
697 "pfkey_comb[%d]->sadb_comb_auth_maxbits=0, fatal.\n",
701 if(pfkey_comb
->sadb_comb_auth_minbits
> pfkey_comb
->sadb_comb_auth_maxbits
) {
702 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
704 "pfkey_comb[%d]->sadb_comb_auth_minbits=%d > maxbits=%d, fatal.\n",
706 pfkey_comb
->sadb_comb_auth_minbits
,
707 pfkey_comb
->sadb_comb_auth_maxbits
);
711 if(pfkey_comb
->sadb_comb_auth_minbits
) {
712 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
714 "pfkey_comb[%d]->sadb_comb_auth_minbits=%d != 0, fatal.\n",
716 pfkey_comb
->sadb_comb_auth_minbits
);
719 if(pfkey_comb
->sadb_comb_auth_maxbits
) {
720 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
722 "pfkey_comb[%d]->sadb_comb_auth_maxbits=%d != 0, fatal.\n",
724 pfkey_comb
->sadb_comb_auth_maxbits
);
729 if(pfkey_comb
->sadb_comb_encrypt
> SADB_EALG_MAX
) {
730 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
732 "pfkey_comb[%d]->sadb_comb_encrypt=%d > SADB_EALG_MAX=%d.\n",
734 pfkey_comb
->sadb_comb_encrypt
,
739 if(pfkey_comb
->sadb_comb_encrypt
) {
740 if(!pfkey_comb
->sadb_comb_encrypt_minbits
) {
741 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
743 "pfkey_comb[%d]->sadb_comb_encrypt_minbits=0, fatal.\n",
747 if(!pfkey_comb
->sadb_comb_encrypt_maxbits
) {
748 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
750 "pfkey_comb[%d]->sadb_comb_encrypt_maxbits=0, fatal.\n",
754 if(pfkey_comb
->sadb_comb_encrypt_minbits
> pfkey_comb
->sadb_comb_encrypt_maxbits
) {
755 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
757 "pfkey_comb[%d]->sadb_comb_encrypt_minbits=%d > maxbits=%d, fatal.\n",
759 pfkey_comb
->sadb_comb_encrypt_minbits
,
760 pfkey_comb
->sadb_comb_encrypt_maxbits
);
764 if(pfkey_comb
->sadb_comb_encrypt_minbits
) {
765 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
767 "pfkey_comb[%d]->sadb_comb_encrypt_minbits=%d != 0, fatal.\n",
769 pfkey_comb
->sadb_comb_encrypt_minbits
);
772 if(pfkey_comb
->sadb_comb_encrypt_maxbits
) {
773 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
775 "pfkey_comb[%d]->sadb_comb_encrypt_maxbits=%d != 0, fatal.\n",
777 pfkey_comb
->sadb_comb_encrypt_maxbits
);
782 /* XXX do sanity check on flags */
784 if(pfkey_comb
->sadb_comb_hard_allocations
&& pfkey_comb
->sadb_comb_soft_allocations
> pfkey_comb
->sadb_comb_hard_allocations
) {
785 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
787 "pfkey_comb[%d]->sadb_comb_soft_allocations=%d > hard_allocations=%d, fatal.\n",
789 pfkey_comb
->sadb_comb_soft_allocations
,
790 pfkey_comb
->sadb_comb_hard_allocations
);
794 if(pfkey_comb
->sadb_comb_hard_bytes
&& pfkey_comb
->sadb_comb_soft_bytes
> pfkey_comb
->sadb_comb_hard_bytes
) {
795 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
797 "pfkey_comb[%d]->sadb_comb_soft_bytes=%Ld > hard_bytes=%Ld, fatal.\n",
799 (unsigned long long int)pfkey_comb
->sadb_comb_soft_bytes
,
800 (unsigned long long int)pfkey_comb
->sadb_comb_hard_bytes
);
804 if(pfkey_comb
->sadb_comb_hard_addtime
&& pfkey_comb
->sadb_comb_soft_addtime
> pfkey_comb
->sadb_comb_hard_addtime
) {
805 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
807 "pfkey_comb[%d]->sadb_comb_soft_addtime=%Ld > hard_addtime=%Ld, fatal.\n",
809 (unsigned long long int)pfkey_comb
->sadb_comb_soft_addtime
,
810 (unsigned long long int)pfkey_comb
->sadb_comb_hard_addtime
);
814 if(pfkey_comb
->sadb_comb_hard_usetime
&& pfkey_comb
->sadb_comb_soft_usetime
> pfkey_comb
->sadb_comb_hard_usetime
) {
815 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
817 "pfkey_comb[%d]->sadb_comb_soft_usetime=%Ld > hard_usetime=%Ld, fatal.\n",
819 (unsigned long long int)pfkey_comb
->sadb_comb_soft_usetime
,
820 (unsigned long long int)pfkey_comb
->sadb_comb_hard_usetime
);
824 if(pfkey_comb
->sadb_x_comb_hard_packets
&& pfkey_comb
->sadb_x_comb_soft_packets
> pfkey_comb
->sadb_x_comb_hard_packets
) {
825 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
827 "pfkey_comb[%d]->sadb_x_comb_soft_packets=%d > hard_packets=%d, fatal.\n",
829 pfkey_comb
->sadb_x_comb_soft_packets
,
830 pfkey_comb
->sadb_x_comb_hard_packets
);
834 if(pfkey_comb
->sadb_comb_reserved
) {
835 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
837 "comb[%d].res=%d, must be zero.\n",
839 pfkey_comb
->sadb_comb_reserved
);
850 pfkey_supported_parse(struct sadb_ext
*pfkey_ext
)
853 unsigned int i
, num_alg
;
854 struct sadb_supported
*pfkey_supported
= (struct sadb_supported
*)pfkey_ext
;
855 struct sadb_alg
*pfkey_alg
= (struct sadb_alg
*)((char*)pfkey_ext
+ sizeof(struct sadb_supported
));
857 /* sanity checks... */
858 if((pfkey_supported
->sadb_supported_len
<
859 sizeof(struct sadb_supported
) / IPSEC_PFKEYv2_ALIGN
) ||
860 (((pfkey_supported
->sadb_supported_len
* IPSEC_PFKEYv2_ALIGN
) -
861 sizeof(struct sadb_supported
)) % sizeof(struct sadb_alg
))) {
863 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
864 "pfkey_supported_parse: "
865 "size wrong ext_len=%d, supported_ext_len=%d alg_ext_len=%d.\n",
866 pfkey_supported
->sadb_supported_len
,
867 (int)sizeof(struct sadb_supported
),
868 (int)sizeof(struct sadb_alg
));
872 if(pfkey_supported
->sadb_supported_reserved
) {
873 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
874 "pfkey_supported_parse: "
875 "res=%d, must be zero.\n",
876 pfkey_supported
->sadb_supported_reserved
);
880 num_alg
= ((pfkey_supported
->sadb_supported_len
* IPSEC_PFKEYv2_ALIGN
) - sizeof(struct sadb_supported
)) / sizeof(struct sadb_alg
);
882 for(i
= 0; i
< num_alg
; i
++) {
883 /* process algo description */
884 if(pfkey_alg
->sadb_alg_reserved
) {
885 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
886 "pfkey_supported_parse: "
887 "alg[%d], id=%d, ivlen=%d, minbits=%d, maxbits=%d, res=%d, must be zero.\n",
889 pfkey_alg
->sadb_alg_id
,
890 pfkey_alg
->sadb_alg_ivlen
,
891 pfkey_alg
->sadb_alg_minbits
,
892 pfkey_alg
->sadb_alg_maxbits
,
893 pfkey_alg
->sadb_alg_reserved
);
897 /* XXX can alg_id auth/enc be determined from info given?
898 Yes, but OpenBSD's method does not iteroperate with rfc2367.
901 switch(pfkey_supported
->sadb_supported_exttype
) {
902 case SADB_EXT_SUPPORTED_AUTH
:
903 if(pfkey_alg
->sadb_alg_id
> SADB_AALG_MAX
) {
904 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
905 "pfkey_supported_parse: "
906 "alg[%d], alg_id=%d > SADB_AALG_MAX=%d, fatal.\n",
908 pfkey_alg
->sadb_alg_id
,
913 case SADB_EXT_SUPPORTED_ENCRYPT
:
914 if(pfkey_alg
->sadb_alg_id
> SADB_EALG_MAX
) {
915 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
916 "pfkey_supported_parse: "
917 "alg[%d], alg_id=%d > SADB_EALG_MAX=%d, fatal.\n",
919 pfkey_alg
->sadb_alg_id
,
925 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
926 "pfkey_supported_parse: "
927 "alg[%d], alg_id=%d > SADB_EALG_MAX=%d, fatal.\n",
929 pfkey_alg
->sadb_alg_id
,
941 pfkey_spirange_parse(struct sadb_ext
*pfkey_ext
)
944 struct sadb_spirange
*pfkey_spirange
= (struct sadb_spirange
*)pfkey_ext
;
946 /* sanity checks... */
947 if(pfkey_spirange
->sadb_spirange_len
!=
948 sizeof(struct sadb_spirange
) / IPSEC_PFKEYv2_ALIGN
) {
949 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
950 "pfkey_spirange_parse: "
951 "size wrong ext_len=%d, key_ext_len=%d.\n",
952 pfkey_spirange
->sadb_spirange_len
,
953 (int)sizeof(struct sadb_spirange
));
957 if(pfkey_spirange
->sadb_spirange_reserved
) {
958 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
959 "pfkey_spirange_parse: "
960 "reserved=%d must be set to zero.\n",
961 pfkey_spirange
->sadb_spirange_reserved
);
965 if(ntohl(pfkey_spirange
->sadb_spirange_max
) < ntohl(pfkey_spirange
->sadb_spirange_min
)) {
966 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
967 "pfkey_spirange_parse: "
968 "minspi=%08x must be < maxspi=%08x.\n",
969 ntohl(pfkey_spirange
->sadb_spirange_min
),
970 ntohl(pfkey_spirange
->sadb_spirange_max
));
974 if(ntohl(pfkey_spirange
->sadb_spirange_min
) <= 255) {
975 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
976 "pfkey_spirange_parse: "
977 "minspi=%08x must be > 255.\n",
978 ntohl(pfkey_spirange
->sadb_spirange_min
));
982 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT
,
983 "pfkey_spirange_parse: "
984 "ext_len=%u ext_type=%u(%s) min=%u max=%u res=%u.\n",
985 pfkey_spirange
->sadb_spirange_len
,
986 pfkey_spirange
->sadb_spirange_exttype
,
987 pfkey_v2_sadb_ext_string(pfkey_spirange
->sadb_spirange_exttype
),
988 pfkey_spirange
->sadb_spirange_min
,
989 pfkey_spirange
->sadb_spirange_max
,
990 pfkey_spirange
->sadb_spirange_reserved
);
996 pfkey_x_kmprivate_parse(struct sadb_ext
*pfkey_ext
)
999 struct sadb_x_kmprivate
*pfkey_x_kmprivate
= (struct sadb_x_kmprivate
*)pfkey_ext
;
1001 /* sanity checks... */
1002 if(pfkey_x_kmprivate
->sadb_x_kmprivate_len
<
1003 sizeof(struct sadb_x_kmprivate
) / IPSEC_PFKEYv2_ALIGN
) {
1004 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1005 "pfkey_x_kmprivate_parse: "
1006 "size wrong ext_len=%d, key_ext_len=%d.\n",
1007 pfkey_x_kmprivate
->sadb_x_kmprivate_len
,
1008 (int)sizeof(struct sadb_x_kmprivate
));
1012 if(pfkey_x_kmprivate
->sadb_x_kmprivate_reserved
) {
1013 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1014 "pfkey_x_kmprivate_parse: "
1015 "reserved=%d must be set to zero.\n",
1016 pfkey_x_kmprivate
->sadb_x_kmprivate_reserved
);
1020 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1021 "pfkey_x_kmprivate_parse: "
1022 "Sorry, I can't parse exttype=%d yet.\n",
1023 pfkey_ext
->sadb_ext_type
);
1024 SENDERR(EINVAL
); /* don't process these yet */
1031 pfkey_x_satype_parse(struct sadb_ext
*pfkey_ext
)
1035 struct sadb_x_satype
*pfkey_x_satype
= (struct sadb_x_satype
*)pfkey_ext
;
1037 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW
,
1038 "pfkey_x_satype_parse: enter\n");
1039 /* sanity checks... */
1040 if(pfkey_x_satype
->sadb_x_satype_len
!=
1041 sizeof(struct sadb_x_satype
) / IPSEC_PFKEYv2_ALIGN
) {
1042 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1043 "pfkey_x_satype_parse: "
1044 "size wrong ext_len=%d, key_ext_len=%d.\n",
1045 pfkey_x_satype
->sadb_x_satype_len
,
1046 (int)sizeof(struct sadb_x_satype
));
1050 if(!pfkey_x_satype
->sadb_x_satype_satype
) {
1051 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1052 "pfkey_x_satype_parse: "
1053 "satype is zero, must be non-zero.\n");
1057 if(pfkey_x_satype
->sadb_x_satype_satype
> SADB_SATYPE_MAX
) {
1058 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1059 "pfkey_x_satype_parse: "
1060 "satype %d > max %d, invalid.\n",
1061 pfkey_x_satype
->sadb_x_satype_satype
, SADB_SATYPE_MAX
);
1065 if(!(satype2proto(pfkey_x_satype
->sadb_x_satype_satype
))) {
1066 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1067 "pfkey_x_satype_parse: "
1068 "proto lookup from satype=%d failed.\n",
1069 pfkey_x_satype
->sadb_x_satype_satype
);
1073 for(i
= 0; i
< 3; i
++) {
1074 if(pfkey_x_satype
->sadb_x_satype_reserved
[i
]) {
1075 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1076 "pfkey_x_satype_parse: "
1077 "reserved[%d]=%d must be set to zero.\n",
1078 i
, pfkey_x_satype
->sadb_x_satype_reserved
[i
]);
1083 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT
,
1084 "pfkey_x_satype_parse: "
1085 "len=%u ext=%u(%s) satype=%u(%s) res=%u,%u,%u.\n",
1086 pfkey_x_satype
->sadb_x_satype_len
,
1087 pfkey_x_satype
->sadb_x_satype_exttype
,
1088 pfkey_v2_sadb_ext_string(pfkey_x_satype
->sadb_x_satype_exttype
),
1089 pfkey_x_satype
->sadb_x_satype_satype
,
1090 satype2name(pfkey_x_satype
->sadb_x_satype_satype
),
1091 pfkey_x_satype
->sadb_x_satype_reserved
[0],
1092 pfkey_x_satype
->sadb_x_satype_reserved
[1],
1093 pfkey_x_satype
->sadb_x_satype_reserved
[2]);
1099 pfkey_x_ext_debug_parse(struct sadb_ext
*pfkey_ext
)
1103 struct sadb_x_debug
*pfkey_x_debug
= (struct sadb_x_debug
*)pfkey_ext
;
1105 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW
,
1106 "pfkey_x_debug_parse: enter\n");
1107 /* sanity checks... */
1108 if(pfkey_x_debug
->sadb_x_debug_len
!=
1109 sizeof(struct sadb_x_debug
) / IPSEC_PFKEYv2_ALIGN
) {
1110 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1111 "pfkey_x_debug_parse: "
1112 "size wrong ext_len=%d, key_ext_len=%d.\n",
1113 pfkey_x_debug
->sadb_x_debug_len
,
1114 (int)sizeof(struct sadb_x_debug
));
1118 for(i
= 0; i
< 4; i
++) {
1119 if(pfkey_x_debug
->sadb_x_debug_reserved
[i
]) {
1120 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1121 "pfkey_x_debug_parse: "
1122 "reserved[%d]=%d must be set to zero.\n",
1123 i
, pfkey_x_debug
->sadb_x_debug_reserved
[i
]);
1133 pfkey_x_ext_protocol_parse(struct sadb_ext
*pfkey_ext
)
1136 struct sadb_protocol
*p
= (struct sadb_protocol
*)pfkey_ext
;
1138 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
, "pfkey_x_protocol_parse:\n");
1139 /* sanity checks... */
1141 if (p
->sadb_protocol_len
!= sizeof(*p
)/IPSEC_PFKEYv2_ALIGN
) {
1142 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1143 "pfkey_x_protocol_parse: size wrong ext_len=%d, key_ext_len=%d.\n",
1144 p
->sadb_protocol_len
, (int)sizeof(*p
));
1148 if (p
->sadb_protocol_reserved2
!= 0) {
1149 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1150 "pfkey_protocol_parse: res=%d, must be zero.\n",
1151 p
->sadb_protocol_reserved2
);
1159 #ifdef NAT_TRAVERSAL
1161 pfkey_x_ext_nat_t_type_parse(struct sadb_ext
*pfkey_ext
)
1166 pfkey_x_ext_nat_t_port_parse(struct sadb_ext
*pfkey_ext
)
1172 #define DEFINEPARSER(NAME) static struct pf_key_ext_parsers_def NAME##_def={NAME, #NAME};
1174 DEFINEPARSER(pfkey_sa_parse
);
1175 DEFINEPARSER(pfkey_lifetime_parse
);
1176 DEFINEPARSER(pfkey_address_parse
);
1177 DEFINEPARSER(pfkey_key_parse
);
1178 DEFINEPARSER(pfkey_ident_parse
);
1179 DEFINEPARSER(pfkey_sens_parse
);
1180 DEFINEPARSER(pfkey_prop_parse
);
1181 DEFINEPARSER(pfkey_supported_parse
);
1182 DEFINEPARSER(pfkey_spirange_parse
);
1183 DEFINEPARSER(pfkey_x_kmprivate_parse
);
1184 DEFINEPARSER(pfkey_x_satype_parse
);
1185 DEFINEPARSER(pfkey_x_ext_debug_parse
);
1186 DEFINEPARSER(pfkey_x_ext_protocol_parse
);
1187 #ifdef NAT_TRAVERSAL
1188 DEFINEPARSER(pfkey_x_ext_nat_t_type_parse
);
1189 DEFINEPARSER(pfkey_x_ext_nat_t_port_parse
);
1192 struct pf_key_ext_parsers_def
*ext_default_parsers
[]=
1194 NULL
, /* pfkey_msg_parse, */
1195 &pfkey_sa_parse_def
,
1196 &pfkey_lifetime_parse_def
,
1197 &pfkey_lifetime_parse_def
,
1198 &pfkey_lifetime_parse_def
,
1199 &pfkey_address_parse_def
,
1200 &pfkey_address_parse_def
,
1201 &pfkey_address_parse_def
,
1202 &pfkey_key_parse_def
,
1203 &pfkey_key_parse_def
,
1204 &pfkey_ident_parse_def
,
1205 &pfkey_ident_parse_def
,
1206 &pfkey_sens_parse_def
,
1207 &pfkey_prop_parse_def
,
1208 &pfkey_supported_parse_def
,
1209 &pfkey_supported_parse_def
,
1210 &pfkey_spirange_parse_def
,
1211 &pfkey_x_kmprivate_parse_def
,
1212 &pfkey_x_satype_parse_def
,
1213 &pfkey_sa_parse_def
,
1214 &pfkey_address_parse_def
,
1215 &pfkey_address_parse_def
,
1216 &pfkey_address_parse_def
,
1217 &pfkey_address_parse_def
,
1218 &pfkey_address_parse_def
,
1219 &pfkey_x_ext_debug_parse_def
,
1220 &pfkey_x_ext_protocol_parse_def
1221 #ifdef NAT_TRAVERSAL
1223 &pfkey_x_ext_nat_t_type_parse_def
,
1224 &pfkey_x_ext_nat_t_port_parse_def
,
1225 &pfkey_x_ext_nat_t_port_parse_def
,
1226 &pfkey_address_parse_def
1231 pfkey_msg_parse(struct sadb_msg
*pfkey_msg
,
1232 struct pf_key_ext_parsers_def
*ext_parsers
[],
1233 struct sadb_ext
*extensions
[],
1238 struct sadb_ext
*pfkey_ext
;
1239 int extensions_seen
= 0;
1241 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT
,
1243 "parsing message ver=%d, type=%d(%s), errno=%d, satype=%d(%s), len=%d, res=%d, seq=%d, pid=%d.\n",
1244 pfkey_msg
->sadb_msg_version
,
1245 pfkey_msg
->sadb_msg_type
,
1246 pfkey_v2_sadb_type_string(pfkey_msg
->sadb_msg_type
),
1247 pfkey_msg
->sadb_msg_errno
,
1248 pfkey_msg
->sadb_msg_satype
,
1249 satype2name(pfkey_msg
->sadb_msg_satype
),
1250 pfkey_msg
->sadb_msg_len
,
1251 pfkey_msg
->sadb_msg_reserved
,
1252 pfkey_msg
->sadb_msg_seq
,
1253 pfkey_msg
->sadb_msg_pid
);
1255 if(ext_parsers
== NULL
) ext_parsers
= ext_default_parsers
;
1257 pfkey_extensions_init(extensions
);
1259 remain
= pfkey_msg
->sadb_msg_len
;
1260 remain
-= sizeof(struct sadb_msg
) / IPSEC_PFKEYv2_ALIGN
;
1262 pfkey_ext
= (struct sadb_ext
*)((char*)pfkey_msg
+
1263 sizeof(struct sadb_msg
));
1265 extensions
[0] = (struct sadb_ext
*) pfkey_msg
;
1268 if(pfkey_msg
->sadb_msg_version
!= PF_KEY_V2
) {
1269 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1271 "not PF_KEY_V2 msg, found %d, should be %d.\n",
1272 pfkey_msg
->sadb_msg_version
,
1277 if(!pfkey_msg
->sadb_msg_type
) {
1278 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1280 "msg type not set, must be non-zero..\n");
1284 if(pfkey_msg
->sadb_msg_type
> SADB_MAX
) {
1285 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1287 "msg type=%d > max=%d.\n",
1288 pfkey_msg
->sadb_msg_type
,
1293 switch(pfkey_msg
->sadb_msg_type
) {
1300 case SADB_X_ADDFLOW
:
1301 if(!satype2proto(pfkey_msg
->sadb_msg_satype
)) {
1302 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1304 "satype %d conversion to proto failed for msg_type %d (%s).\n",
1305 pfkey_msg
->sadb_msg_satype
,
1306 pfkey_msg
->sadb_msg_type
,
1307 pfkey_v2_sadb_type_string(pfkey_msg
->sadb_msg_type
));
1310 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1312 "satype %d(%s) conversion to proto gives %d for msg_type %d(%s).\n",
1313 pfkey_msg
->sadb_msg_satype
,
1314 satype2name(pfkey_msg
->sadb_msg_satype
),
1315 satype2proto(pfkey_msg
->sadb_msg_satype
),
1316 pfkey_msg
->sadb_msg_type
,
1317 pfkey_v2_sadb_type_string(pfkey_msg
->sadb_msg_type
));
1322 if(!pfkey_msg
->sadb_msg_satype
) {
1323 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1325 "satype is zero, must be non-zero for msg_type %d(%s).\n",
1326 pfkey_msg
->sadb_msg_type
,
1327 pfkey_v2_sadb_type_string(pfkey_msg
->sadb_msg_type
));
1334 /* errno must not be set in downward messages */
1335 /* this is not entirely true... a response to an ACQUIRE could return an error */
1336 if((dir
== EXT_BITS_IN
) && (pfkey_msg
->sadb_msg_type
!= SADB_ACQUIRE
) && pfkey_msg
->sadb_msg_errno
) {
1337 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1339 "errno set to %d.\n",
1340 pfkey_msg
->sadb_msg_errno
);
1344 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW
,
1346 "remain=%d, ext_type=%d(%s), ext_len=%d.\n",
1348 pfkey_ext
->sadb_ext_type
,
1349 pfkey_v2_sadb_ext_string(pfkey_ext
->sadb_ext_type
),
1350 pfkey_ext
->sadb_ext_len
);
1352 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW
,
1354 "extensions permitted=%08x, required=%08x.\n",
1355 extensions_bitmaps
[dir
][EXT_BITS_PERM
][pfkey_msg
->sadb_msg_type
],
1356 extensions_bitmaps
[dir
][EXT_BITS_REQ
][pfkey_msg
->sadb_msg_type
]);
1358 extensions_seen
= 1;
1360 while( (remain
* IPSEC_PFKEYv2_ALIGN
) >= sizeof(struct sadb_ext
) ) {
1361 /* Is there enough message left to support another extension header? */
1362 if(remain
< pfkey_ext
->sadb_ext_len
) {
1363 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1365 "remain %d less than ext len %d.\n",
1366 remain
, pfkey_ext
->sadb_ext_len
);
1370 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW
,
1372 "parsing ext type=%d(%s) remain=%d.\n",
1373 pfkey_ext
->sadb_ext_type
,
1374 pfkey_v2_sadb_ext_string(pfkey_ext
->sadb_ext_type
),
1377 /* Is the extension header type valid? */
1378 if((pfkey_ext
->sadb_ext_type
> SADB_EXT_MAX
) || (!pfkey_ext
->sadb_ext_type
)) {
1379 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1381 "ext type %d(%s) invalid, SADB_EXT_MAX=%d.\n",
1382 pfkey_ext
->sadb_ext_type
,
1383 pfkey_v2_sadb_ext_string(pfkey_ext
->sadb_ext_type
),
1388 /* Have we already seen this type of extension? */
1389 if((extensions_seen
& ( 1 << pfkey_ext
->sadb_ext_type
)) != 0)
1391 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1393 "ext type %d(%s) already seen.\n",
1394 pfkey_ext
->sadb_ext_type
,
1395 pfkey_v2_sadb_ext_string(pfkey_ext
->sadb_ext_type
));
1399 /* Do I even know about this type of extension? */
1400 if(ext_parsers
[pfkey_ext
->sadb_ext_type
]==NULL
) {
1401 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1403 "ext type %d(%s) unknown, ignoring.\n",
1404 pfkey_ext
->sadb_ext_type
,
1405 pfkey_v2_sadb_ext_string(pfkey_ext
->sadb_ext_type
));
1409 /* Is this type of extension permitted for this type of message? */
1410 if(!(extensions_bitmaps
[dir
][EXT_BITS_PERM
][pfkey_msg
->sadb_msg_type
] &
1411 1<<pfkey_ext
->sadb_ext_type
)) {
1412 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1414 "ext type %d(%s) not permitted, exts_perm_in=%08x, 1<<type=%08x\n",
1415 pfkey_ext
->sadb_ext_type
,
1416 pfkey_v2_sadb_ext_string(pfkey_ext
->sadb_ext_type
),
1417 extensions_bitmaps
[dir
][EXT_BITS_PERM
][pfkey_msg
->sadb_msg_type
],
1418 1<<pfkey_ext
->sadb_ext_type
);
1422 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT
,
1424 "remain=%d ext_type=%d(%s) ext_len=%d parsing ext 0p%p with parser %s.\n",
1426 pfkey_ext
->sadb_ext_type
,
1427 pfkey_v2_sadb_ext_string(pfkey_ext
->sadb_ext_type
),
1428 pfkey_ext
->sadb_ext_len
,
1430 ext_parsers
[pfkey_ext
->sadb_ext_type
]->parser_name
);
1432 /* Parse the extension */
1434 (*ext_parsers
[pfkey_ext
->sadb_ext_type
]->parser
)(pfkey_ext
))) {
1435 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1437 "extension parsing for type %d(%s) failed with error %d.\n",
1438 pfkey_ext
->sadb_ext_type
,
1439 pfkey_v2_sadb_ext_string(pfkey_ext
->sadb_ext_type
),
1443 DEBUGGING(PF_KEY_DEBUG_PARSE_FLOW
,
1445 "Extension %d(%s) parsed.\n",
1446 pfkey_ext
->sadb_ext_type
,
1447 pfkey_v2_sadb_ext_string(pfkey_ext
->sadb_ext_type
));
1449 /* Mark that we have seen this extension and remember the header location */
1450 extensions_seen
|= ( 1 << pfkey_ext
->sadb_ext_type
);
1451 extensions
[pfkey_ext
->sadb_ext_type
] = pfkey_ext
;
1454 /* Calculate how much message remains */
1455 remain
-= pfkey_ext
->sadb_ext_len
;
1460 /* Find the next extension header */
1461 pfkey_ext
= (struct sadb_ext
*)((char*)pfkey_ext
+
1462 pfkey_ext
->sadb_ext_len
* IPSEC_PFKEYv2_ALIGN
);
1466 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1468 "unexpected remainder of %d.\n",
1470 /* why is there still something remaining? */
1474 /* check required extensions */
1475 DEBUGGING(PF_KEY_DEBUG_PARSE_STRUCT
,
1477 "extensions permitted=%08x, seen=%08x, required=%08x.\n",
1478 extensions_bitmaps
[dir
][EXT_BITS_PERM
][pfkey_msg
->sadb_msg_type
],
1480 extensions_bitmaps
[dir
][EXT_BITS_REQ
][pfkey_msg
->sadb_msg_type
]);
1482 /* don't check further if it is an error return message since it
1483 may not have a body */
1484 if(pfkey_msg
->sadb_msg_errno
) {
1488 if((extensions_seen
&
1489 extensions_bitmaps
[dir
][EXT_BITS_REQ
][pfkey_msg
->sadb_msg_type
]) !=
1490 extensions_bitmaps
[dir
][EXT_BITS_REQ
][pfkey_msg
->sadb_msg_type
]) {
1491 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1493 "required extensions missing:%08x.\n",
1494 extensions_bitmaps
[dir
][EXT_BITS_REQ
][pfkey_msg
->sadb_msg_type
] -
1496 extensions_bitmaps
[dir
][EXT_BITS_REQ
][pfkey_msg
->sadb_msg_type
]));
1500 if((dir
== EXT_BITS_IN
) && (pfkey_msg
->sadb_msg_type
== SADB_X_DELFLOW
)
1501 && ((extensions_seen
& SADB_X_EXT_ADDRESS_DELFLOW
)
1502 != SADB_X_EXT_ADDRESS_DELFLOW
)
1503 && (((extensions_seen
& (1<<SADB_EXT_SA
)) != (1<<SADB_EXT_SA
))
1504 || ((((struct sadb_sa
*)extensions
[SADB_EXT_SA
])->sadb_sa_flags
1505 & SADB_X_SAFLAGS_CLEARFLOW
)
1506 != SADB_X_SAFLAGS_CLEARFLOW
))) {
1507 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1509 "required SADB_X_DELFLOW extensions missing: either %08x must be present or %08x must be present with SADB_X_SAFLAGS_CLEARFLOW set.\n",
1510 SADB_X_EXT_ADDRESS_DELFLOW
1511 - (extensions_seen
& SADB_X_EXT_ADDRESS_DELFLOW
),
1512 (1<<SADB_EXT_SA
) - (extensions_seen
& (1<<SADB_EXT_SA
)));
1516 switch(pfkey_msg
->sadb_msg_type
) {
1519 /* check maturity */
1520 if(((struct sadb_sa
*)extensions
[SADB_EXT_SA
])->sadb_sa_state
!=
1521 SADB_SASTATE_MATURE
) {
1522 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1524 "state=%d for add or update should be MATURE=%d.\n",
1525 ((struct sadb_sa
*)extensions
[SADB_EXT_SA
])->sadb_sa_state
,
1526 SADB_SASTATE_MATURE
);
1530 /* check AH and ESP */
1531 switch(((struct sadb_msg
*)extensions
[SADB_EXT_RESERVED
])->sadb_msg_satype
) {
1532 case SADB_SATYPE_AH
:
1533 if(!(((struct sadb_sa
*)extensions
[SADB_EXT_SA
]) &&
1534 ((struct sadb_sa
*)extensions
[SADB_EXT_SA
])->sadb_sa_auth
!=
1536 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1538 "auth alg is zero, must be non-zero for AH SAs.\n");
1541 if(((struct sadb_sa
*)(extensions
[SADB_EXT_SA
]))->sadb_sa_encrypt
!=
1543 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1545 "AH handed encalg=%d, must be zero.\n",
1546 ((struct sadb_sa
*)(extensions
[SADB_EXT_SA
]))->sadb_sa_encrypt
);
1550 case SADB_SATYPE_ESP
:
1551 if(!(((struct sadb_sa
*)extensions
[SADB_EXT_SA
]) &&
1552 ((struct sadb_sa
*)extensions
[SADB_EXT_SA
])->sadb_sa_encrypt
!=
1554 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1556 "encrypt alg=%d is zero, must be non-zero for ESP=%d SAs.\n",
1557 ((struct sadb_sa
*)extensions
[SADB_EXT_SA
])->sadb_sa_encrypt
,
1558 ((struct sadb_msg
*)extensions
[SADB_EXT_RESERVED
])->sadb_msg_satype
);
1561 if((((struct sadb_sa
*)(extensions
[SADB_EXT_SA
]))->sadb_sa_encrypt
==
1563 (((struct sadb_sa
*)(extensions
[SADB_EXT_SA
]))->sadb_sa_auth
==
1565 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1567 "ESP handed encNULL+authNONE, illegal combination.\n");
1571 case SADB_X_SATYPE_COMP
:
1572 if(!(((struct sadb_sa
*)extensions
[SADB_EXT_SA
]) &&
1573 ((struct sadb_sa
*)extensions
[SADB_EXT_SA
])->sadb_sa_encrypt
!=
1575 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1577 "encrypt alg=%d is zero, must be non-zero for COMP=%d SAs.\n",
1578 ((struct sadb_sa
*)extensions
[SADB_EXT_SA
])->sadb_sa_encrypt
,
1579 ((struct sadb_msg
*)extensions
[SADB_EXT_RESERVED
])->sadb_msg_satype
);
1582 if(((struct sadb_sa
*)(extensions
[SADB_EXT_SA
]))->sadb_sa_auth
!=
1584 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1586 "COMP handed auth=%d, must be zero.\n",
1587 ((struct sadb_sa
*)(extensions
[SADB_EXT_SA
]))->sadb_sa_auth
);
1594 if(ntohl(((struct sadb_sa
*)(extensions
[SADB_EXT_SA
]))->sadb_sa_spi
) <= 255) {
1595 DEBUGGING(PF_KEY_DEBUG_PARSE_PROBLEM
,
1597 "spi=%08x must be > 255.\n",
1598 ntohl(((struct sadb_sa
*)(extensions
[SADB_EXT_SA
]))->sadb_sa_spi
));
1610 * $Log: pfkey_v2_parse.c,v $
1611 * Revision 1.4 2004/06/13 20:35:07 as
1612 * removed references to ipsec_netlink.h
1614 * Revision 1.3 2004/03/30 10:00:17 as
1617 * Revision 1.2 2004/03/22 21:53:18 as
1618 * merged alg-0.8.1 branch with HEAD
1620 * Revision 1.1.2.1 2004/03/15 22:30:06 as
1621 * nat-0.6c patch merged
1623 * Revision 1.1 2004/03/15 20:35:26 as
1624 * added files from freeswan-2.04-x509-1.5.3
1626 * Revision 1.53 2003/01/30 02:32:09 rgb
1628 * Rename SAref table macro names for clarity.
1629 * Convert IPsecSAref_t from signed to unsigned to fix apparent SAref exhaustion bug.
1631 * Revision 1.52 2002/12/30 06:53:07 mcr
1632 * deal with short SA structures... #if 0 out for now. Probably
1633 * not quite the right way.
1635 * Revision 1.51 2002/12/13 18:16:02 mcr
1636 * restored sa_ref code
1638 * Revision 1.50 2002/12/13 18:06:52 mcr
1639 * temporarily removed sadb_x_sa_ref reference for 2.xx
1641 * Revision 1.49 2002/10/05 05:02:58 dhr
1643 * C labels go on statements
1645 * Revision 1.48 2002/09/20 15:40:45 rgb
1646 * Added sadb_x_sa_ref to struct sadb_sa.
1648 * Revision 1.47 2002/09/20 05:01:31 rgb
1649 * Fixed usage of pfkey_lib_debug.
1650 * Format for function declaration style consistency.
1651 * Added text labels to elucidate numeric values presented.
1652 * Re-organised debug output to reduce noise in output.
1654 * Revision 1.46 2002/07/24 18:44:54 rgb
1655 * Type fiddling to tame ia64 compiler.
1657 * Revision 1.45 2002/05/23 07:14:11 rgb
1658 * Cleaned up %p variants to 0p%p for test suite cleanup.
1660 * Revision 1.44 2002/04/24 07:55:32 mcr
1661 * #include patches and Makefiles for post-reorg compilation.
1663 * Revision 1.43 2002/04/24 07:36:40 mcr
1664 * Moved from ./lib/pfkey_v2_parse.c,v
1666 * Revision 1.42 2002/01/29 22:25:36 rgb
1667 * Re-add ipsec_kversion.h to keep MALLOC happy.
1669 * Revision 1.41 2002/01/29 01:59:10 mcr
1670 * removal of kversions.h - sources that needed it now use ipsec_param.h.
1671 * updating of IPv6 structures to match latest in6.h version.
1672 * removed dead code from freeswan.h that also duplicated kversions.h
1675 * Revision 1.40 2002/01/20 20:34:50 mcr
1676 * added pfkey_v2_sadb_type_string to decode sadb_type to string.
1678 * Revision 1.39 2001/11/27 05:29:22 mcr
1679 * pfkey parses are now maintained by a structure
1680 * that includes their name for debug purposes.
1681 * DEBUGGING() macro changed so that it takes a debug
1682 * level so that pf_key() can use this to decode the
1683 * structures without innundanting humans.
1684 * Also uses pfkey_v2_sadb_ext_string() in messages.
1686 * Revision 1.38 2001/11/06 19:47:47 rgb
1687 * Added packet parameter to lifetime and comb structures.
1689 * Revision 1.37 2001/10/18 04:45:24 rgb
1690 * 2.4.9 kernel deprecates linux/malloc.h in favour of linux/slab.h,
1691 * lib/freeswan.h version macros moved to lib/kversions.h.
1692 * Other compiler directive cleanups.
1694 * Revision 1.36 2001/06/14 19:35:16 rgb
1695 * Update copyright date.
1697 * Revision 1.35 2001/05/03 19:44:51 rgb
1698 * Standardise on SENDERR() macro.
1700 * Revision 1.34 2001/03/16 07:41:51 rgb
1701 * Put freeswan.h include before pluto includes.
1703 * Revision 1.33 2001/02/27 07:13:51 rgb
1704 * Added satype2name() function.
1705 * Added text to default satype_tbl entry.
1706 * Added satype2name() conversions for most satype debug output.
1708 * Revision 1.32 2001/02/26 20:01:09 rgb
1709 * Added internal IP protocol 61 for magic SAs.
1710 * Ditch unused sadb_satype2proto[], replaced by satype2proto().
1711 * Re-formatted debug output (split lines, consistent spacing).
1712 * Removed acquire, register and expire requirements for a known satype.
1713 * Changed message type checking to a switch structure.
1714 * Verify expected NULL auth for IPCOMP.
1715 * Enforced spi > 0x100 requirement, now that pass uses a magic SA for
1716 * appropriate message types.
1718 * Revision 1.31 2000/12/01 07:09:00 rgb
1719 * Added ipcomp sanity check to require encalgo is set.
1721 * Revision 1.30 2000/11/17 18:10:30 rgb
1722 * Fixed bugs mostly relating to spirange, to treat all spi variables as
1723 * network byte order since this is the way PF_KEYv2 stored spis.
1725 * Revision 1.29 2000/10/12 00:02:39 rgb
1726 * Removed 'format, ##' nonsense from debug macros for RH7.0.
1728 * Revision 1.28 2000/09/20 16:23:04 rgb
1729 * Remove over-paranoid extension check in the presence of sadb_msg_errno.
1731 * Revision 1.27 2000/09/20 04:04:21 rgb
1732 * Changed static functions to DEBUG_NO_STATIC to reveal function names in
1735 * Revision 1.26 2000/09/15 11:37:02 rgb
1736 * Merge in heavily modified Svenning Soerensen's <svenning@post5.tele.dk>
1737 * IPCOMP zlib deflate code.
1739 * Revision 1.25 2000/09/12 22:35:37 rgb
1740 * Restructured to remove unused extensions from CLEARFLOW messages.
1742 * Revision 1.24 2000/09/12 18:59:54 rgb
1743 * Added Gerhard's IPv6 support to pfkey parts of libfreeswan.
1745 * Revision 1.23 2000/09/12 03:27:00 rgb
1746 * Moved DEBUGGING definition to compile kernel with debug off.
1748 * Revision 1.22 2000/09/09 06:39:27 rgb
1749 * Restrict pfkey errno check to downward messages only.
1751 * Revision 1.21 2000/09/08 19:22:34 rgb
1752 * Enabled pfkey_sens_parse().
1753 * Added check for errno on downward acquire messages only.
1755 * Revision 1.20 2000/09/01 18:48:23 rgb
1756 * Fixed reserved check bug and added debug output in
1757 * pfkey_supported_parse().
1758 * Fixed debug output label bug in pfkey_ident_parse().
1760 * Revision 1.19 2000/08/27 01:55:26 rgb
1761 * Define OCTETBITS and PFKEYBITS to avoid using 'magic' numbers in code.
1763 * Revision 1.18 2000/08/24 17:00:36 rgb
1764 * Ignore unknown extensions instead of failing.
1766 * Revision 1.17 2000/06/02 22:54:14 rgb
1767 * Added Gerhard Gessler's struct sockaddr_storage mods for IPv6 support.
1769 * Revision 1.16 2000/05/10 19:25:11 rgb
1770 * Fleshed out proposal and supported extensions.
1772 * Revision 1.15 2000/01/24 21:15:31 rgb
1773 * Added disabled pluto pfkey lib debug flag.
1774 * Added algo debugging reporting.
1776 * Revision 1.14 2000/01/22 23:24:29 rgb
1777 * Added new functions proto2satype() and satype2proto() and lookup
1778 * table satype_tbl. Also added proto2name() since it was easy.
1780 * Revision 1.13 2000/01/21 09:43:59 rgb
1781 * Cast ntohl(spi) as (unsigned long int) to shut up compiler.
1783 * Revision 1.12 2000/01/21 06:28:19 rgb
1784 * Added address cases for eroute flows.
1785 * Indented compiler directives for readability.
1786 * Added klipsdebug switching capability.
1788 * Revision 1.11 1999/12/29 21:14:59 rgb
1789 * Fixed debug text cut and paste typo.
1791 * Revision 1.10 1999/12/10 17:45:24 rgb
1792 * Added address debugging.
1794 * Revision 1.9 1999/12/09 23:11:42 rgb
1795 * Ditched <string.h> include since we no longer use memset().
1796 * Use new pfkey_extensions_init() instead of memset().
1797 * Added check for SATYPE in pfkey_msg_build().
1798 * Tidy up comments and debugging comments.
1800 * Revision 1.8 1999/12/07 19:55:26 rgb
1801 * Removed unused first argument from extension parsers.
1802 * Removed static pluto debug flag.
1803 * Moved message type and state checking to pfkey_msg_parse().
1804 * Changed print[fk] type from lx to x to quiet compiler.
1805 * Removed redundant remain check.
1806 * Changed __u* types to uint* to avoid use of asm/types.h and
1807 * sys/types.h in userspace code.
1809 * Revision 1.7 1999/12/01 22:20:51 rgb
1810 * Moved pfkey_lib_debug variable into the library.
1811 * Added pfkey version check into header parsing.
1812 * Added check for SATYPE only for those extensions that require a
1815 * Revision 1.6 1999/11/27 11:58:05 rgb
1816 * Added ipv6 headers.
1817 * Moved sadb_satype2proto protocol lookup table from
1818 * klips/net/ipsec/pfkey_v2_parser.c.
1819 * Enable lifetime_current checking.
1820 * Debugging error messages added.
1821 * Add argument to pfkey_msg_parse() for direction.
1822 * Consolidated the 4 1-d extension bitmap arrays into one 4-d array.
1823 * Add CVS log entry to bottom of file.
1824 * Moved auth and enc alg check to pfkey_msg_parse().
1825 * Enable accidentally disabled spirange parsing.
1826 * Moved protocol/algorithm checks from klips/net/ipsec/pfkey_v2_parser.c
1829 * c-file-style: "linux"