~ubuntu-branches/ubuntu/hardy/openswan/hardy-updates

« back to all changes in this revision

Viewing changes to include/constants.h

  • Committer: Bazaar Package Importer
  • Author(s): Rene Mayrhofer
  • Date: 2005-01-27 16:10:11 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050127161011-idgybmyz3vwhpfiq
Tags: 2.3.0-2
Urgency HIGH due to security issue and problems with build-deps in sarge.
* Fix the security issue. Please see
  http://www.idefense.com/application/poi/display?id=190&
      type=vulnerabilities&flashstatus=false
  for more details. Thanks to Martin Schulze for informing me about
  this issue.
  Closes: #292458: Openswan XAUTH/PAM Buffer Overflow Vulnerability
* Added a Build-Dependency to lynx.
  Closes: #291143: openswan: FTBFS: Missing build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* manifest constants
 
2
 *
 
3
 * Copyright (C) 2004       Michael Richardson <mcr@xelerance.com>
 
4
 * COpyright (C) 1997       Angelos D. Keromytis.
 
5
 * Copyright (C) 1998-2002  D. Hugh Redelmeier.
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify it
 
8
 * under the terms of the GNU General Public License as published by the
 
9
 * Free Software Foundation; either version 2 of the License, or (at your
 
10
 * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
14
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
15
 * for more details.
 
16
 *
 
17
 * RCSID $Id: constants.h,v 1.3 2004/05/29 03:06:12 mcr Exp $
 
18
 */
 
19
 
 
20
#ifndef _CONSTANTS_H_
 
21
 
 
22
/*
 
23
 * This file was split into internal contants (Openswan/pluto related),
 
24
 * and external constants (defined by IETF, etc.)
 
25
 *
 
26
 * Constants which are kernel/IPsec related are in appropriate
 
27
 * openswan / *.h files. 
 
28
 *
 
29
 */
 
30
 
 
31
/*
 
32
 * NOTE:For debugging purposes, constants.c has tables to map
 
33
 * numbers back to names.
 
34
 * Any changes here should be reflected there.
 
35
 */
 
36
 
 
37
#define elemsof(array) (sizeof(array) / sizeof(*(array)))       /* number of elements in an array */
 
38
 
 
39
/* Many routines return only success or failure, but wish to describe
 
40
 * the failure in a message.  We use the convention that they return
 
41
 * a NULL on success and a pointer to constant string on failure.
 
42
 * The fact that the string is a constant is limiting, but it
 
43
 * avoids storage management issues: the recipient is allowed to assume
 
44
 * that the string will live "long enough" (usually forever).
 
45
 * <openswan.h> defines err_t for this return type.
 
46
 */
 
47
 
 
48
typedef int bool;
 
49
#define FALSE   0
 
50
#define TRUE    1
 
51
 
 
52
#define NULL_FD (-1)    /* NULL file descriptor */
 
53
#define dup_any(fd) ((fd) == NULL_FD? NULL_FD : dup(fd))
 
54
#define close_any(fd) { if ((fd) != NULL_FD) { close(fd); (fd) = NULL_FD; } }
 
55
 
 
56
#define BITS_PER_BYTE   8
 
57
#define BYTES_FOR_BITS(b)   (((b) + BITS_PER_BYTE - 1) / BITS_PER_BYTE)
 
58
 
 
59
#define streq(a, b) (strcmp((a), (b)) == 0)     /* clearer shorthand */
 
60
#define strcaseeq(a, b) (strcasecmp((a), (b)) == 0)     /* clearer shorthand */
 
61
 
 
62
/* set type with room for at least 64 elements for ALG opts (was 32 in stock FS) */
 
63
 
 
64
typedef unsigned long long lset_t;
 
65
#define LEMPTY 0ULL
 
66
#define LELEM(opt) (1ULL << (opt))
 
67
#define LRANGE(lwb, upb) LRANGES(LELEM(lwb), LELEM(upb))
 
68
#define LRANGES(first, last) (last - first + last)
 
69
#define LHAS(set, elem)  ((LELEM(elem) & (set)) != LEMPTY)
 
70
#define LIN(subset, set)  (((subset) & (set)) == (subset))
 
71
#define LDISJOINT(a, b)  (((a) & (b)) == LEMPTY)
 
72
 
 
73
/* Routines to check and display values.
 
74
 *
 
75
 * An enum_names describes an enumeration.
 
76
 * enum_name() returns the name of an enum value, or NULL if invalid.
 
77
 * enum_show() is like enum_name, except it formats a numeric representation
 
78
 *    for any invalid value (in a static area!)
 
79
 *
 
80
 * bitnames() formats a display of a set of named bits (in a static area)
 
81
 */
 
82
 
 
83
typedef const struct enum_names enum_names;
 
84
 
 
85
extern const char *enum_name(enum_names *ed, unsigned long val);
 
86
extern const char *enum_show(enum_names *ed, unsigned long val);
 
87
extern int enum_search(enum_names *ed, const char *string);
 
88
 
 
89
extern bool testset(const char *const table[], lset_t val);
 
90
extern const char *bitnamesof(const char *const table[], lset_t val);
 
91
extern const char *bitnamesofb(const char *const table[]
 
92
                               , lset_t val
 
93
                               , char *buf, size_t blen);
 
94
 
 
95
/*
 
96
 * The sparser_name should be transformed into keyword_enum_value
 
97
 *
 
98
 * keyword_enum_value is used by starter()
 
99
 *
 
100
 */
 
101
 
 
102
#define LOOSE_ENUM_OTHER 255
 
103
 
 
104
struct keyword_enum_value {
 
105
    const unsigned char *name;
 
106
    unsigned int value;
 
107
};
 
108
 
 
109
struct keyword_enum_values {
 
110
    struct keyword_enum_value *values;
 
111
    size_t                     valuesize;
 
112
};
 
113
 
 
114
extern const char *keyword_name(struct keyword_enum_values *kevs, unsigned int value);
 
115
 
 
116
/* sparse_names is much like enum_names, except values are
 
117
 * not known to be contiguous or ordered.
 
118
 * The array of names is ended with one with the name sparse_end
 
119
 * (this avoids having to reserve a value to signify the end).
 
120
 * Often appropriate for enums defined by others.
 
121
 */
 
122
struct sparse_name {
 
123
    unsigned long val;
 
124
    const char *const name;
 
125
};
 
126
 
 
127
typedef const struct sparse_name sparse_names[];
 
128
 
 
129
extern const char *sparse_name(sparse_names sd, unsigned long val);
 
130
extern const char *sparse_val_show(sparse_names sd, unsigned long val);
 
131
extern const char sparse_end[];
 
132
 
 
133
#define FULL_INET_ADDRESS_SIZE    6
 
134
 
 
135
extern void init_constants(void);
 
136
 
 
137
#include "ietf_constants.h"
 
138
#include "pluto_constants.h"
 
139
 
 
140
#define _CONSTANTS_H_
 
141
#endif /* _CONSTANTS_H_ */
 
142
 
 
143