Browse Source

Add per-file error identifiers

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
9aa61ad5a2

+ 31
- 0
src/arch/i386/include/bits/errfile.h View File

@@ -0,0 +1,31 @@
1
+#ifndef _BITS_ERRFILE_H
2
+#define _BITS_ERRFILE_H
3
+
4
+/**
5
+ * @addtogroup errfile Error file identifiers
6
+ * @{
7
+ */
8
+
9
+#define ERRFILE_umalloc		( ERRFILE_ARCH | ERRFILE_CORE | 0x00000000 )
10
+#define ERRFILE_memmap		( ERRFILE_ARCH | ERRFILE_CORE | 0x00010000 )
11
+#define ERRFILE_pnpbios		( ERRFILE_ARCH | ERRFILE_CORE | 0x00020000 )
12
+#define ERRFILE_smbios		( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
13
+#define ERRFILE_biosint		( ERRFILE_ARCH | ERRFILE_CORE | 0x00040000 )
14
+#define ERRFILE_int13		( ERRFILE_ARCH | ERRFILE_CORE | 0x00050000 )
15
+
16
+#define ERRFILE_bootsector     ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
17
+#define ERRFILE_bzimage	       ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
18
+#define ERRFILE_eltorito       ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00020000 )
19
+#define ERRFILE_multiboot      ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00030000 )
20
+#define ERRFILE_nbi	       ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00040000 )
21
+#define ERRFILE_pxe_image      ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00050000 )
22
+
23
+#define ERRFILE_undi		 ( ERRFILE_ARCH | ERRFILE_NET | 0x00000000 )
24
+#define ERRFILE_undiload	 ( ERRFILE_ARCH | ERRFILE_NET | 0x00010000 )
25
+#define ERRFILE_undinet		 ( ERRFILE_ARCH | ERRFILE_NET | 0x00020000 )
26
+#define ERRFILE_undionly	 ( ERRFILE_ARCH | ERRFILE_NET | 0x00030000 )
27
+#define ERRFILE_undirom		 ( ERRFILE_ARCH | ERRFILE_NET | 0x00040000 )
28
+
29
+/** @} */
30
+
31
+#endif /* _BITS_ERRFILE_H */

+ 20
- 0
src/core/iobuf.c View File

@@ -17,6 +17,7 @@
17 17
  */
18 18
 
19 19
 #include <stdint.h>
20
+#include <errno.h>
20 21
 #include <gpxe/malloc.h>
21 22
 #include <gpxe/iobuf.h>
22 23
 
@@ -72,3 +73,22 @@ void free_iob ( struct io_buffer *iobuf ) {
72 73
 			   ( iobuf->end - iobuf->head ) + sizeof ( *iobuf ) );
73 74
 	}
74 75
 }
76
+
77
+/**
78
+ * Ensure I/O buffer has sufficient headroom
79
+ *
80
+ * @v iobuf	I/O buffer
81
+ * @v len	Required headroom
82
+ *
83
+ * This function currently only checks for the required headroom; it
84
+ * does not reallocate the I/O buffer if required.  If we ever have a
85
+ * code path that requires this functionality, it's a fairly trivial
86
+ * change to make.
87
+ */
88
+int iob_ensure_headroom ( struct io_buffer *iobuf, size_t len ) {
89
+
90
+	if ( iob_headroom ( iobuf ) >= len )
91
+		return 0;
92
+	return -ENOBUFS;
93
+}
94
+

+ 1
- 0
src/crypto/axtls_aes.c View File

@@ -1,5 +1,6 @@
1 1
 #include "crypto/axtls/crypto.h"
2 2
 #include <string.h>
3
+#include <errno.h>
3 4
 #include <gpxe/crypto.h>
4 5
 #include <gpxe/aes.h>
5 6
 

+ 24
- 0
src/crypto/cipher.c View File

@@ -0,0 +1,24 @@
1
+#include <stdint.h>
2
+#include <errno.h>
3
+#include <gpxe/crypto.h>
4
+
5
+int cipher_encrypt ( struct crypto_algorithm *crypto,
6
+		     void *ctx, const void *src, void *dst,
7
+		     size_t len ) {
8
+	if ( ( len & ( crypto->blocksize - 1 ) ) ) {
9
+		return -EINVAL;
10
+	}
11
+	crypto->encode ( ctx, src, dst, len );
12
+	return 0;
13
+}
14
+
15
+int cipher_decrypt ( struct crypto_algorithm *crypto,
16
+		     void *ctx, const void *src, void *dst,
17
+		     size_t len ) {
18
+	if ( ( len & ( crypto->blocksize - 1 ) ) ) {
19
+		return -EINVAL;
20
+	}
21
+	crypto->decode ( ctx, src, dst, len );
22
+	return 0;
23
+}
24
+

+ 6
- 9
src/hci/strerror.c View File

@@ -60,15 +60,7 @@ static struct errortab * find_closest_error ( int errno ) {
60 60
 	/* Second, try masking off the gPXE-specific bit and seeing if
61 61
 	 * we have an entry for the generic POSIX error message.
62 62
 	 */
63
-	if ( ( errortab = find_error ( errno, 0x0000ffff ) ) != NULL )
64
-		return errortab;
65
-
66
-	/* Lastly, try masking off the POSIX bits and seeing if we
67
-	 * have a match just based on the PXENV component.  This
68
-	 * allows us to report errors from underlying PXE stacks.
69
-	 */
70
-	if ( ( errortab = find_error ( ( errno & 0x000000ff ),
71
-				       0xffff00ff ) ) != NULL )
63
+	if ( ( errortab = find_error ( errno, 0x4f0000ff ) ) != NULL )
72 64
 		return errortab;
73 65
 
74 66
 	return NULL;
@@ -109,6 +101,10 @@ const char * strerror ( int errno ) {
109 101
 	return errbuf;
110 102
 }
111 103
 
104
+/* Do not include ERRFILE portion in the numbers in the error table */
105
+#undef ERRFILE
106
+#define ERRFILE 0
107
+
112 108
 /** The most common errors */
113 109
 struct errortab common_errors[] __errortab = {
114 110
 	{ 0, "No error" },
@@ -121,4 +117,5 @@ struct errortab common_errors[] __errortab = {
121 117
 	{ ENETUNREACH, "Network unreachable" },
122 118
 	{ ETIMEDOUT, "Connection timed out" },
123 119
 	{ EPIPE, "Broken pipe" },
120
+	{ ECANCELED, "Operation cancelled" },
124 121
 };

+ 3
- 0
src/include/compiler.h View File

@@ -267,6 +267,9 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr,
267 267
 #define NDEBUG
268 268
 #endif
269 269
 
270
+/** Select file identifier for errno.h (if used) */
271
+#define ERRFILE PREFIX_OBJECT ( ERRFILE_ )
272
+
270 273
 /** Declare a data structure as packed. */
271 274
 #define PACKED __attribute__ (( packed ))
272 275
 

+ 174
- 107
src/include/errno.h View File

@@ -7,35 +7,53 @@
7 7
  *
8 8
  * Return status codes as used within gPXE are designed to allow for
9 9
  * maximum visibility into the source of an error even in an end-user
10
- * build with no debugging.  They are constructed in three parts: a
11
- * PXE error code, a POSIX error code, and a gPXE-specific error code.
10
+ * build with no debugging.  They are constructed as follows:
12 11
  *
13
- * The low byte is the closest equivalent PXE error code
12
+ * Bits 7-0 : PXE error code
13
+ *
14
+ * This is the closest equivalent PXE error code
14 15
  * (e.g. PXENV_STATUS_OUT_OF_RESOURCES), and is the only part of the
15 16
  * error that will be returned via the PXE API, since PXE has
16 17
  * predefined error codes.
17 18
  *
18
- * The next byte is the closest equivalent POSIX error code
19
- * (e.g. ENOMEM).
19
+ * Bits 12-8 : Per-file disambiguator
20
+ *
21
+ * When the same error number can be generated from multiple points
22
+ * within a file, this field can be used to identify the unique
23
+ * instance.
24
+ *
25
+ * Bits 23-13 : File identifier
26
+ *
27
+ * This is a unique identifier for the file generating the error
28
+ * (e.g. ERRFILE_tcp for tcp.c).
29
+ *
30
+ * Bits 30-24 : POSIX error code
31
+ *
32
+ * This is the closest equivalent POSIX error code (e.g. ENOMEM).
33
+ *
34
+ * Bit 31 : Reserved
35
+ *
36
+ * Errors are usually return as negative error numbers (e.g. -EINVAL);
37
+ * bit 31 is therefore unusable.
20 38
  *
21
- * The remaining bytes are the gPXE-specific error code, which allow
22
- * us to disambiguate between errors which should have the same POSIX
23
- * error code but which mean very different things to the user
24
- * (e.g. ENOENT due to a DNS name not existing versus ENOENT due to
25
- * a web server returning HTTP/404 Not Found).
26 39
  *
27 40
  * The convention within the code is that errors are negative and
28
- * expressed as the bitwise OR of a POSIX error code and (optionally)
29
- * a gPXE error code, as in
41
+ * expressed using the POSIX error code and (optionally) a per-file
42
+ * disambiguator, e.g.
30 43
  *
31
- *     return -( ENOENT | NO_SUCH_FILE );
44
+ *     return -EINVAL;
32 45
  *
33
- * The POSIX error code is #defined to include the closest matching
34
- * PXE error code (which, in most cases, is just
35
- * PXENV_STATUS_FAILURE), so we don't need to litter the codebase with
36
- * PXEisms.
46
+ * or
37 47
  *
38
- * Functions that wish to return failure should be declared as
48
+ *     #define ETCP_BAD_CHECKSUM EUNIQ_02
49
+ *     return -( EINVAL | ETCP_BAD_CHECKSUM )
50
+ *
51
+ * By various bits of preprocessor magic, the PXE error code and file
52
+ * identifier are already incorporated into the definition of the
53
+ * POSIX error code, which keeps the code relatively clean.
54
+ *
55
+ *
56
+ * Functions that wish to return failures should be declared as
39 57
  * returning an integer @c rc "Return status code".  A return value of
40 58
  * zero indicates success, a non-zero value indicates failure.  The
41 59
  * return value can be passed directly to strerror() in order to
@@ -51,6 +69,20 @@
51 69
  *
52 70
  */
53 71
 
72
+/* Get definitions for file identifiers */
73
+#include <gpxe/errfile.h>
74
+
75
+/* If we do not have a valid file identifier, generate a compiler
76
+ * warning upon usage of any error codes.  (Don't just use a #warning,
77
+ * because some files include errno.h but don't ever actually use any
78
+ * error codes.)
79
+ */
80
+#if ! ERRFILE
81
+extern char missing_errfile_declaration[] __attribute__ (( deprecated ));
82
+#undef ERRFILE
83
+#define ERRFILE ( 0 * ( ( int ) missing_errfile_declaration ) )
84
+#endif
85
+
54 86
 /** Derive PXENV_STATUS code from gPXE error number */
55 87
 #define PXENV_STATUS( rc ) ( (-(rc)) & 0x00ff )
56 88
 
@@ -178,262 +210,297 @@
178 210
  */
179 211
 
180 212
 /** Operation completed successfully */
181
-#define ENOERR				      ( PXENV_STATUS_SUCCESS | 0x0000 )
213
+#define ENOERR			( ERRFILE | PXENV_STATUS_SUCCESS | 0x00000000 )
182 214
 
183 215
 /** Arg list too long */
184
-#define E2BIG				     ( PXENV_STATUS_BAD_FUNC | 0x0100 )
216
+#define E2BIG		       ( ERRFILE | PXENV_STATUS_BAD_FUNC | 0x01000000 )
185 217
 
186 218
 /** Permission denied */
187
-#define EACCES			( PXENV_STATUS_TFTP_ACCESS_VIOLATION | 0x0200 )
219
+#define EACCES	  ( ERRFILE | PXENV_STATUS_TFTP_ACCESS_VIOLATION | 0x02000000 )
188 220
 
189 221
 /** Address in use */
190
-#define EADDRINUSE			     ( PXENV_STATUS_UDP_OPEN | 0x0300 )
222
+#define EADDRINUSE	       ( ERRFILE | PXENV_STATUS_UDP_OPEN | 0x03000000 )
191 223
 
192 224
 /** Address not available */
193
-#define EADDRNOTAVAIL			     ( PXENV_STATUS_UDP_OPEN | 0x0400 )
225
+#define EADDRNOTAVAIL	       ( ERRFILE | PXENV_STATUS_UDP_OPEN | 0x04000000 )
194 226
 
195 227
 /** Address family not supported */
196
-#define EAFNOSUPPORT			  ( PXENV_STATUS_UNSUPPORTED | 0x0500 )
228
+#define EAFNOSUPPORT	    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x05000000 )
197 229
 
198 230
 /** Resource temporarily unavailable */
199
-#define EAGAIN				      ( PXENV_STATUS_FAILURE | 0x0600 )
231
+#define EAGAIN			( ERRFILE | PXENV_STATUS_FAILURE | 0x06000000 )
200 232
 
201 233
 /** Connection already in progress */
202
-#define EALREADY			     ( PXENV_STATUS_UDP_OPEN | 0x0700 )
234
+#define EALREADY	       ( ERRFILE | PXENV_STATUS_UDP_OPEN | 0x07000000 )
203 235
 
204 236
 /** Bad file descriptor */
205
-#define EBADF				  ( PXENV_STATUS_TFTP_CLOSED | 0x0800 )
237
+#define EBADF		    ( ERRFILE | PXENV_STATUS_TFTP_CLOSED | 0x08000000 )
206 238
 
207 239
 /** Bad message */
208
-#define EBADMSG				      ( PXENV_STATUS_FAILURE | 0x0900 )
240
+#define EBADMSG			( ERRFILE | PXENV_STATUS_FAILURE | 0x09000000 )
209 241
 
210 242
 /** Resource busy */
211
-#define EBUSY			     ( PXENV_STATUS_OUT_OF_RESOURCES | 0x0a00 )
243
+#define EBUSY	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x0a000000 )
212 244
 
213 245
 /** Operation canceled */
214
-#define ECANCELED	   ( PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE | 0x0b00 )
246
+#define ECANCELED \
247
+	     ( ERRFILE | PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE | 0x0b000000 )
215 248
 
216 249
 /** No child processes */
217
-#define ECHILD			  ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x0c00 )
250
+#define ECHILD	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x0c000000 )
218 251
 
219 252
 /** Connection aborted */
220
-#define ECONNABORTED ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x0d00 )
253
+#define ECONNABORTED \
254
+       ( ERRFILE | PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x0d000000 )
221 255
 
222 256
 /** Connection refused */
223
-#define ECONNREFUSED	  ( PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION | 0x0e00 )
257
+#define ECONNREFUSED \
258
+	    ( ERRFILE | PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION | 0x0e000000 )
224 259
 
225 260
 /** Connection reset */
226
-#define ECONNRESET   ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x0f00 )
261
+#define ECONNRESET \
262
+       ( ERRFILE | PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x0f000000 )
227 263
 
228 264
 /** Resource deadlock avoided */
229
-#define EDEADLK				      ( PXENV_STATUS_FAILURE | 0x1000 )
265
+#define EDEADLK			( ERRFILE | PXENV_STATUS_FAILURE | 0x10000000 )
230 266
 
231 267
 /** Destination address required */
232
-#define EDESTADDRREQ			     ( PXENV_STATUS_BAD_FUNC | 0x1100 )
268
+#define EDESTADDRREQ	       ( ERRFILE | PXENV_STATUS_BAD_FUNC | 0x11000000 )
233 269
 
234 270
 /** Domain error */
235
-#define EDOM				      ( PXENV_STATUS_FAILURE | 0x1200 )
271
+#define EDOM			( ERRFILE | PXENV_STATUS_FAILURE | 0x12000000 )
236 272
 
237 273
 /** Reserved */
238
-#define EDQUOT				      ( PXENV_STATUS_FAILURE | 0x1300 )
274
+#define EDQUOT			( ERRFILE | PXENV_STATUS_FAILURE | 0x13000000 )
239 275
 
240 276
 /** File exists */
241
-#define EEXIST				      ( PXENV_STATUS_FAILURE | 0x1400 )
277
+#define EEXIST			( ERRFILE | PXENV_STATUS_FAILURE | 0x14000000 )
242 278
 
243 279
 /** Bad address */
244
-#define EFAULT				( PXENV_STATUS_MCOPY_PROBLEM | 0x1500 )
280
+#define EFAULT		  ( ERRFILE | PXENV_STATUS_MCOPY_PROBLEM | 0x15000000 )
245 281
 
246 282
 /** File too large */
247
-#define EFBIG				( PXENV_STATUS_MCOPY_PROBLEM | 0x1600 )
283
+#define EFBIG		  ( ERRFILE | PXENV_STATUS_MCOPY_PROBLEM | 0x16000000 )
248 284
 
249 285
 /** Host is unreachable */
250
-#define EHOSTUNREACH			  ( PXENV_STATUS_ARP_TIMEOUT | 0x1700 )
286
+#define EHOSTUNREACH	    ( ERRFILE | PXENV_STATUS_ARP_TIMEOUT | 0x17000000 )
251 287
 
252 288
 /** Identifier removed */
253
-#define EIDRM				      ( PXENV_STATUS_FAILURE | 0x1800 )
289
+#define EIDRM			( ERRFILE | PXENV_STATUS_FAILURE | 0x18000000 )
254 290
 
255 291
 /** Illegal byte sequence */
256
-#define EILSEQ				      ( PXENV_STATUS_FAILURE | 0x1900 )
292
+#define EILSEQ			( ERRFILE | PXENV_STATUS_FAILURE | 0x19000000 )
257 293
 
258 294
 /** Operation in progress */
259
-#define EINPROGRESS			      ( PXENV_STATUS_FAILURE | 0x1a00 )
295
+#define EINPROGRESS		( ERRFILE | PXENV_STATUS_FAILURE | 0x1a000000 )
260 296
 
261 297
 /** Interrupted function call */
262
-#define EINTR				      ( PXENV_STATUS_FAILURE | 0x1b00 )
298
+#define EINTR			( ERRFILE | PXENV_STATUS_FAILURE | 0x1b000000 )
263 299
 
264 300
 /** Invalid argument */
265
-#define EINVAL				     ( PXENV_STATUS_BAD_FUNC | 0x1c00 )
301
+#define EINVAL		       ( ERRFILE | PXENV_STATUS_BAD_FUNC | 0x1c000000 )
266 302
 
267 303
 /** Input/output error */
268
-#define EIO	     ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x1d00 )
304
+#define EIO \
305
+       ( ERRFILE | PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x1d000000 )
269 306
 
270 307
 /** Socket is connected */
271
-#define EISCONN				     ( PXENV_STATUS_UDP_OPEN | 0x1e00 )
308
+#define EISCONN		       ( ERRFILE | PXENV_STATUS_UDP_OPEN | 0x1e000000 )
272 309
 
273 310
 /** Is a directory */
274
-#define EISDIR				      ( PXENV_STATUS_FAILURE | 0x1f00 )
311
+#define EISDIR			( ERRFILE | PXENV_STATUS_FAILURE | 0x1f000000 )
275 312
 
276 313
 /** Too many levels of symbolic links */
277
-#define ELOOP				      ( PXENV_STATUS_FAILURE | 0x2000 )
314
+#define ELOOP			( ERRFILE | PXENV_STATUS_FAILURE | 0x20000000 )
278 315
 
279 316
 /** Too many open files */
280
-#define EMFILE			     ( PXENV_STATUS_OUT_OF_RESOURCES | 0x2100 )
317
+#define EMFILE	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x21000000 )
281 318
 
282 319
 /** Too many links */
283
-#define EMLINK				      ( PXENV_STATUS_FAILURE | 0x2200 )
320
+#define EMLINK			( ERRFILE | PXENV_STATUS_FAILURE | 0x22000000 )
284 321
 
285 322
 /** Inappropriate message buffer length */
286
-#define EMSGSIZE			     ( PXENV_STATUS_BAD_FUNC | 0x2300 )
323
+#define EMSGSIZE	       ( ERRFILE | PXENV_STATUS_BAD_FUNC | 0x23000000 )
287 324
 
288 325
 /** Reserved */
289
-#define EMULTIHOP			      ( PXENV_STATUS_FAILURE | 0x2400 )
326
+#define EMULTIHOP		( ERRFILE | PXENV_STATUS_FAILURE | 0x24000000 )
290 327
 
291 328
 /** Filename too long */
292
-#define ENAMETOOLONG			      ( PXENV_STATUS_FAILURE | 0x2500 )
329
+#define ENAMETOOLONG		( ERRFILE | PXENV_STATUS_FAILURE | 0x25000000 )
293 330
 
294 331
 /** Network is down */
295
-#define ENETDOWN			  ( PXENV_STATUS_ARP_TIMEOUT | 0x2600 )
332
+#define ENETDOWN	    ( ERRFILE | PXENV_STATUS_ARP_TIMEOUT | 0x26000000 )
296 333
 
297 334
 /** Connection aborted by network */
298
-#define ENETRESET			      ( PXENV_STATUS_FAILURE | 0x2700 )
335
+#define ENETRESET		( ERRFILE | PXENV_STATUS_FAILURE | 0x27000000 )
299 336
 
300 337
 /** Network unreachable */
301
-#define ENETUNREACH			  ( PXENV_STATUS_ARP_TIMEOUT | 0x2800 )
338
+#define ENETUNREACH	    ( ERRFILE | PXENV_STATUS_ARP_TIMEOUT | 0x28000000 )
302 339
 
303 340
 /** Too many open files in system */
304
-#define ENFILE			     ( PXENV_STATUS_OUT_OF_RESOURCES | 0x2900 )
341
+#define ENFILE	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x29000000 )
305 342
 
306 343
 /** No buffer space available */
307
-#define ENOBUFS			     ( PXENV_STATUS_OUT_OF_RESOURCES | 0x2a00 )
344
+#define ENOBUFS	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x2a000000 )
308 345
 
309 346
 /** No message is available on the STREAM head read queue */
310
-#define ENODATA				      ( PXENV_STATUS_FAILURE | 0x2b00 )
347
+#define ENODATA			( ERRFILE | PXENV_STATUS_FAILURE | 0x2b000000 )
311 348
 
312 349
 /** No such device */
313
-#define ENODEV			  ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x2c00 )
350
+#define ENODEV	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x2c000000 )
314 351
 
315 352
 /** No such file or directory */
316
-#define ENOENT			  ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x2d00 )
353
+#define ENOENT	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x2d000000 )
317 354
 
318 355
 /** Exec format error */
319
-#define ENOEXEC				      ( PXENV_STATUS_FAILURE | 0x2e00 )
356
+#define ENOEXEC			( ERRFILE | PXENV_STATUS_FAILURE | 0x2e000000 )
320 357
 
321 358
 /** No locks available */
322
-#define ENOLCK				      ( PXENV_STATUS_FAILURE | 0x2f00 )
359
+#define ENOLCK			( ERRFILE | PXENV_STATUS_FAILURE | 0x2f000000 )
323 360
 
324 361
 /** Reserved */
325
-#define ENOLINK				      ( PXENV_STATUS_FAILURE | 0x3000 )
362
+#define ENOLINK			( ERRFILE | PXENV_STATUS_FAILURE | 0x30000000 )
326 363
 
327 364
 /** Not enough space */
328
-#define ENOMEM			     ( PXENV_STATUS_OUT_OF_RESOURCES | 0x3100 )
365
+#define ENOMEM	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x31000000 )
329 366
 
330 367
 /** No message of the desired type */
331
-#define ENOMSG				      ( PXENV_STATUS_FAILURE | 0x3200 )
368
+#define ENOMSG			( ERRFILE | PXENV_STATUS_FAILURE | 0x32000000 )
332 369
 
333 370
 /** Protocol not available */
334
-#define ENOPROTOOPT			  ( PXENV_STATUS_UNSUPPORTED | 0x3300 )
371
+#define ENOPROTOOPT	    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x33000000 )
335 372
 
336 373
 /** No space left on device */
337
-#define ENOSPC			     ( PXENV_STATUS_OUT_OF_RESOURCES | 0x3400 )
374
+#define ENOSPC	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x34000000 )
338 375
 
339 376
 /** No STREAM resources */
340
-#define ENOSR			     ( PXENV_STATUS_OUT_OF_RESOURCES | 0x3500 )
377
+#define ENOSR	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x35000000 )
341 378
 
342 379
 /** Not a STREAM */
343
-#define ENOSTR				      ( PXENV_STATUS_FAILURE | 0x3600 )
380
+#define ENOSTR			( ERRFILE | PXENV_STATUS_FAILURE | 0x36000000 )
344 381
 
345 382
 /** Function not implemented */
346
-#define ENOSYS				  ( PXENV_STATUS_UNSUPPORTED | 0x3700 )
383
+#define ENOSYS		    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x37000000 )
347 384
 
348 385
 /** The socket is not connected */
349
-#define ENOTCONN			      ( PXENV_STATUS_FAILURE | 0x3800 )
386
+#define ENOTCONN		( ERRFILE | PXENV_STATUS_FAILURE | 0x38000000 )
350 387
 
351 388
 /** Not a directory */
352
-#define ENOTDIR				      ( PXENV_STATUS_FAILURE | 0x3900 )
389
+#define ENOTDIR			( ERRFILE | PXENV_STATUS_FAILURE | 0x39000000 )
353 390
 
354 391
 /** Directory not empty */
355
-#define ENOTEMPTY			      ( PXENV_STATUS_FAILURE | 0x3a00 )
392
+#define ENOTEMPTY		( ERRFILE | PXENV_STATUS_FAILURE | 0x3a000000 )
356 393
 
357 394
 /** Not a socket */
358
-#define ENOTSOCK			      ( PXENV_STATUS_FAILURE | 0x3b00 )
395
+#define ENOTSOCK		( ERRFILE | PXENV_STATUS_FAILURE | 0x3b000000 )
359 396
 
360 397
 /** Not supported */
361
-#define ENOTSUP				  ( PXENV_STATUS_UNSUPPORTED | 0x3c00 )
398
+#define ENOTSUP		    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x3c000000 )
362 399
 
363 400
 /** Inappropriate I/O control operation */
364
-#define ENOTTY				      ( PXENV_STATUS_FAILURE | 0x3d00 )
401
+#define ENOTTY			( ERRFILE | PXENV_STATUS_FAILURE | 0x3d000000 )
365 402
 
366 403
 /** No such device or address */
367
-#define ENXIO			  ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x3e00 )
404
+#define ENXIO	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x3e000000 )
368 405
 
369 406
 /** Operation not supported on socket */
370
-#define EOPNOTSUPP			  ( PXENV_STATUS_UNSUPPORTED | 0x3f00 )
407
+#define EOPNOTSUPP	    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x3f000000 )
371 408
 
372 409
 /** Value too large to be stored in data type */
373
-#define EOVERFLOW			      ( PXENV_STATUS_FAILURE | 0x4000 )
410
+#define EOVERFLOW		( ERRFILE | PXENV_STATUS_FAILURE | 0x40000000 )
374 411
 
375 412
 /** Operation not permitted */
376
-#define EPERM			( PXENV_STATUS_TFTP_ACCESS_VIOLATION | 0x4100 )
413
+#define EPERM	  ( ERRFILE | PXENV_STATUS_TFTP_ACCESS_VIOLATION | 0x41000000 )
377 414
 
378 415
 /** Broken pipe */
379
-#define EPIPE				      ( PXENV_STATUS_FAILURE | 0x4200 )
416
+#define EPIPE			( ERRFILE | PXENV_STATUS_FAILURE | 0x42000000 )
380 417
 
381 418
 /** Protocol error */
382
-#define EPROTO				      ( PXENV_STATUS_FAILURE | 0x4300 )
419
+#define EPROTO			( ERRFILE | PXENV_STATUS_FAILURE | 0x43000000 )
383 420
 
384 421
 /** Protocol not supported */
385
-#define EPROTONOSUPPORT			  ( PXENV_STATUS_UNSUPPORTED | 0x4400 )
422
+#define EPROTONOSUPPORT	    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x44000000 )
386 423
 
387 424
 /** Protocol wrong type for socket */
388
-#define EPROTOTYPE			      ( PXENV_STATUS_FAILURE | 0x4500 )
425
+#define EPROTOTYPE		( ERRFILE | PXENV_STATUS_FAILURE | 0x45000000 )
389 426
 
390 427
 /** Result too large */
391
-#define ERANGE				      ( PXENV_STATUS_FAILURE | 0x4600 )
428
+#define ERANGE			( ERRFILE | PXENV_STATUS_FAILURE | 0x46000000 )
392 429
 
393 430
 /** Read-only file system */
394
-#define EROFS				      ( PXENV_STATUS_FAILURE | 0x4700 )
431
+#define EROFS			( ERRFILE | PXENV_STATUS_FAILURE | 0x47000000 )
395 432
 
396 433
 /** Invalid seek */
397
-#define ESPIPE				      ( PXENV_STATUS_FAILURE | 0x4800 )
434
+#define ESPIPE			( ERRFILE | PXENV_STATUS_FAILURE | 0x48000000 )
398 435
 
399 436
 /** No such process */
400
-#define ESRCH			  ( PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x4900 )
437
+#define ESRCH	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x49000000 )
401 438
 
402 439
 /** Stale file handle */
403
-#define ESTALE				      ( PXENV_STATUS_FAILURE | 0x4a00 )
440
+#define ESTALE			( ERRFILE | PXENV_STATUS_FAILURE | 0x4a000000 )
404 441
 
405 442
 /** STREAM ioctl() timeout */
406
-#define ETIME				      ( PXENV_STATUS_FAILURE | 0x4b00 )
443
+#define ETIME			( ERRFILE | PXENV_STATUS_FAILURE | 0x4b000000 )
407 444
 
408 445
 /** Operation timed out */
409
-#define ETIMEDOUT		    ( PXENV_STATUS_TFTP_READ_TIMEOUT | 0x4c00 )
446
+#define ETIMEDOUT     ( ERRFILE | PXENV_STATUS_TFTP_READ_TIMEOUT | 0x4c000000 )
410 447
 
411 448
 /** Text file busy */
412
-#define ETXTBSY				      ( PXENV_STATUS_FAILURE | 0x4d00 )
449
+#define ETXTBSY			( ERRFILE | PXENV_STATUS_FAILURE | 0x4d000000 )
413 450
 
414 451
 /** Operation would block */
415
-#define EWOULDBLOCK			      ( PXENV_STATUS_FAILURE | 0x4e00 )
452
+#define EWOULDBLOCK		( ERRFILE | PXENV_STATUS_FAILURE | 0x4e000000 )
416 453
 
417 454
 /** Improper link */
418
-#define EXDEV				      ( PXENV_STATUS_FAILURE | 0x4f00 )
455
+#define EXDEV			( ERRFILE | PXENV_STATUS_FAILURE | 0x4f000000 )
419 456
 
420 457
 /** @} */
421 458
 
422 459
 /**
423
- * @defgroup gpxeerrors gPXE-specific error codes
460
+ * @defgroup euniq Per-file error disambiguators
424 461
  *
425
- * The names, meanings, and values of these error codes are defined by
426
- * this file.  A gPXE-specific error code should be defined only where
427
- * the POSIX error code does not identify the error with sufficient
428
- * specificity.  For example, ENOMEM probably encapsulates everything
429
- * that needs to be known about the error (we've run out of heap
430
- * space), while EACCES does not (did the server refuse the
431
- * connection, or did we decide that the server failed to provide a
432
- * valid SSL/TLS certificate?).
462
+ * Files which use the same error number multiple times should
463
+ * probably define their own error subspace using these
464
+ * disambiguators.  For example:
465
+ *
466
+ *     #define ETCP_HEADER_TOO_SHORT	EUNIQ_01
467
+ *     #define ETCP_BAD_CHECKSUM	EUNIQ_02
433 468
  *
434 469
  * @{
435 470
  */
436 471
 
472
+#define EUNIQ_01	0x00000100
473
+#define EUNIQ_02	0x00000200
474
+#define EUNIQ_03	0x00000300
475
+#define EUNIQ_04	0x00000400
476
+#define EUNIQ_05	0x00000500
477
+#define EUNIQ_06	0x00000600
478
+#define EUNIQ_07	0x00000700
479
+#define EUNIQ_08	0x00000800
480
+#define EUNIQ_09	0x00000900
481
+#define EUNIQ_0A	0x00000a00
482
+#define EUNIQ_0B	0x00000b00
483
+#define EUNIQ_0C	0x00000c00
484
+#define EUNIQ_0D	0x00000d00
485
+#define EUNIQ_0E	0x00000e00
486
+#define EUNIQ_0F	0x00000f00
487
+#define EUNIQ_10	0x00001000
488
+#define EUNIQ_11	0x00001100
489
+#define EUNIQ_12	0x00001200
490
+#define EUNIQ_13	0x00001300
491
+#define EUNIQ_14	0x00001400
492
+#define EUNIQ_15	0x00001500
493
+#define EUNIQ_16	0x00001600
494
+#define EUNIQ_17	0x00001700
495
+#define EUNIQ_18	0x00001800
496
+#define EUNIQ_19	0x00001900
497
+#define EUNIQ_1A	0x00001a00
498
+#define EUNIQ_1B	0x00001b00
499
+#define EUNIQ_1C	0x00001c00
500
+#define EUNIQ_1D	0x00001d00
501
+#define EUNIQ_1E	0x00001e00
502
+#define EUNIQ_1F	0x00001f00
503
+
437 504
 /** @} */
438 505
 
439 506
 extern int errno;

+ 7
- 21
src/include/gpxe/crypto.h View File

@@ -9,7 +9,6 @@
9 9
 
10 10
 #include <stdint.h>
11 11
 #include <stddef.h>
12
-#include <errno.h>
13 12
 
14 13
 /** A cryptographic algorithm */
15 14
 struct crypto_algorithm {
@@ -101,30 +100,17 @@ static inline int cipher_setkey ( struct crypto_algorithm *crypto,
101 100
 	return crypto->setkey ( ctx, key, keylen );
102 101
 }
103 102
 
104
-static inline int cipher_encrypt ( struct crypto_algorithm *crypto,
105
-				   void *ctx, const void *src, void *dst,
106
-				   size_t len ) {
107
-	if ( ( len & ( crypto->blocksize - 1 ) ) ) {
108
-		return -EINVAL;
109
-	}
110
-	crypto->encode ( ctx, src, dst, len );
111
-	return 0;
112
-}
113
-
114
-static inline int cipher_decrypt ( struct crypto_algorithm *crypto,
115
-				   void *ctx, const void *src, void *dst,
116
-				   size_t len ) {
117
-	if ( ( len & ( crypto->blocksize - 1 ) ) ) {
118
-		return -EINVAL;
119
-	}
120
-	crypto->decode ( ctx, src, dst, len );
121
-	return 0;
122
-}
123
-
124 103
 static inline int is_stream_cipher ( struct crypto_algorithm *crypto ) {
125 104
 	return ( crypto->blocksize == 1 );
126 105
 }
127 106
 
128 107
 extern struct crypto_algorithm crypto_null;
129 108
 
109
+extern int cipher_encrypt ( struct crypto_algorithm *crypto,
110
+			    void *ctx, const void *src, void *dst,
111
+			    size_t len );
112
+extern int cipher_decrypt ( struct crypto_algorithm *crypto,
113
+			    void *ctx, const void *src, void *dst,
114
+			    size_t len );
115
+
130 116
 #endif /* _GPXE_CRYPTO_H */

+ 121
- 0
src/include/gpxe/errfile.h View File

@@ -0,0 +1,121 @@
1
+#ifndef _GPXE_ERRFILE_H
2
+#define _GPXE_ERRFILE_H
3
+
4
+/** @file
5
+ *
6
+ * Error file identifiers
7
+ *
8
+ */
9
+
10
+#include <bits/errfile.h>
11
+
12
+/**
13
+ * @defgroup errfilecat Error file identifier categories
14
+ *
15
+ * @{
16
+ */
17
+
18
+#define ERRFILE_CORE		0x00002000	/**< Core code */
19
+#define ERRFILE_DRIVER		0x00004000	/**< Driver code */
20
+#define ERRFILE_NET		0x00006000	/**< Networking code */
21
+#define ERRFILE_IMAGE		0x00008000	/**< Image code */
22
+#define ERRFILE_OTHER		0x0000e000	/**< Any other code */
23
+
24
+/** @} */
25
+
26
+/** Flag for architecture-dependent error files */
27
+#define ERRFILE_ARCH		0x00800000
28
+
29
+/**
30
+ * @defgroup errfile Error file identifiers
31
+ *
32
+ * These values are automatically incorporated into the definitions
33
+ * for error numbers such as EINVAL.
34
+ *
35
+ * @{
36
+ */
37
+
38
+#define ERRFILE_asprintf	       ( ERRFILE_CORE | 0x00000000 )
39
+#define ERRFILE_downloader	       ( ERRFILE_CORE | 0x00010000 )
40
+#define ERRFILE_exec		       ( ERRFILE_CORE | 0x00020000 )
41
+#define ERRFILE_hw		       ( ERRFILE_CORE | 0x00030000 )
42
+#define ERRFILE_iobuf		       ( ERRFILE_CORE | 0x00040000 )
43
+#define ERRFILE_job		       ( ERRFILE_CORE | 0x00050000 )
44
+#define ERRFILE_linebuf		       ( ERRFILE_CORE | 0x00060000 )
45
+#define ERRFILE_monojob		       ( ERRFILE_CORE | 0x00070000 )
46
+#define ERRFILE_nvo		       ( ERRFILE_CORE | 0x00080000 )
47
+#define ERRFILE_open		       ( ERRFILE_CORE | 0x00090000 )
48
+#define ERRFILE_posix_io	       ( ERRFILE_CORE | 0x000a0000 )
49
+#define ERRFILE_resolv		       ( ERRFILE_CORE | 0x000b0000 )
50
+#define ERRFILE_settings	       ( ERRFILE_CORE | 0x000c0000 )
51
+#define ERRFILE_vsprintf	       ( ERRFILE_CORE | 0x000d0000 )
52
+#define ERRFILE_xfer		       ( ERRFILE_CORE | 0x000e0000 )
53
+
54
+#define ERRFILE_eisa		     ( ERRFILE_DRIVER | 0x00000000 )
55
+#define ERRFILE_isa		     ( ERRFILE_DRIVER | 0x00010000 )
56
+#define ERRFILE_isapnp		     ( ERRFILE_DRIVER | 0x00020000 )
57
+#define ERRFILE_mca		     ( ERRFILE_DRIVER | 0x00030000 )
58
+#define ERRFILE_pci		     ( ERRFILE_DRIVER | 0x00040000 )
59
+
60
+#define ERRFILE_nvs		     ( ERRFILE_DRIVER | 0x00100000 )
61
+#define ERRFILE_spi		     ( ERRFILE_DRIVER | 0x00110000 )
62
+#define ERRFILE_i2c_bit		     ( ERRFILE_DRIVER | 0x00120000 )
63
+#define ERRFILE_spi_bit		     ( ERRFILE_DRIVER | 0x00130000 )
64
+
65
+#define ERRFILE_3c509		     ( ERRFILE_DRIVER | 0x00200000 )
66
+#define ERRFILE_bnx2		     ( ERRFILE_DRIVER | 0x00210000 )
67
+#define ERRFILE_cs89x0		     ( ERRFILE_DRIVER | 0x00220000 )
68
+#define ERRFILE_eepro		     ( ERRFILE_DRIVER | 0x00230000 )
69
+#define ERRFILE_etherfabric	     ( ERRFILE_DRIVER | 0x00240000 )
70
+#define ERRFILE_legacy		     ( ERRFILE_DRIVER | 0x00250000 )
71
+#define ERRFILE_natsemi		     ( ERRFILE_DRIVER | 0x00260000 )
72
+#define ERRFILE_pnic		     ( ERRFILE_DRIVER | 0x00270000 )
73
+#define ERRFILE_prism2_pci	     ( ERRFILE_DRIVER | 0x00280000 )
74
+#define ERRFILE_prism2_plx	     ( ERRFILE_DRIVER | 0x00290000 )
75
+#define ERRFILE_rtl8139		     ( ERRFILE_DRIVER | 0x002a0000 )
76
+#define ERRFILE_smc9000		     ( ERRFILE_DRIVER | 0x002b0000 )
77
+#define ERRFILE_tg3		     ( ERRFILE_DRIVER | 0x002c0000 )
78
+
79
+#define ERRFILE_scsi		     ( ERRFILE_DRIVER | 0x00700000 )
80
+
81
+#define ERRFILE_aoe			( ERRFILE_NET | 0x00000000 )
82
+#define ERRFILE_arp			( ERRFILE_NET | 0x00010000 )
83
+#define ERRFILE_dhcpopts		( ERRFILE_NET | 0x00020000 )
84
+#define ERRFILE_ethernet		( ERRFILE_NET | 0x00030000 )
85
+#define ERRFILE_icmpv6			( ERRFILE_NET | 0x00040000 )
86
+#define ERRFILE_ipv4			( ERRFILE_NET | 0x00050000 )
87
+#define ERRFILE_ipv6			( ERRFILE_NET | 0x00060000 )
88
+#define ERRFILE_ndp			( ERRFILE_NET | 0x00070000 )
89
+#define ERRFILE_netdevice		( ERRFILE_NET | 0x00080000 )
90
+#define ERRFILE_nullnet			( ERRFILE_NET | 0x00090000 )
91
+#define ERRFILE_tcp			( ERRFILE_NET | 0x000a0000 )
92
+#define ERRFILE_ftp			( ERRFILE_NET | 0x000b0000 )
93
+#define ERRFILE_http			( ERRFILE_NET | 0x000c0000 )
94
+#define ERRFILE_iscsi			( ERRFILE_NET | 0x000d0000 )
95
+#define ERRFILE_tcpip			( ERRFILE_NET | 0x000e0000 )
96
+#define ERRFILE_udp			( ERRFILE_NET | 0x000f0000 )
97
+#define ERRFILE_dhcp			( ERRFILE_NET | 0x00100000 )
98
+#define ERRFILE_dns			( ERRFILE_NET | 0x00110000 )
99
+#define ERRFILE_tftp			( ERRFILE_NET | 0x00120000 )
100
+
101
+#define ERRFILE_image		      ( ERRFILE_IMAGE | 0x00000000 )
102
+#define ERRFILE_elf		      ( ERRFILE_IMAGE | 0x00010000 )
103
+#define ERRFILE_script		      ( ERRFILE_IMAGE | 0x00020000 )
104
+#define ERRFILE_segment		      ( ERRFILE_IMAGE | 0x00030000 )
105
+
106
+#define ERRFILE_asn1		      ( ERRFILE_OTHER | 0x00000000 )
107
+#define ERRFILE_chap		      ( ERRFILE_OTHER | 0x00010000 )
108
+#define ERRFILE_aoeboot		      ( ERRFILE_OTHER | 0x00020000 )
109
+#define ERRFILE_autoboot	      ( ERRFILE_OTHER | 0x00030000 )
110
+#define ERRFILE_dhcpmgmt	      ( ERRFILE_OTHER | 0x00040000 )
111
+#define ERRFILE_imgmgmt		      ( ERRFILE_OTHER | 0x00050000 )
112
+#define ERRFILE_pxe_tftp	      ( ERRFILE_OTHER | 0x00060000 )
113
+#define ERRFILE_pxe_udp		      ( ERRFILE_OTHER | 0x00070000 )
114
+#define ERRFILE_axtls_aes	      ( ERRFILE_OTHER | 0x00080000 )
115
+#define ERRFILE_cipher		      ( ERRFILE_OTHER | 0x00090000 )
116
+#define ERRFILE_image_cmd	      ( ERRFILE_OTHER | 0x000a0000 )
117
+#define ERRFILE_uri_test	      ( ERRFILE_OTHER | 0x000b0000 )
118
+
119
+/** @} */
120
+
121
+#endif /* _GPXE_ERRFILE_H */

+ 0
- 1
src/include/gpxe/errortab.h View File

@@ -7,7 +7,6 @@
7 7
  *
8 8
  */
9 9
 
10
-#include <errno.h>
11 10
 #include <gpxe/tables.h>
12 11
 
13 12
 struct errortab {

+ 1
- 19
src/include/gpxe/iobuf.h View File

@@ -9,7 +9,6 @@
9 9
 
10 10
 #include <stdint.h>
11 11
 #include <assert.h>
12
-#include <errno.h>
13 12
 #include <gpxe/list.h>
14 13
 
15 14
 /**
@@ -162,26 +161,9 @@ static inline size_t iob_tailroom ( struct io_buffer *iobuf ) {
162 161
 	return ( iobuf->end - iobuf->tail );
163 162
 }
164 163
 
165
-/**
166
- * Ensure I/O buffer has sufficient headroom
167
- *
168
- * @v iobuf	I/O buffer
169
- * @v len	Required headroom
170
- *
171
- * This function currently only checks for the required headroom; it
172
- * does not reallocate the I/O buffer if required.  If we ever have a
173
- * code path that requires this functionality, it's a fairly trivial
174
- * change to make.
175
- */
176
-static inline __attribute__ (( always_inline )) int
177
-iob_ensure_headroom ( struct io_buffer *iobuf, size_t len ) {
178
-	if ( iob_headroom ( iobuf ) >= len )
179
-		return 0;
180
-	return -ENOBUFS;
181
-}
182
-
183 164
 extern struct io_buffer * alloc_iob ( size_t len );
184 165
 extern void free_iob ( struct io_buffer *iobuf );
185 166
 extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );
167
+extern int iob_ensure_headroom ( struct io_buffer *iobuf, size_t len );
186 168
 
187 169
 #endif /* _GPXE_IOBUF_H */

+ 0
- 1
src/include/gpxe/ndp.h View File

@@ -1,6 +1,5 @@
1 1
 #include <stdint.h>
2 2
 #include <byteswap.h>
3
-#include <errno.h>
4 3
 #include <string.h>
5 4
 #include <gpxe/icmp6.h>
6 5
 #include <gpxe/ip6.h>

+ 1
- 0
src/interface/pxe/pxe_errors.c View File

@@ -1,3 +1,4 @@
1
+#include <errno.h>
1 2
 #include <gpxe/errortab.h>
2 3
 
3 4
 /*

+ 1
- 0
src/interface/pxe/pxe_tftp.c View File

@@ -24,6 +24,7 @@
24 24
 
25 25
 #include <stdlib.h>
26 26
 #include <stdio.h>
27
+#include <errno.h>
27 28
 #include <byteswap.h>
28 29
 #include <gpxe/uaccess.h>
29 30
 #include <gpxe/in.h>

+ 1
- 0
src/net/nullnet.c View File

@@ -17,6 +17,7 @@
17 17
  */
18 18
 
19 19
 #include <stdint.h>
20
+#include <errno.h>
20 21
 #include <gpxe/iobuf.h>
21 22
 #include <gpxe/netdevice.h>
22 23
 

+ 2
- 20
src/net/tcp.c View File

@@ -395,7 +395,6 @@ static int tcp_xmit ( struct tcp_connection *tcp, int force_send ) {
395 395
 	size_t seq_len;
396 396
 	size_t app_win;
397 397
 	size_t rcv_win;
398
-	int rc;
399 398
 
400 399
 	/* If retransmission timer is already running, do nothing */
401 400
 	if ( timer_running ( &tcp->timer ) )
@@ -485,25 +484,8 @@ static int tcp_xmit ( struct tcp_connection *tcp, int force_send ) {
485 484
 	DBGC ( tcp, "\n" );
486 485
 
487 486
 	/* Transmit packet */
488
-	rc = tcpip_tx ( iobuf, &tcp_protocol, &tcp->peer, NULL, &tcphdr->csum );
489
-
490
-	/* If we got -ENETUNREACH, kill the connection immediately
491
-	 * because there is no point retrying.  This isn't strictly
492
-	 * necessary (since we will eventually time out anyway), but
493
-	 * it avoids irritating needless delays.  Don't do this for
494
-	 * RST packets transmitted on connection abort, to avoid a
495
-	 * potential infinite loop.
496
-	 */
497
-	if ( ( ! ( tcp->tcp_state & TCP_STATE_SENT ( TCP_RST ) ) ) &&
498
-	     ( rc == -ENETUNREACH ) ) {
499
-		DBGC ( tcp, "TCP %p aborting after TX failed: %s\n",
500
-		       tcp, strerror ( rc ) );
501
-		tcp->tcp_state = TCP_CLOSED;
502
-		tcp_dump_state ( tcp );
503
-		tcp_close ( tcp, rc );
504
-	}
505
-
506
-	return rc;
487
+	return tcpip_tx ( iobuf, &tcp_protocol, &tcp->peer, NULL,
488
+			  &tcphdr->csum );
507 489
 }
508 490
 
509 491
 /**

Loading…
Cancel
Save