Merge in changes between wrstuden-revivesa-base-2 and wrstuden-revivesa-base-3.diff -r1.6.2.1 -r1.6.2.2 src/common/include/prop/prop_array.h
(wrstuden)
--- src/common/include/prop/prop_array.h 2008/06/23 04:26:44 1.6.2.1
+++ src/common/include/prop/prop_array.h 2008/09/24 16:30:24 1.6.2.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: prop_array.h,v 1.6.2.1 2008/06/23 04:26:44 wrstuden Exp $ */ | 1 | /* $NetBSD: prop_array.h,v 1.6.2.2 2008/09/24 16:30:24 wrstuden Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -114,26 +114,38 @@ bool prop_array_set_int32(prop_array_t, | @@ -114,26 +114,38 @@ bool prop_array_set_int32(prop_array_t, | |||
114 | int32_t); | 114 | int32_t); | |
115 | bool prop_array_set_uint32(prop_array_t, unsigned int, | 115 | bool prop_array_set_uint32(prop_array_t, unsigned int, | |
116 | uint32_t); | 116 | uint32_t); | |
117 | 117 | |||
118 | bool prop_array_get_int64(prop_array_t, unsigned int, | 118 | bool prop_array_get_int64(prop_array_t, unsigned int, | |
119 | int64_t *); | 119 | int64_t *); | |
120 | bool prop_array_get_uint64(prop_array_t, unsigned int, | 120 | bool prop_array_get_uint64(prop_array_t, unsigned int, | |
121 | uint64_t *); | 121 | uint64_t *); | |
122 | bool prop_array_set_int64(prop_array_t, unsigned int, | 122 | bool prop_array_set_int64(prop_array_t, unsigned int, | |
123 | int64_t); | 123 | int64_t); | |
124 | bool prop_array_set_uint64(prop_array_t, unsigned int, | 124 | bool prop_array_set_uint64(prop_array_t, unsigned int, | |
125 | uint64_t); | 125 | uint64_t); | |
126 | 126 | |||
127 | bool prop_array_add_int8(prop_array_t, int8_t); | |||
128 | bool prop_array_add_uint8(prop_array_t, uint8_t); | |||
129 | ||||
130 | bool prop_array_add_int16(prop_array_t, int16_t); | |||
131 | bool prop_array_add_uint16(prop_array_t, uint16_t); | |||
132 | ||||
133 | bool prop_array_add_int32(prop_array_t, int32_t); | |||
134 | bool prop_array_add_uint32(prop_array_t, uint32_t); | |||
135 | ||||
136 | bool prop_array_add_int64(prop_array_t, int64_t); | |||
137 | bool prop_array_add_uint64(prop_array_t, uint64_t); | |||
138 | ||||
127 | bool prop_array_get_cstring(prop_array_t, unsigned int, | 139 | bool prop_array_get_cstring(prop_array_t, unsigned int, | |
128 | char **); | 140 | char **); | |
129 | bool prop_array_set_cstring(prop_array_t, unsigned int, | 141 | bool prop_array_set_cstring(prop_array_t, unsigned int, | |
130 | const char *); | 142 | const char *); | |
131 | 143 | |||
132 | bool prop_array_get_cstring_nocopy(prop_array_t, | 144 | bool prop_array_get_cstring_nocopy(prop_array_t, | |
133 | unsigned int, | 145 | unsigned int, | |
134 | const char **); | 146 | const char **); | |
135 | bool prop_array_set_cstring_nocopy(prop_array_t, | 147 | bool prop_array_set_cstring_nocopy(prop_array_t, | |
136 | unsigned int, | 148 | unsigned int, | |
137 | const char *); | 149 | const char *); | |
138 | 150 | |||
139 | __END_DECLS | 151 | __END_DECLS |
--- src/common/lib/libc/stdlib/strtoull.c 2008/09/18 04:54:18 1.1.26.1
+++ src/common/lib/libc/stdlib/strtoull.c 2008/09/24 16:30:24 1.1.26.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: strtoull.c,v 1.1.26.1 2008/09/18 04:54:18 wrstuden Exp $ */ | 1 | /* $NetBSD: strtoull.c,v 1.1.26.2 2008/09/24 16:30:24 wrstuden Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2005 The DragonFly Project. All rights reserved. | 4 | * Copyright (c) 2005 The DragonFly Project. All rights reserved. | |
5 | * Copyright (c) 2003 Citrus Project, | 5 | * Copyright (c) 2003 Citrus Project, | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -21,28 +21,32 @@ | @@ -21,28 +21,32 @@ | |||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
27 | * SUCH DAMAGE. | 27 | * SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #if HAVE_NBTOOL_CONFIG_H | 30 | #if HAVE_NBTOOL_CONFIG_H | |
31 | #include "nbtool_config.h" | 31 | #include "nbtool_config.h" | |
32 | #endif | 32 | #endif | |
33 | 33 | |||
34 | #if HAVE_NBTOOL_CONFIG_H | |||
35 | #include "nbtool_config.h" | |||
36 | #endif | |||
37 | ||||
34 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
35 | __RCSID("$NetBSD: strtoull.c,v 1.1.26.1 2008/09/18 04:54:18 wrstuden Exp $"); | 39 | __RCSID("$NetBSD: strtoull.c,v 1.1.26.2 2008/09/24 16:30:24 wrstuden Exp $"); | |
36 | 40 | |||
37 | #ifdef _LIBC | 41 | #ifdef _LIBC | |
38 | #include "namespace.h" | 42 | #include "namespace.h" | |
39 | #endif | 43 | #endif | |
40 | 44 | |||
41 | #if defined(_KERNEL) | 45 | #if defined(_KERNEL) | |
42 | #include <sys/param.h> | 46 | #include <sys/param.h> | |
43 | #include <lib/libkern/libkern.h> | 47 | #include <lib/libkern/libkern.h> | |
44 | #elif defined(_STANDALONE) | 48 | #elif defined(_STANDALONE) | |
45 | #include <sys/param.h> | 49 | #include <sys/param.h> | |
46 | #include <lib/libkern/libkern.h> | 50 | #include <lib/libkern/libkern.h> | |
47 | #include <lib/libsa/stand.h> | 51 | #include <lib/libsa/stand.h> | |
48 | #else | 52 | #else |
--- src/common/lib/libc/stdlib/strtoumax.c 2008/09/18 04:54:18 1.1.28.1
+++ src/common/lib/libc/stdlib/strtoumax.c 2008/09/24 16:30:24 1.1.28.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: strtoumax.c,v 1.1.28.1 2008/09/18 04:54:18 wrstuden Exp $ */ | 1 | /* $NetBSD: strtoumax.c,v 1.1.28.2 2008/09/24 16:30:24 wrstuden Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2005 The DragonFly Project. All rights reserved. | 4 | * Copyright (c) 2005 The DragonFly Project. All rights reserved. | |
5 | * Copyright (c) 2003 Citrus Project, | 5 | * Copyright (c) 2003 Citrus Project, | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -21,28 +21,32 @@ | @@ -21,28 +21,32 @@ | |||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
27 | * SUCH DAMAGE. | 27 | * SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #if HAVE_NBTOOL_CONFIG_H | 30 | #if HAVE_NBTOOL_CONFIG_H | |
31 | #include "nbtool_config.h" | 31 | #include "nbtool_config.h" | |
32 | #endif | 32 | #endif | |
33 | 33 | |||
34 | #if HAVE_NBTOOL_CONFIG_H | |||
35 | #include "nbtool_config.h" | |||
36 | #endif | |||
37 | ||||
34 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
35 | __RCSID("$NetBSD: strtoumax.c,v 1.1.28.1 2008/09/18 04:54:18 wrstuden Exp $"); | 39 | __RCSID("$NetBSD: strtoumax.c,v 1.1.28.2 2008/09/24 16:30:24 wrstuden Exp $"); | |
36 | 40 | |||
37 | #ifdef _LIBC | 41 | #ifdef _LIBC | |
38 | #include "namespace.h" | 42 | #include "namespace.h" | |
39 | #endif | 43 | #endif | |
40 | 44 | |||
41 | #if defined(_KERNEL) | 45 | #if defined(_KERNEL) | |
42 | #include <sys/param.h> | 46 | #include <sys/param.h> | |
43 | #include <lib/libkern/libkern.h> | 47 | #include <lib/libkern/libkern.h> | |
44 | #elif defined(_STANDALONE) | 48 | #elif defined(_STANDALONE) | |
45 | #include <sys/param.h> | 49 | #include <sys/param.h> | |
46 | #include <lib/libkern/libkern.h> | 50 | #include <lib/libkern/libkern.h> | |
47 | #include <lib/libsa/stand.h> | 51 | #include <lib/libsa/stand.h> | |
48 | #else | 52 | #else |
--- src/common/lib/libprop/prop_array_util.3 2008/06/23 05:01:56 1.2.4.2
+++ src/common/lib/libprop/prop_array_util.3 2008/09/24 16:30:24 1.2.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | .\" $NetBSD: prop_array_util.3,v 1.2.4.2 2008/06/23 05:01:56 wrstuden Exp $ | 1 | .\" $NetBSD: prop_array_util.3,v 1.2.4.3 2008/09/24 16:30:24 wrstuden Exp $ | |
2 | .\" | 2 | .\" | |
3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | 3 | .\" Copyright (c) 2006 The NetBSD Foundation, Inc. | |
4 | .\" All rights reserved. | 4 | .\" All rights reserved. | |
5 | .\" | 5 | .\" | |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | 6 | .\" This code is derived from software contributed to The NetBSD Foundation | |
7 | .\" by Jason R. Thorpe. | 7 | .\" by Jason R. Thorpe. | |
8 | .\" | 8 | .\" | |
9 | .\" Redistribution and use in source and binary forms, with or without | 9 | .\" Redistribution and use in source and binary forms, with or without | |
10 | .\" modification, are permitted provided that the following conditions | 10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | 11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | 12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | 13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
@@ -40,26 +40,34 @@ | @@ -40,26 +40,34 @@ | |||
40 | .Nm prop_array_set_uint8 , | 40 | .Nm prop_array_set_uint8 , | |
41 | .Nm prop_array_get_int16 , | 41 | .Nm prop_array_get_int16 , | |
42 | .Nm prop_array_get_uint16 , | 42 | .Nm prop_array_get_uint16 , | |
43 | .Nm prop_array_set_int16 , | 43 | .Nm prop_array_set_int16 , | |
44 | .Nm prop_array_set_uint16 , | 44 | .Nm prop_array_set_uint16 , | |
45 | .Nm prop_array_get_int32 , | 45 | .Nm prop_array_get_int32 , | |
46 | .Nm prop_array_get_uint32 , | 46 | .Nm prop_array_get_uint32 , | |
47 | .Nm prop_array_set_int32 , | 47 | .Nm prop_array_set_int32 , | |
48 | .Nm prop_array_set_uint32 , | 48 | .Nm prop_array_set_uint32 , | |
49 | .Nm prop_array_get_int64 , | 49 | .Nm prop_array_get_int64 , | |
50 | .Nm prop_array_get_uint64 , | 50 | .Nm prop_array_get_uint64 , | |
51 | .Nm prop_array_set_int64 , | 51 | .Nm prop_array_set_int64 , | |
52 | .Nm prop_array_set_uint64 , | 52 | .Nm prop_array_set_uint64 , | |
53 | .Nm prop_array_add_int8 , | |||
54 | .Nm prop_array_add_uint8 , | |||
55 | .Nm prop_array_add_int16 , | |||
56 | .Nm prop_array_add_uint16 , | |||
57 | .Nm prop_array_add_int32 , | |||
58 | .Nm prop_array_add_uint32 , | |||
59 | .Nm prop_array_add_int64 , | |||
60 | .Nm prop_array_add_uint64 , | |||
53 | .Nm prop_array_get_cstring , | 61 | .Nm prop_array_get_cstring , | |
54 | .Nm prop_array_set_cstring , | 62 | .Nm prop_array_set_cstring , | |
55 | .Nm prop_array_get_cstring_nocopy , | 63 | .Nm prop_array_get_cstring_nocopy , | |
56 | .Nm prop_array_set_cstring_nocopy | 64 | .Nm prop_array_set_cstring_nocopy | |
57 | .Sh LIBRARY | 65 | .Sh LIBRARY | |
58 | .Lb libprop | 66 | .Lb libprop | |
59 | .Sh SYNOPSIS | 67 | .Sh SYNOPSIS | |
60 | .In prop/proplib.h | 68 | .In prop/proplib.h | |
61 | .\" | 69 | .\" | |
62 | .Ft bool | 70 | .Ft bool | |
63 | .Fn prop_array_get_bool "prop_array_t dict" "unsigned int indx" \ | 71 | .Fn prop_array_get_bool "prop_array_t dict" "unsigned int indx" \ | |
64 | "bool *valp" | 72 | "bool *valp" | |
65 | .Ft bool | 73 | .Ft bool | |
@@ -109,26 +117,50 @@ | @@ -109,26 +117,50 @@ | |||
109 | .Fn prop_array_get_int64 "prop_array_t dict" "unsigned int indx" \ | 117 | .Fn prop_array_get_int64 "prop_array_t dict" "unsigned int indx" \ | |
110 | "int64_t *valp" | 118 | "int64_t *valp" | |
111 | .Ft bool | 119 | .Ft bool | |
112 | .Fn prop_array_get_uint64 "prop_array_t dict" "unsigned int indx" \ | 120 | .Fn prop_array_get_uint64 "prop_array_t dict" "unsigned int indx" \ | |
113 | "uint64_t *valp" | 121 | "uint64_t *valp" | |
114 | .Ft bool | 122 | .Ft bool | |
115 | .Fn prop_array_set_int64 "prop_array_t dict" "unsigned int indx" \ | 123 | .Fn prop_array_set_int64 "prop_array_t dict" "unsigned int indx" \ | |
116 | "int64_t val" | 124 | "int64_t val" | |
117 | .Ft bool | 125 | .Ft bool | |
118 | .Fn prop_array_set_uint64 "prop_array_t dict" "unsigned int indx" \ | 126 | .Fn prop_array_set_uint64 "prop_array_t dict" "unsigned int indx" \ | |
119 | "uint64_t val" | 127 | "uint64_t val" | |
120 | .\" | 128 | .\" | |
121 | .Ft bool | 129 | .Ft bool | |
130 | .Fn prop_array_set_int32 "prop_array_t dict" "unsigned int indx" \ | |||
131 | "int32_t val" | |||
132 | .Ft bool | |||
133 | .Fn prop_array_set_uint32 "prop_array_t dict" "unsigned int indx" \ | |||
134 | "uint32_t val" | |||
135 | .\" | |||
136 | .Ft bool | |||
137 | .Fn prop_array_add_int8 "prop_array_t dict" "int8_t val" | |||
138 | .Ft bool | |||
139 | .Fn prop_array_add_uint8 "prop_array_t dict" "uint8_t val" | |||
140 | .Ft bool | |||
141 | .Fn prop_array_add_int16 "prop_array_t dict" "int16_t val" | |||
142 | .Ft bool | |||
143 | .Fn prop_array_add_uint16 "prop_array_t dict" "uint16_t val" | |||
144 | .Ft bool | |||
145 | .Fn prop_array_add_int32 "prop_array_t dict" "int32_t val" | |||
146 | .Ft bool | |||
147 | .Fn prop_array_add_uint32 "prop_array_t dict" "uint32_t val" | |||
148 | .Ft bool | |||
149 | .Fn prop_array_add_int64 "prop_array_t dict" "int64_t val" | |||
150 | .Ft bool | |||
151 | .Fn prop_array_add_uint64 "prop_array_t dict" "uint64_t val" | |||
152 | .\" | |||
153 | .Ft bool | |||
122 | .Fn prop_array_get_cstring "prop_array_t dict" "unsigned int indx" \ | 154 | .Fn prop_array_get_cstring "prop_array_t dict" "unsigned int indx" \ | |
123 | "char **strp" | 155 | "char **strp" | |
124 | .Ft bool | 156 | .Ft bool | |
125 | .Fn prop_array_set_cstring "prop_array_t dict" "unsigned int indx" \ | 157 | .Fn prop_array_set_cstring "prop_array_t dict" "unsigned int indx" \ | |
126 | "const char *str" | 158 | "const char *str" | |
127 | .\" | 159 | .\" | |
128 | .Ft bool | 160 | .Ft bool | |
129 | .Fn prop_array_get_cstring_nocopy "prop_array_t dict" \ | 161 | .Fn prop_array_get_cstring_nocopy "prop_array_t dict" \ | |
130 | "unsigned int indx" "const char **strp" | 162 | "unsigned int indx" "const char **strp" | |
131 | .Ft bool | 163 | .Ft bool | |
132 | .Fn prop_array_set_cstring_nocopy "prop_array_t dict" \ | 164 | .Fn prop_array_set_cstring_nocopy "prop_array_t dict" \ | |
133 | "unsigned int indx" "const char *strp" | 165 | "unsigned int indx" "const char *strp" | |
134 | .Sh DESCRIPTION | 166 | .Sh DESCRIPTION |
--- src/common/lib/libprop/prop_array_util.c 2008/06/23 05:01:56 1.1.4.2
+++ src/common/lib/libprop/prop_array_util.c 2008/09/24 16:30:24 1.1.4.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: prop_array_util.c,v 1.1.4.2 2008/06/23 05:01:56 wrstuden Exp $ */ | 1 | /* $NetBSD: prop_array_util.c,v 1.1.4.3 2008/09/24 16:30:24 wrstuden Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2006 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -149,26 +149,58 @@ prop_array_set_uint ## size (prop_array_ | @@ -149,26 +149,58 @@ prop_array_set_uint ## size (prop_array_ | |||
149 | unsigned int indx, \ | 149 | unsigned int indx, \ | |
150 | uint ## size ## _t val) \ | 150 | uint ## size ## _t val) \ | |
151 | { \ | 151 | { \ | |
152 | prop_number_t num; \ | 152 | prop_number_t num; \ | |
153 | int rv; \ | 153 | int rv; \ | |
154 | \ | 154 | \ | |
155 | num = prop_number_create_unsigned_integer((uint64_t) val); \ | 155 | num = prop_number_create_unsigned_integer((uint64_t) val); \ | |
156 | if (num == NULL) \ | 156 | if (num == NULL) \ | |
157 | return (false); \ | 157 | return (false); \ | |
158 | rv = prop_array_set(array, indx, num); \ | 158 | rv = prop_array_set(array, indx, num); \ | |
159 | prop_object_release(num); \ | 159 | prop_object_release(num); \ | |
160 | \ | 160 | \ | |
161 | return (rv); \ | 161 | return (rv); \ | |
162 | } \ | |||
163 | \ | |||
164 | bool \ | |||
165 | prop_array_add_int ## size (prop_array_t array, \ | |||
166 | int ## size ## _t val) \ | |||
167 | { \ | |||
168 | prop_number_t num; \ | |||
169 | int rv; \ | |||
170 | \ | |||
171 | num = prop_number_create_integer((int64_t) val); \ | |||
172 | if (num == NULL) \ | |||
173 | return (false); \ | |||
174 | rv = prop_array_add(array, num); \ | |||
175 | prop_object_release(num); \ | |||
176 | \ | |||
177 | return (rv); \ | |||
178 | } \ | |||
179 | \ | |||
180 | bool \ | |||
181 | prop_array_add_uint ## size (prop_array_t array, \ | |||
182 | uint ## size ## _t val) \ | |||
183 | { \ | |||
184 | prop_number_t num; \ | |||
185 | int rv; \ | |||
186 | \ | |||
187 | num = prop_number_create_integer((int64_t) val); \ | |||
188 | if (num == NULL) \ | |||
189 | return (false); \ | |||
190 | rv = prop_array_add(array, num); \ | |||
191 | prop_object_release(num); \ | |||
192 | \ | |||
193 | return (rv); \ | |||
162 | } | 194 | } | |
163 | 195 | |||
164 | TEMPLATE(8) | 196 | TEMPLATE(8) | |
165 | TEMPLATE(16) | 197 | TEMPLATE(16) | |
166 | TEMPLATE(32) | 198 | TEMPLATE(32) | |
167 | TEMPLATE(64) | 199 | TEMPLATE(64) | |
168 | 200 | |||
169 | #undef TEMPLATE | 201 | #undef TEMPLATE | |
170 | 202 | |||
171 | #define TEMPLATE(variant, qualifier) \ | 203 | #define TEMPLATE(variant, qualifier) \ | |
172 | bool \ | 204 | bool \ | |
173 | prop_array_get_cstring ## variant (prop_array_t array, \ | 205 | prop_array_get_cstring ## variant (prop_array_t array, \ | |
174 | unsigned int indx, \ | 206 | unsigned int indx, \ |
--- src/crypto/dist/ipsec-tools/Attic/ChangeLog 2008/09/18 04:54:19 1.153.2.2
+++ src/crypto/dist/ipsec-tools/Attic/ChangeLog 2008/09/24 16:30:24 1.153.2.3
@@ -1,13 +1,21 @@ | @@ -1,13 +1,21 @@ | |||
1 | 2008-09-17 Yvan Vanhullebus <vanhu@netasq.com> | |||
2 | * src/racoon/isakmp_inf.c: Fixed port match in purge_ipsec_spi() | |||
3 | when NAT-T enabled and trying to purge non NAT-T SAs. | |||
4 | ||||
5 | 2008-09-09 Yvan Vanhullebus <vanhu@netasq.com> | |||
6 | * src/racoon/pfkey.c: Some calls to set_port() were not correctly | |||
7 | updated in the previous commit. | |||
8 | ||||
1 | 2008-09-03 Yvan Vanhullebus <vanhu@netasq.com> | 9 | 2008-09-03 Yvan Vanhullebus <vanhu@netasq.com> | |
2 | From Tomas Mraz <tmraz@redhat.com>: | 10 | From Tomas Mraz <tmraz@redhat.com>: | |
3 | * src/racoon/pfkey.c: Duplicate addresses in pk_sendxxx functions, as | 11 | * src/racoon/pfkey.c: Duplicate addresses in pk_sendxxx functions, as | |
4 | they may be altered for NAT-T stuff. | 12 | they may be altered for NAT-T stuff. | |
5 | 13 | |||
6 | 2008-09-03 Timo Teras <timo.teras@iki.fi> | 14 | 2008-09-03 Timo Teras <timo.teras@iki.fi> | |
7 | * src/libipsec/pfkey.c: no satype check for Linux spdflush messages | 15 | * src/libipsec/pfkey.c: no satype check for Linux spdflush messages | |
8 | * src/racoon/pfkey.c: handle SPD dump responses in pfkey_reload() | 16 | * src/racoon/pfkey.c: handle SPD dump responses in pfkey_reload() | |
9 | to make configuration reloading work better | 17 | to make configuration reloading work better | |
10 | * src/racoon/sockmisc.c: it is not an error to call extract_port() | 18 | * src/racoon/sockmisc.c: it is not an error to call extract_port() | |
11 | with AF_UNSPEC address (happens with anonymous config blocks) | 19 | with AF_UNSPEC address (happens with anonymous config blocks) | |
12 | 20 | |||
13 | 2008-08-12 Yvan Vanhullebus <vanhu@netasq.com> | 21 | 2008-08-12 Yvan Vanhullebus <vanhu@netasq.com> |
--- src/crypto/dist/ipsec-tools/src/racoon/isakmp_inf.c 2008/09/18 04:54:19 1.27.2.2
+++ src/crypto/dist/ipsec-tools/src/racoon/isakmp_inf.c 2008/09/24 16:30:24 1.27.2.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: isakmp_inf.c,v 1.27.2.2 2008/09/18 04:54:19 wrstuden Exp $ */ | 1 | /* $NetBSD: isakmp_inf.c,v 1.27.2.3 2008/09/24 16:30:24 wrstuden Exp $ */ | |
2 | 2 | |||
3 | /* Id: isakmp_inf.c,v 1.44 2006/05/06 20:45:52 manubsd Exp */ | 3 | /* Id: isakmp_inf.c,v 1.44 2006/05/06 20:45:52 manubsd Exp */ | |
4 | 4 | |||
5 | /* | 5 | /* | |
6 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 6 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
7 | * All rights reserved. | 7 | * All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -1199,40 +1199,54 @@ purge_ipsec_spi(dst0, proto, spi, n) | @@ -1199,40 +1199,54 @@ purge_ipsec_spi(dst0, proto, spi, n) | |||
1199 | } | 1199 | } | |
1200 | #ifdef ENABLE_NATT | 1200 | #ifdef ENABLE_NATT | |
1201 | natt_type = (void *)mhp[SADB_X_EXT_NAT_T_TYPE]; | 1201 | natt_type = (void *)mhp[SADB_X_EXT_NAT_T_TYPE]; | |
1202 | if (natt_type && natt_type->sadb_x_nat_t_type_type) { | 1202 | if (natt_type && natt_type->sadb_x_nat_t_type_type) { | |
1203 | /* NAT-T is enabled for this SADB entry; copy | 1203 | /* NAT-T is enabled for this SADB entry; copy | |
1204 | * the ports from NAT-T extensions */ | 1204 | * the ports from NAT-T extensions */ | |
1205 | natt_port = (void *)mhp[SADB_X_EXT_NAT_T_SPORT]; | 1205 | natt_port = (void *)mhp[SADB_X_EXT_NAT_T_SPORT]; | |
1206 | if (extract_port(src) == 0 && natt_port != NULL) | 1206 | if (extract_port(src) == 0 && natt_port != NULL) | |
1207 | set_port(src, ntohs(natt_port->sadb_x_nat_t_port_port)); | 1207 | set_port(src, ntohs(natt_port->sadb_x_nat_t_port_port)); | |
1208 | 1208 | |||
1209 | natt_port = (void *)mhp[SADB_X_EXT_NAT_T_DPORT]; | 1209 | natt_port = (void *)mhp[SADB_X_EXT_NAT_T_DPORT]; | |
1210 | if (extract_port(dst) == 0 && natt_port != NULL) | 1210 | if (extract_port(dst) == 0 && natt_port != NULL) | |
1211 | set_port(dst, ntohs(natt_port->sadb_x_nat_t_port_port)); | 1211 | set_port(dst, ntohs(natt_port->sadb_x_nat_t_port_port)); | |
1212 | }else{ | |||
1213 | /* Force default UDP ports, so CMPSADDR will match SAs with NO encapsulation | |||
1214 | */ | |||
1215 | set_port(src, PORT_ISAKMP); | |||
1216 | set_port(dst, PORT_ISAKMP); | |||
1212 | } | 1217 | } | |
1213 | #endif | 1218 | #endif | |
1214 | plog(LLV_DEBUG2, LOCATION, NULL, "src: %s\n", saddr2str(src)); | 1219 | plog(LLV_DEBUG2, LOCATION, NULL, "src: %s\n", saddr2str(src)); | |
1215 | plog(LLV_DEBUG2, LOCATION, NULL, "dst: %s\n", saddr2str(dst)); | 1220 | plog(LLV_DEBUG2, LOCATION, NULL, "dst: %s\n", saddr2str(dst)); | |
1216 | 1221 | |||
1217 | /* XXX n^2 algorithm, inefficient */ | 1222 | /* XXX n^2 algorithm, inefficient */ | |
1218 | 1223 | |||
1219 | /* don't delete inbound SAs at the moment */ | 1224 | /* don't delete inbound SAs at the moment */ | |
1220 | /* XXX should we remove SAs with opposite direction as well? */ | 1225 | /* XXX should we remove SAs with opposite direction as well? */ | |
1221 | if (CMPSADDR(dst0, dst)) { | 1226 | if (CMPSADDR(dst0, dst)) { | |
1222 | msg = next; | 1227 | msg = next; | |
1223 | continue; | 1228 | continue; | |
1224 | } | 1229 | } | |
1225 | 1230 | |||
1231 | #ifdef ENABLE_NATT | |||
1232 | if (natt_type == NULL || | |||
1233 | ! natt_type->sadb_x_nat_t_type_type) { | |||
1234 | /* Set back port to 0 if it was forced to default UDP port | |||
1235 | */ | |||
1236 | set_port(src, 0); | |||
1237 | set_port(dst, 0); | |||
1238 | } | |||
1239 | #endif | |||
1226 | for (i = 0; i < n; i++) { | 1240 | for (i = 0; i < n; i++) { | |
1227 | plog(LLV_DEBUG, LOCATION, NULL, | 1241 | plog(LLV_DEBUG, LOCATION, NULL, | |
1228 | "check spi(packet)=%u spi(db)=%u.\n", | 1242 | "check spi(packet)=%u spi(db)=%u.\n", | |
1229 | ntohl(spi[i]), ntohl(sa->sadb_sa_spi)); | 1243 | ntohl(spi[i]), ntohl(sa->sadb_sa_spi)); | |
1230 | if (spi[i] != sa->sadb_sa_spi) | 1244 | if (spi[i] != sa->sadb_sa_spi) | |
1231 | continue; | 1245 | continue; | |
1232 | 1246 | |||
1233 | pfkey_send_delete(lcconf->sock_pfkey, | 1247 | pfkey_send_delete(lcconf->sock_pfkey, | |
1234 | msg->sadb_msg_satype, | 1248 | msg->sadb_msg_satype, | |
1235 | IPSEC_MODE_ANY, | 1249 | IPSEC_MODE_ANY, | |
1236 | src, dst, sa->sadb_sa_spi); | 1250 | src, dst, sa->sadb_sa_spi); | |
1237 | 1251 | |||
1238 | /* | 1252 | /* |
--- src/crypto/dist/ipsec-tools/src/racoon/pfkey.c 2008/09/18 04:54:19 1.27.4.2
+++ src/crypto/dist/ipsec-tools/src/racoon/pfkey.c 2008/09/24 16:30:24 1.27.4.3
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | /* $NetBSD: pfkey.c,v 1.27.4.2 2008/09/18 04:54:19 wrstuden Exp $ */ | 1 | /* $NetBSD: pfkey.c,v 1.27.4.3 2008/09/24 16:30:24 wrstuden Exp $ */ | |
2 | 2 | |||
3 | /* $Id: pfkey.c,v 1.27.4.2 2008/09/18 04:54:19 wrstuden Exp $ */ | 3 | /* $Id: pfkey.c,v 1.27.4.3 2008/09/24 16:30:24 wrstuden Exp $ */ | |
4 | 4 | |||
5 | /* | 5 | /* | |
6 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 6 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | |
7 | * All rights reserved. | 7 | * All rights reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
16 | * documentation and/or other materials provided with the distribution. | 16 | * documentation and/or other materials provided with the distribution. | |
@@ -910,28 +910,28 @@ pk_sendgetspi(iph2) | @@ -910,28 +910,28 @@ pk_sendgetspi(iph2) | |||
910 | } | 910 | } | |
911 | mode = ipsecdoi2pfkey_mode(pr->encmode); | 911 | mode = ipsecdoi2pfkey_mode(pr->encmode); | |
912 | if (mode == ~0) { | 912 | if (mode == ~0) { | |
913 | plog(LLV_ERROR, LOCATION, NULL, | 913 | plog(LLV_ERROR, LOCATION, NULL, | |
914 | "invalid encmode %d\n", pr->encmode); | 914 | "invalid encmode %d\n", pr->encmode); | |
915 | racoon_free(src); | 915 | racoon_free(src); | |
916 | racoon_free(dst); | 916 | racoon_free(dst); | |
917 | return -1; | 917 | return -1; | |
918 | } | 918 | } | |
919 | 919 | |||
920 | #ifdef ENABLE_NATT | 920 | #ifdef ENABLE_NATT | |
921 | if (! pr->udp_encap) { | 921 | if (! pr->udp_encap) { | |
922 | /* Remove port information, that SA doesn't use it */ | 922 | /* Remove port information, that SA doesn't use it */ | |
923 | set_port(src, 0); | 923 | set_port(iph2->src, 0); | |
924 | set_port(dst, 0); | 924 | set_port(iph2->dst, 0); | |
925 | } | 925 | } | |
926 | #endif | 926 | #endif | |
927 | plog(LLV_DEBUG, LOCATION, NULL, "call pfkey_send_getspi\n"); | 927 | plog(LLV_DEBUG, LOCATION, NULL, "call pfkey_send_getspi\n"); | |
928 | if (pfkey_send_getspi( | 928 | if (pfkey_send_getspi( | |
929 | lcconf->sock_pfkey, | 929 | lcconf->sock_pfkey, | |
930 | satype, | 930 | satype, | |
931 | mode, | 931 | mode, | |
932 | dst, /* src of SA */ | 932 | dst, /* src of SA */ | |
933 | src, /* dst of SA */ | 933 | src, /* dst of SA */ | |
934 | minspi, maxspi, | 934 | minspi, maxspi, | |
935 | pr->reqid_in, iph2->seq) < 0) { | 935 | pr->reqid_in, iph2->seq) < 0) { | |
936 | plog(LLV_ERROR, LOCATION, NULL, | 936 | plog(LLV_ERROR, LOCATION, NULL, | |
937 | "ipseclib failed send getspi (%s)\n", | 937 | "ipseclib failed send getspi (%s)\n", |
--- src/crypto/dist/ssh/Attic/misc.c 2008/04/06 23:38:19 1.21
+++ src/crypto/dist/ssh/Attic/misc.c 2008/09/24 16:30:24 1.21.4.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: misc.c,v 1.21 2008/04/06 23:38:19 christos Exp $ */ | 1 | /* $NetBSD: misc.c,v 1.21.4.1 2008/09/24 16:30:24 wrstuden Exp $ */ | |
2 | /* $OpenBSD: misc.c,v 1.67 2008/01/01 08:47:04 dtucker Exp $ */ | 2 | /* $OpenBSD: misc.c,v 1.67 2008/01/01 08:47:04 dtucker Exp $ */ | |
3 | /* | 3 | /* | |
4 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 4 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | |
5 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. | 5 | * Copyright (c) 2005,2006 Damien Miller. All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -16,33 +16,34 @@ | @@ -16,33 +16,34 @@ | |||
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | 27 | |||
28 | #include "includes.h" | 28 | #include "includes.h" | |
29 | __RCSID("$NetBSD: misc.c,v 1.21 2008/04/06 23:38:19 christos Exp $"); | 29 | __RCSID("$NetBSD: misc.c,v 1.21.4.1 2008/09/24 16:30:24 wrstuden Exp $"); | |
30 | #include <sys/types.h> | 30 | #include <sys/types.h> | |
31 | #include <sys/ioctl.h> | 31 | #include <sys/ioctl.h> | |
32 | #include <sys/socket.h> | 32 | #include <sys/socket.h> | |
33 | #include <sys/param.h> | 33 | #include <sys/param.h> | |
34 | 34 | |||
35 | #include <net/if.h> | 35 | #include <net/if.h> | |
36 | #include <net/if_tun.h> | |||
36 | #include <netinet/in.h> | 37 | #include <netinet/in.h> | |
37 | #include <netinet/tcp.h> | 38 | #include <netinet/tcp.h> | |
38 | 39 | |||
39 | #include <errno.h> | 40 | #include <errno.h> | |
40 | #include <fcntl.h> | 41 | #include <fcntl.h> | |
41 | #include <netdb.h> | 42 | #include <netdb.h> | |
42 | #include <paths.h> | 43 | #include <paths.h> | |
43 | #include <pwd.h> | 44 | #include <pwd.h> | |
44 | #include <stdarg.h> | 45 | #include <stdarg.h> | |
45 | #include <stdio.h> | 46 | #include <stdio.h> | |
46 | #include <stdlib.h> | 47 | #include <stdlib.h> | |
47 | #include <string.h> | 48 | #include <string.h> | |
48 | #include <unistd.h> | 49 | #include <unistd.h> | |
@@ -630,82 +631,96 @@ read_keyfile_line(FILE *f, const char *f | @@ -630,82 +631,96 @@ read_keyfile_line(FILE *f, const char *f | |||
630 | filename, *lineno); | 631 | filename, *lineno); | |
631 | /* discard remainder of line */ | 632 | /* discard remainder of line */ | |
632 | while (fgetc(f) != '\n' && !feof(f)) | 633 | while (fgetc(f) != '\n' && !feof(f)) | |
633 | ; /* nothing */ | 634 | ; /* nothing */ | |
634 | } | 635 | } | |
635 | } | 636 | } | |
636 | return -1; | 637 | return -1; | |
637 | } | 638 | } | |
638 | 639 | |||
639 | int | 640 | int | |
640 | tun_open(int tun, int mode) | 641 | tun_open(int tun, int mode) | |
641 | { | 642 | { | |
642 | struct ifreq ifr; | 643 | struct ifreq ifr; | |
643 | char name[100]; | 644 | int fd = -1, sock, flag; | |
644 | int fd = -1, sock; | 645 | const char *tunbase = mode == SSH_TUNMODE_ETHERNET ? "tap" : "tun"; | |
645 | 646 | |||
646 | /* Open the tunnel device */ | 647 | /* Open the tunnel device */ | |
647 | if (tun <= SSH_TUNID_MAX) { | 648 | if (tun <= SSH_TUNID_MAX) { | |
648 | snprintf(name, sizeof(name), "/dev/tun%d", tun); | 649 | snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), | |
649 | fd = open(name, O_RDWR); | 650 | "/dev/%s%d", tunbase, tun); | |
651 | fd = open(ifr.ifr_name, O_RDWR); | |||
650 | } else if (tun == SSH_TUNID_ANY) { | 652 | } else if (tun == SSH_TUNID_ANY) { | |
651 | for (tun = 100; tun >= 0; tun--) { | 653 | for (tun = 100; tun >= 0; tun--) { | |
652 | snprintf(name, sizeof(name), "/dev/tun%d", tun); | 654 | snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), | |
653 | if ((fd = open(name, O_RDWR)) >= 0) | 655 | "/dev/%s%d", tunbase, tun); | |
656 | if ((fd = open(ifr.ifr_name, O_RDWR)) >= 0) | |||
654 | break; | 657 | break; | |
655 | } | 658 | } | |
656 | } else { | 659 | } else { | |
657 | debug("%s: invalid tunnel %u", __func__, tun); | 660 | debug("%s: invalid tunnel %u", __func__, tun); | |
658 | return (-1); | 661 | return (-1); | |
659 | } | 662 | } | |
660 | 663 | |||
661 | if (fd < 0) { | 664 | if (fd < 0) { | |
662 | debug("%s: %s open failed: %s", __func__, name, strerror(errno)); | 665 | debug("%s: %s open failed: %s", __func__, ifr.ifr_name, | |
666 | strerror(errno)); | |||
663 | return (-1); | 667 | return (-1); | |
664 | } | 668 | } | |
665 | 669 | |||
666 | debug("%s: %s mode %d fd %d", __func__, name, mode, fd); | 670 | /* Turn on tunnel headers */ | |
671 | flag = 1; | |||
672 | if (mode != SSH_TUNMODE_ETHERNET && | |||
673 | ioctl(fd, TUNSIFHEAD, &flag) == -1) { | |||
674 | debug("%s: ioctl(%d, TUNSIFHEAD, 1): %s", __func__, fd, | |||
675 | strerror(errno)); | |||
676 | close(fd); | |||
677 | return -1; | |||
678 | } | |||
679 | ||||
680 | debug("%s: %s mode %d fd %d", __func__, ifr.ifr_name, mode, fd); | |||
667 | 681 | |||
668 | /* Set the tunnel device operation mode */ | 682 | /* Set the tunnel device operation mode */ | |
669 | snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "tun%d", tun); | |||
670 | if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) | 683 | if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) | |
671 | goto failed; | 684 | goto failed; | |
672 | 685 | |||
673 | if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) | 686 | if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) | |
674 | goto failed; | 687 | goto failed; | |
675 | 688 | |||
689 | #if 0 | |||
676 | /* Set interface mode */ | 690 | /* Set interface mode */ | |
677 | ifr.ifr_flags &= ~IFF_UP; | 691 | ifr.ifr_flags &= ~IFF_UP; | |
678 | if (mode == SSH_TUNMODE_ETHERNET) | 692 | if (mode == SSH_TUNMODE_ETHERNET) | |
679 | ifr.ifr_flags |= IFF_LINK0; | 693 | ifr.ifr_flags |= IFF_LINK0; | |
680 | else | 694 | else | |
681 | ifr.ifr_flags &= ~IFF_LINK0; | 695 | ifr.ifr_flags &= ~IFF_LINK0; | |
682 | if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) | 696 | if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) | |
683 | goto failed; | 697 | goto failed; | |
698 | #endif | |||
684 | 699 | |||
685 | /* Bring interface up */ | 700 | /* Bring interface up */ | |
686 | ifr.ifr_flags |= IFF_UP; | 701 | ifr.ifr_flags |= IFF_UP; | |
687 | if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) | 702 | if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) | |
688 | goto failed; | 703 | goto failed; | |
689 | 704 | |||
690 | close(sock); | 705 | close(sock); | |
691 | return (fd); | 706 | return (fd); | |
692 | 707 | |||
693 | failed: | 708 | failed: | |
694 | if (fd >= 0) | 709 | if (fd >= 0) | |
695 | close(fd); | 710 | close(fd); | |
696 | if (sock >= 0) | 711 | if (sock >= 0) | |
697 | close(sock); | 712 | close(sock); | |
698 | debug("%s: failed to set %s mode %d: %s", __func__, name, | 713 | debug("%s: failed to set %s mode %d: %s", __func__, ifr.ifr_name, | |
699 | mode, strerror(errno)); | 714 | mode, strerror(errno)); | |
700 | return (-1); | 715 | return (-1); | |
701 | } | 716 | } | |
702 | 717 | |||
703 | void | 718 | void | |
704 | sanitise_stdfd(void) | 719 | sanitise_stdfd(void) | |
705 | { | 720 | { | |
706 | int nullfd, dupfd; | 721 | int nullfd, dupfd; | |
707 | 722 | |||
708 | if ((nullfd = dupfd = open(_PATH_DEVNULL, O_RDWR)) == -1) { | 723 | if ((nullfd = dupfd = open(_PATH_DEVNULL, O_RDWR)) == -1) { | |
709 | fprintf(stderr, "Couldn't open /dev/null: %s", strerror(errno)); | 724 | fprintf(stderr, "Couldn't open /dev/null: %s", strerror(errno)); | |
710 | exit(1); | 725 | exit(1); | |
711 | } | 726 | } |