Browse Source

[libc] Enable automated extraction of error usage reports

Add preprocessor magic to the error definitions to enable every error
usage to be tracked.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
6c0e8c14be

+ 1
- 0
src/Makefile View File

43
 ELF2EFI64	:= ./util/elf2efi64
43
 ELF2EFI64	:= ./util/elf2efi64
44
 EFIROM		:= ./util/efirom
44
 EFIROM		:= ./util/efirom
45
 ICCFIX		:= ./util/iccfix
45
 ICCFIX		:= ./util/iccfix
46
+EINFO		:= ./util/einfo
46
 DOXYGEN		:= doxygen
47
 DOXYGEN		:= doxygen
47
 BINUTILS_DIR	:= /usr
48
 BINUTILS_DIR	:= /usr
48
 BFD_DIR		:= $(BINUTILS_DIR)
49
 BFD_DIR		:= $(BINUTILS_DIR)

+ 21
- 0
src/Makefile.housekeeping View File

550
 
550
 
551
 CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
551
 CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
552
 
552
 
553
+# Generate error usage information
554
+#
555
+$(BIN)/%.einfo : $(BIN)/%.o
556
+	$(QM)$(ECHO) "  [EINFO] $@"
557
+	$(Q)$(OBJCOPY) -O binary -j .einfo --set-section-flags .einfo=alloc \
558
+		$< $@
559
+
560
+EINFOS		:= $(patsubst $(BIN)/%.o,$(BIN)/%.einfo,$(BOBJS))
561
+$(BIN)/errors : $(EINFOS) $(EINFO)
562
+	$(QM)$(ECHO) "  [EINFO] $@"
563
+	$(Q)$(EINFO) $(EINFOS) | sort > $@
564
+
553
 # Generate the NIC file from the parsed source files.  The NIC file is
565
 # Generate the NIC file from the parsed source files.  The NIC file is
554
 # only for rom-o-matic.
566
 # only for rom-o-matic.
555
 #
567
 #
902
 	$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
914
 	$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
903
 CLEANUP += $(ICCFIX)
915
 CLEANUP += $(ICCFIX)
904
 
916
 
917
+###############################################################################
918
+#
919
+# The error usage information utility
920
+#
921
+$(EINFO) : util/einfo.c $(MAKEDEPS)
922
+	$(QM)$(ECHO) "  [HOSTCC] $@"
923
+	$(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
924
+CLEANUP += $(EINFO)
925
+
905
 ###############################################################################
926
 ###############################################################################
906
 #
927
 #
907
 # Local configs
928
 # Local configs

+ 2
- 0
src/arch/i386/scripts/i386.lds View File

162
 	*(.eh_frame.*)
162
 	*(.eh_frame.*)
163
 	*(.rel)
163
 	*(.rel)
164
 	*(.rel.*)
164
 	*(.rel.*)
165
+	*(.einfo)
166
+	*(.einfo.*)
165
 	*(.discard)
167
 	*(.discard)
166
     }
168
     }
167
 
169
 

+ 2
- 0
src/arch/x86/scripts/efi.lds View File

99
 	*(.eh_frame.*)
99
 	*(.eh_frame.*)
100
 	*(.rel)
100
 	*(.rel)
101
 	*(.rel.*)
101
 	*(.rel.*)
102
+	*(.einfo)
103
+	*(.einfo.*)
102
 	*(.discard)
104
 	*(.discard)
103
     }
105
     }
104
 }
106
 }

+ 4
- 2
src/drivers/net/ipoib.c View File

77
 };
77
 };
78
 
78
 
79
 /** Link status for "broadcast join in progress" */
79
 /** Link status for "broadcast join in progress" */
80
-#define EINPROGRESS_JOINING ( EINPROGRESS | EUNIQ_01 )
80
+#define EINPROGRESS_JOINING __einfo_error ( EINFO_EINPROGRESS_JOINING )
81
+#define EINFO_EINPROGRESS_JOINING __einfo_uniqify \
82
+	( EINFO_EINPROGRESS, 0x01, "Joining" )
81
 
83
 
82
 /** Human-readable message for the link status */
84
 /** Human-readable message for the link status */
83
 struct errortab ipoib_errors[] __errortab = {
85
 struct errortab ipoib_errors[] __errortab = {
84
-	{ EINPROGRESS_JOINING, "Joining" },
86
+	__einfo_errortab ( EINFO_EINPROGRESS_JOINING ),
85
 };
87
 };
86
 
88
 
87
 /****************************************************************************
89
 /****************************************************************************

+ 17
- 17
src/hci/strerror.c View File

102
 
102
 
103
 /** The most common errors */
103
 /** The most common errors */
104
 struct errortab common_errors[] __errortab = {
104
 struct errortab common_errors[] __errortab = {
105
-	{ 0, "No error" },
106
-	{ EACCES, "Permission denied" },
107
-	{ ECANCELED, "Operation cancelled" },
108
-	{ ECONNRESET, "Connection reset" },
109
-	{ EINVAL, "Invalid argument" },
110
-	{ EIO, "Input/output error" },
111
-	{ ENETUNREACH, "Network unreachable" },
112
-	{ ENODEV, "No such device" },
113
-	{ ENOENT, "File not found" },
114
-	{ ENOEXEC, "Not an executable image" },
115
-	{ ENOMEM, "Out of memory" },
116
-	{ ENOSPC, "No space left on device" },
117
-	{ ENOTCONN, "Not connected" },
118
-	{ ENOTSUP, "Not supported" },
119
-	{ EPERM, "Operation not permitted" },
120
-	{ ERANGE, "Out of range" },
121
-	{ ETIMEDOUT, "Connection timed out" },
105
+	__einfo_errortab ( EINFO_ENOERR ),
106
+	__einfo_errortab ( EINFO_EACCES ),
107
+	__einfo_errortab ( EINFO_ECANCELED ),
108
+	__einfo_errortab ( EINFO_ECONNRESET ),
109
+	__einfo_errortab ( EINFO_EINVAL ),
110
+	__einfo_errortab ( EINFO_EIO ),
111
+	__einfo_errortab ( EINFO_ENETUNREACH ),
112
+	__einfo_errortab ( EINFO_ENODEV ),
113
+	__einfo_errortab ( EINFO_ENOENT ),
114
+	__einfo_errortab ( EINFO_ENOEXEC ),
115
+	__einfo_errortab ( EINFO_ENOMEM ),
116
+	__einfo_errortab ( EINFO_ENOSPC ),
117
+	__einfo_errortab ( EINFO_ENOTCONN ),
118
+	__einfo_errortab ( EINFO_ENOTSUP ),
119
+	__einfo_errortab ( EINFO_EPERM ),
120
+	__einfo_errortab ( EINFO_ERANGE ),
121
+	__einfo_errortab ( EINFO_ETIMEDOUT ),
122
 };
122
 };

+ 77
- 87
src/hci/wireless_errors.c View File

20
 
20
 
21
 #include <errno.h>
21
 #include <errno.h>
22
 #include <ipxe/errortab.h>
22
 #include <ipxe/errortab.h>
23
+#include <ipxe/net80211_err.h>
23
 
24
 
24
 /* Record errors as though they come from the 802.11 stack */
25
 /* Record errors as though they come from the 802.11 stack */
25
 #undef ERRFILE
26
 #undef ERRFILE
26
 #define ERRFILE ERRFILE_net80211
27
 #define ERRFILE ERRFILE_net80211
27
 
28
 
28
 /** All 802.11 errors
29
 /** All 802.11 errors
29
- *
30
- * These follow the 802.11 standard as much as is feasible, but most
31
- * have been abbreviated to fit the 50-character limit imposed by
32
- * strerror.
33
  */
30
  */
34
 struct errortab wireless_errors[] __errortab = {
31
 struct errortab wireless_errors[] __errortab = {
35
-	/* iPXE 802.11 stack errors */
36
-	{ EINVAL | EUNIQ_01, "Packet too short" },
37
-	{ EINVAL | EUNIQ_02, "Packet 802.11 version not supported" },
38
-	{ EINVAL | EUNIQ_03, "Packet not a data packet" },
39
-	{ EINVAL | EUNIQ_04, "Packet not from an Access Point" },
40
-	{ EINVAL | EUNIQ_05, "Packet has invalid LLC header" },
41
-	{ EINVAL | EUNIQ_06, "Packet decryption error", },
42
-	{ EINVAL | EUNIQ_07, "Invalid active scan requested" },
43
-
44
-	/* 802.11 status codes (IEEE Std 802.11-2007, Table 7-23) */
45
-	/* Maximum error length: 50 chars                                            | */
46
-	{ ECONNREFUSED | EUNIQ_01, "Unspecified failure" },
47
-	{ ECONNREFUSED | EUNIQ_0A, "Cannot support all requested capabilities" },
48
-	{ ECONNREFUSED | EUNIQ_0B, "Reassociation denied due to lack of association" },
49
-	{ ECONNREFUSED | EUNIQ_0C, "Association denied for another reason" },
50
-	{ ECONNREFUSED | EUNIQ_0D, "Authentication algorithm unsupported" },
51
-	{ ECONNREFUSED | EUNIQ_0E, "Authentication sequence number unexpected" },
52
-	{ ECONNREFUSED | EUNIQ_0F, "Authentication rejected due to challenge failure" },
53
-	{ ECONNREFUSED | EUNIQ_10, "Authentication rejected due to timeout" },
54
-	{ ECONNREFUSED | EUNIQ_11, "Association denied because AP is out of resources" },
55
-	{ ECONNREFUSED | EUNIQ_12, "Association denied; basic rate support required" },
56
-	{ ECONNREFUSED | EUNIQ_13, "Association denied; short preamble support req'd" },
57
-	{ ECONNREFUSED | EUNIQ_14, "Association denied; PBCC modulation support req'd" },
58
-	{ ECONNREFUSED | EUNIQ_15, "Association denied; Channel Agility support req'd" },
59
-	{ ECONNREFUSED | EUNIQ_16, "Association denied; Spectrum Management required" },
60
-	{ ECONNREFUSED | EUNIQ_17, "Association denied; Power Capability unacceptable" },
61
-	{ ECONNREFUSED | EUNIQ_18, "Association denied; Supported Channels unacceptable" },
62
-	{ ECONNREFUSED | EUNIQ_19, "Association denied; Short Slot Tume support req'd" },
63
-	{ ECONNREFUSED | EUNIQ_1A, "Association denied; DSSS-OFDM support required" },
64
-	{ EHOSTUNREACH,            "Unspecified, QoS-related failure" },
65
-	{ EHOSTUNREACH | EUNIQ_01, "Association denied; QoS AP out of QoS resources" },
66
-	{ EHOSTUNREACH | EUNIQ_02, "Association denied due to excessively poor link" },
67
-	{ EHOSTUNREACH | EUNIQ_03, "Association denied; QoS support required" },
68
-	{ EHOSTUNREACH | EUNIQ_05, "The request has been declined" },
69
-	{ EHOSTUNREACH | EUNIQ_06, "Request unsuccessful due to invalid parameters" },
70
-	{ EHOSTUNREACH | EUNIQ_07, "TS not created due to bad specification" },
71
-	{ EHOSTUNREACH | EUNIQ_08, "Invalid information element" },
72
-	{ EHOSTUNREACH | EUNIQ_09, "Invalid group cipher" },
73
-	{ EHOSTUNREACH | EUNIQ_0A, "Invalid pairwise cipher" },
74
-	{ EHOSTUNREACH | EUNIQ_0B, "Invalid AKMP" },
75
-	{ EHOSTUNREACH | EUNIQ_0C, "Unsupported RSN information element version" },
76
-	{ EHOSTUNREACH | EUNIQ_0D, "Invalid RSN information element capabilities" },
77
-	{ EHOSTUNREACH | EUNIQ_0E, "Cipher suite rejected because of security policy" },
78
-	{ EHOSTUNREACH | EUNIQ_0F, "TS not created due to insufficient delay" },
79
-	{ EHOSTUNREACH | EUNIQ_10, "Direct link is not allowed in the BSS by policy" },
80
-	{ EHOSTUNREACH | EUNIQ_11, "The Destination STA is not present within the BSS" },
81
-	{ EHOSTUNREACH | EUNIQ_12, "The Destination STA is not a QoS STA" },
82
-	{ EHOSTUNREACH | EUNIQ_13, "Association denied; Listen Interval is too large" },
83
-
84
-	/* 802.11 reason codes (IEEE Std 802.11-2007, Table 7-22) */
85
-	/* Maximum error length: 50 chars                                          | */
86
-	{ ECONNRESET | EUNIQ_01, "Unspecified reason" },
87
-	{ ECONNRESET | EUNIQ_02, "Previous authentication no longer valid" },
88
-	{ ECONNRESET | EUNIQ_03, "Deauthenticated due to leaving network" },
89
-	{ ECONNRESET | EUNIQ_04, "Disassociated due to inactivity" },
90
-	{ ECONNRESET | EUNIQ_05, "Disassociated because AP is out of resources" },
91
-	{ ECONNRESET | EUNIQ_06, "Class 2 frame received from nonauthenticated STA" },
92
-	{ ECONNRESET | EUNIQ_07, "Class 3 frame received from nonassociated STA" },
93
-	{ ECONNRESET | EUNIQ_08, "Disassociated due to roaming" },
94
-	{ ECONNRESET | EUNIQ_09, "STA requesting (re)association not authenticated" },
95
-	{ ECONNRESET | EUNIQ_0A, "Disassociated; Power Capability unacceptable" },
96
-	{ ECONNRESET | EUNIQ_0B, "Disassociated; Supported Channels unacceptable" },
97
-	{ ECONNRESET | EUNIQ_0D, "Invalid information element" },
98
-	{ ECONNRESET | EUNIQ_0E, "Message integrity code (MIC) failure" },
99
-	{ ECONNRESET | EUNIQ_0F, "4-Way Handshake timeout" },
100
-	{ ECONNRESET | EUNIQ_10, "Group Key Handshake timeout" },
101
-	{ ECONNRESET | EUNIQ_11, "4-Way Handshake information element changed unduly" },
102
-	{ ECONNRESET | EUNIQ_12, "Invalid group cipher" },
103
-	{ ECONNRESET | EUNIQ_13, "Invalid pairwise cipher" },
104
-	{ ECONNRESET | EUNIQ_14, "Invalid AKMP" },
105
-	{ ECONNRESET | EUNIQ_15, "Unsupported RSN information element version" },
106
-	{ ECONNRESET | EUNIQ_16, "Invalid RSN information element capabilities" },
107
-	{ ECONNRESET | EUNIQ_17, "IEEE 802.1X authentication failed" },
108
-	{ ECONNRESET | EUNIQ_18, "Cipher suite rejected because of security policy" },
109
-	{ ENETRESET,            "Disassociated for unspecified, QoS-related reason" },
110
-	{ ENETRESET | EUNIQ_01, "Disassociated; QoS AP is out of QoS resources" },
111
-	{ ENETRESET | EUNIQ_02, "Disassociated due to excessively poor link" },
112
-	{ ENETRESET | EUNIQ_03, "Disassociated due to TXOP limit violation" },
113
-	{ ENETRESET | EUNIQ_04, "Requested; STA is leaving the BSS (or resetting)" },
114
-	{ ENETRESET | EUNIQ_05, "Requested; does not want to use the mechanism" },
115
-	{ ENETRESET | EUNIQ_06, "Requested; setup is required" },
116
-	{ ENETRESET | EUNIQ_07, "Requested from peer STA due to timeout" },
117
-	{ ENETRESET | EUNIQ_0D, "Peer STA does not support requested cipher suite" },
32
+	__einfo_errortab ( EINFO_EINVAL_PKT_TOO_SHORT ),
33
+	__einfo_errortab ( EINFO_EINVAL_PKT_VERSION ),
34
+	__einfo_errortab ( EINFO_EINVAL_PKT_NOT_DATA ),
35
+	__einfo_errortab ( EINFO_EINVAL_PKT_NOT_FROMDS ),
36
+	__einfo_errortab ( EINFO_EINVAL_PKT_LLC_HEADER ),
37
+	__einfo_errortab ( EINFO_EINVAL_CRYPTO_REQUEST ),
38
+	__einfo_errortab ( EINFO_EINVAL_ACTIVE_SCAN ),
39
+	__einfo_errortab ( EINFO_ECONNREFUSED_FAILURE ),
40
+	__einfo_errortab ( EINFO_ECONNREFUSED_CAPAB_UNSUPP ),
41
+	__einfo_errortab ( EINFO_ECONNREFUSED_REASSOC_INVALID ),
42
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_DENIED ),
43
+	__einfo_errortab ( EINFO_ECONNREFUSED_AUTH_ALGO_UNSUPP ),
44
+	__einfo_errortab ( EINFO_ECONNREFUSED_AUTH_SEQ_INVALID ),
45
+	__einfo_errortab ( EINFO_ECONNREFUSED_AUTH_CHALL_INVALID ),
46
+	__einfo_errortab ( EINFO_ECONNREFUSED_AUTH_TIMEOUT ),
47
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_NO_ROOM ),
48
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_NEED_RATE ),
49
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_NEED_SHORT_PMBL ),
50
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_NEED_PBCC ),
51
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_NEED_CHAN_AGILITY ),
52
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_NEED_SPECTRUM_MGMT ),
53
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_BAD_POWER ),
54
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_BAD_CHANNELS ),
55
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_NEED_SHORT_SLOT ),
56
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_NEED_DSSS_OFDM ),
57
+	__einfo_errortab ( EINFO_EHOSTUNREACH_QOS_FAILURE ),
58
+	__einfo_errortab ( EINFO_EHOSTUNREACH_QOS_NO_ROOM ),
59
+	__einfo_errortab ( EINFO_EHOSTUNREACH_LINK_IS_HORRIBLE ),
60
+	__einfo_errortab ( EINFO_EHOSTUNREACH_ASSOC_NEED_QOS ),
61
+	__einfo_errortab ( EINFO_EHOSTUNREACH_REQUEST_DECLINED ),
62
+	__einfo_errortab ( EINFO_EHOSTUNREACH_REQUEST_INVALID ),
63
+	__einfo_errortab ( EINFO_EHOSTUNREACH_TS_NOT_CREATED_AGAIN ),
64
+	__einfo_errortab ( EINFO_EHOSTUNREACH_INVALID_IE ),
65
+	__einfo_errortab ( EINFO_EHOSTUNREACH_GROUP_CIPHER_INVALID ),
66
+	__einfo_errortab ( EINFO_EHOSTUNREACH_PAIR_CIPHER_INVALID ),
67
+	__einfo_errortab ( EINFO_EHOSTUNREACH_AKMP_INVALID ),
68
+	__einfo_errortab ( EINFO_EHOSTUNREACH_RSN_VERSION_UNSUPP ),
69
+	__einfo_errortab ( EINFO_EHOSTUNREACH_RSN_CAPAB_INVALID ),
70
+	__einfo_errortab ( EINFO_EHOSTUNREACH_CIPHER_REJECTED ),
71
+	__einfo_errortab ( EINFO_EHOSTUNREACH_TS_NOT_CREATED_WAIT ),
72
+	__einfo_errortab ( EINFO_EHOSTUNREACH_DIRECT_LINK_FORBIDDEN ),
73
+	__einfo_errortab ( EINFO_EHOSTUNREACH_DEST_NOT_PRESENT ),
74
+	__einfo_errortab ( EINFO_EHOSTUNREACH_DEST_NOT_QOS ),
75
+	__einfo_errortab ( EINFO_EHOSTUNREACH_ASSOC_LISTEN_TOO_HIGH ),
76
+	__einfo_errortab ( EINFO_ECONNRESET_UNSPECIFIED ),
77
+	__einfo_errortab ( EINFO_ECONNRESET_AUTH_NO_LONGER_VALID ),
78
+	__einfo_errortab ( EINFO_ECONNRESET_LEAVING ),
79
+	__einfo_errortab ( EINFO_ECONNRESET_INACTIVITY ),
80
+	__einfo_errortab ( EINFO_ECONNRESET_OUT_OF_RESOURCES ),
81
+	__einfo_errortab ( EINFO_ECONNRESET_NEED_AUTH ),
82
+	__einfo_errortab ( EINFO_ECONNRESET_NEED_ASSOC ),
83
+	__einfo_errortab ( EINFO_ECONNRESET_LEAVING_TO_ROAM ),
84
+	__einfo_errortab ( EINFO_ECONNRESET_REASSOC_INVALID ),
85
+	__einfo_errortab ( EINFO_ECONNRESET_BAD_POWER ),
86
+	__einfo_errortab ( EINFO_ECONNRESET_BAD_CHANNELS ),
87
+	__einfo_errortab ( EINFO_ECONNRESET_INVALID_IE ),
88
+	__einfo_errortab ( EINFO_ECONNRESET_MIC_FAILURE ),
89
+	__einfo_errortab ( EINFO_ECONNRESET_4WAY_TIMEOUT ),
90
+	__einfo_errortab ( EINFO_ECONNRESET_GROUPKEY_TIMEOUT ),
91
+	__einfo_errortab ( EINFO_ECONNRESET_4WAY_INVALID ),
92
+	__einfo_errortab ( EINFO_ECONNRESET_GROUP_CIPHER_INVALID ),
93
+	__einfo_errortab ( EINFO_ECONNRESET_PAIR_CIPHER_INVALID ),
94
+	__einfo_errortab ( EINFO_ECONNRESET_AKMP_INVALID ),
95
+	__einfo_errortab ( EINFO_ECONNRESET_RSN_VERSION_INVALID ),
96
+	__einfo_errortab ( EINFO_ECONNRESET_RSN_CAPAB_INVALID ),
97
+	__einfo_errortab ( EINFO_ECONNRESET_8021X_FAILURE ),
98
+	__einfo_errortab ( EINFO_ECONNRESET_CIPHER_REJECTED ),
99
+	__einfo_errortab ( EINFO_ENETRESET_QOS_UNSPECIFIED ),
100
+	__einfo_errortab ( EINFO_ENETRESET_QOS_OUT_OF_RESOURCES ),
101
+	__einfo_errortab ( EINFO_ENETRESET_LINK_IS_HORRIBLE ),
102
+	__einfo_errortab ( EINFO_ENETRESET_INVALID_TXOP ),
103
+	__einfo_errortab ( EINFO_ENETRESET_REQUESTED_LEAVING ),
104
+	__einfo_errortab ( EINFO_ENETRESET_REQUESTED_NO_USE ),
105
+	__einfo_errortab ( EINFO_ENETRESET_REQUESTED_NEED_SETUP ),
106
+	__einfo_errortab ( EINFO_ENETRESET_REQUESTED_TIMEOUT ),
107
+	__einfo_errortab ( EINFO_ENETRESET_CIPHER_UNSUPPORTED ),
118
 };
108
 };

+ 14
- 11
src/image/segment.c View File

31
 #include <ipxe/errortab.h>
31
 #include <ipxe/errortab.h>
32
 #include <ipxe/segment.h>
32
 #include <ipxe/segment.h>
33
 
33
 
34
+/**
35
+ * Segment-specific error messages
36
+ *
37
+ * This error happens sufficiently often to merit a user-friendly
38
+ * description.
39
+ */
40
+#define ERANGE_SEGMENT __einfo_error ( EINFO_ERANGE_SEGMENT )
41
+#define EINFO_ERANGE_SEGMENT \
42
+	__einfo_uniqify ( EINFO_ERANGE, 0x01, "Requested memory not available" )
43
+struct errortab segment_errors[] __errortab = {
44
+	__einfo_errortab ( EINFO_ERANGE_SEGMENT ),
45
+};
46
+
34
 /**
47
 /**
35
  * Prepare segment for loading
48
  * Prepare segment for loading
36
  *
49
  *
73
 	/* No suitable memory region found */
86
 	/* No suitable memory region found */
74
 	DBG ( "Segment [%lx,%lx,%lx) does not fit into available memory\n",
87
 	DBG ( "Segment [%lx,%lx,%lx) does not fit into available memory\n",
75
 	      start, mid, end );
88
 	      start, mid, end );
76
-	return -ERANGE;
89
+	return -ERANGE_SEGMENT;
77
 }
90
 }
78
-
79
-/**
80
- * Segment-specific error messages
81
- *
82
- * This error happens sufficiently often to merit a user-friendly
83
- * description.
84
- */
85
-struct errortab segment_errors[] __errortab = {
86
-	{ ERANGE, "Requested memory not available" },
87
-};

+ 409
- 158
src/include/errno.h View File

1
+/*
2
+ * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
1
 #ifndef ERRNO_H
19
 #ifndef ERRNO_H
2
 #define ERRNO_H
20
 #define ERRNO_H
3
 
21
 
40
  *
58
  *
41
  *
59
  *
42
  * The convention within the code is that errors are negative and
60
  * The convention within the code is that errors are negative and
43
- * expressed using the POSIX error code and (optionally) a per-file
44
- * disambiguator, e.g.
61
+ * expressed using the POSIX error, e.g.
45
  *
62
  *
46
  *     return -EINVAL;
63
  *     return -EINVAL;
47
  *
64
  *
48
- * or
49
- *
50
- *     #define ETCP_BAD_CHECKSUM EUNIQ_02
51
- *     return -( EINVAL | ETCP_BAD_CHECKSUM )
52
- *
53
  * By various bits of preprocessor magic, the PXE error code and file
65
  * By various bits of preprocessor magic, the PXE error code and file
54
  * identifier are already incorporated into the definition of the
66
  * identifier are already incorporated into the definition of the
55
- * POSIX error code, which keeps the code relatively clean.
67
+ * POSIX error macro, which keeps the code relatively clean.
56
  *
68
  *
57
  *
69
  *
58
  * Functions that wish to return failures should be declared as
70
  * Functions that wish to return failures should be declared as
69
  * As illustrated in the above example, error returns should generally
81
  * As illustrated in the above example, error returns should generally
70
  * be directly propagated upward to the calling function.
82
  * be directly propagated upward to the calling function.
71
  *
83
  *
84
+ *
85
+ * Individual files may declare localised errors using
86
+ * __einfo_uniqify().  For example, iscsi.c declares a localised
87
+ * version of EACCES for the error of "access denied due to incorrect
88
+ * target username":
89
+ *
90
+ *     #define EACCES_INCORRECT_TARGET_USERNAME	\
91
+ *         __einfo_error ( EINFO_EACCES_INCORRECT_TARGET_USERNAME )
92
+ *     #define EINFO_EACCES_INCORRECT_TARGET_USERNAME \
93
+ *         __einfo_uniqify ( EINFO_EACCESS, 0x01, "Incorrect target username" )
94
+ *
95
+ * which can then be used as:
96
+ *
97
+ *     return -EACCES_INCORRECT_TARGET_USERNAME;
98
+ *
72
  */
99
  */
73
 
100
 
74
 /* Get definitions for file identifiers */
101
 /* Get definitions for file identifiers */
85
 #define ERRFILE ( 0 * ( ( int ) missing_errfile_declaration ) )
112
 #define ERRFILE ( 0 * ( ( int ) missing_errfile_declaration ) )
86
 #endif
113
 #endif
87
 
114
 
88
-/** Derive PXENV_STATUS code from iPXE error number */
89
-#define PXENV_STATUS( rc ) ( (-(rc)) & 0x00ff )
115
+/**
116
+ * Declare error information
117
+ *
118
+ * @v pxe		PXE error number (0x00-0xff)
119
+ * @v posix		POSIX error number (0x00-0x7f)
120
+ * @v uniq		Error disambiguator (0x00-0x1f)
121
+ * @v desc		Error description
122
+ * @ret einfo		Error information
123
+ */
124
+#define __einfo( pxe, posix, uniq, desc ) ( pxe, posix, uniq, desc )
125
+
126
+/**
127
+ * Get PXE error number
128
+ *
129
+ * @v einfo		Error information
130
+ * @ret pxe		PXE error number
131
+ */
132
+#define __einfo_pxe( einfo ) __einfo_extract_pxe einfo
133
+#define __einfo_extract_pxe( pxe, posix, uniq, desc ) pxe
134
+
135
+/**
136
+ * Get POSIX error number
137
+ *
138
+ * @v einfo		Error information
139
+ * @ret posix		POSIX error number
140
+ */
141
+#define __einfo_posix( einfo ) __einfo_extract_posix einfo
142
+#define __einfo_extract_posix( pxe, posix, uniq, desc ) posix
143
+
144
+/**
145
+ * Get error disambiguator
146
+ *
147
+ * @v einfo		Error information
148
+ * @ret uniq		Error disambiguator
149
+ */
150
+#define __einfo_uniq( einfo ) __einfo_extract_uniq einfo
151
+#define __einfo_extract_uniq( pxe, posix, uniq, desc ) uniq
152
+
153
+/**
154
+ * Get error description
155
+ *
156
+ * @v einfo		Error information
157
+ * @ret desc		Error description
158
+ */
159
+#define __einfo_desc( einfo ) __einfo_extract_desc einfo
160
+#define __einfo_extract_desc( pxe, posix, uniq, desc ) desc
161
+
162
+/**
163
+ * Declare disambiguated error
164
+ *
165
+ * @v einfo_base	Base error information
166
+ * @v uniq		Error disambiguator
167
+ * @v desc		Error description
168
+ * @ret einfo		Error information
169
+ */
170
+#define __einfo_uniqify( einfo_base, uniq, desc )			\
171
+	__einfo ( __einfo_pxe ( einfo_base ),				\
172
+		  __einfo_posix ( einfo_base ),				\
173
+		  uniq, desc )
174
+
175
+/**
176
+ * Get error number
177
+ *
178
+ * @v einfo		Error information
179
+ * @ret errno		Error number
180
+ */
181
+#define __einfo_errno( einfo )						\
182
+	( ( __einfo_posix ( einfo ) << 24 ) | ( ERRFILE ) |		\
183
+	  ( __einfo_uniq ( einfo ) << 8 ) |				\
184
+	  ( __einfo_pxe ( einfo ) << 0 ) )
185
+
186
+/**
187
+ * Disambiguate a base error based on non-constant information
188
+ *
189
+ * @v error_base	Base error
190
+ * @v uniq		Error disambiguator
191
+ * @v ...		List of expected possible disambiguated errors
192
+ * @ret error		Error
193
+ *
194
+ * EUNIQ() should be used when information from an external source is
195
+ * being incorporated into an error.  For example, the 802.11 stack
196
+ * uses EUNIQ() to incorporate 802.11 status codes returned by an
197
+ * access point into an error.
198
+ *
199
+ * EUNIQ() should not be used for constant error disambiguators; use
200
+ * __einfo_uniqify() instead.
201
+ */
202
+#define EUNIQ( errno, uniq, ... ) ( {					\
203
+	euniq_discard ( 0, ##__VA_ARGS__);				\
204
+	( (errno) | ( (uniq) << 8 ) ); } )
205
+static inline void euniq_discard ( int dummy __unused, ... ) {}
206
+
207
+/**
208
+ * Declare error
209
+ *
210
+ * @v einfo		Error information
211
+ * @ret error		Error
212
+ */
213
+#define __einfo_error( einfo ) ( {					\
214
+	__asm__ ( ".section \".einfo\", \"\", @progbits\n\t"		\
215
+		  ".align 8\n\t"					\
216
+		  "\n1:\n\t"						\
217
+		  ".long ( 4f - 1b )\n\t"				\
218
+		  ".long %c0\n\t"					\
219
+		  ".long ( 2f - 1b )\n\t"				\
220
+		  ".long ( 3f - 1b )\n\t"				\
221
+		  ".long %c1\n\t"					\
222
+		  "\n2:\t.asciz \"" __einfo_desc ( einfo ) "\"\n\t"	\
223
+		  "\n3:\t.asciz \"" __FILE__ "\"\n\t"			\
224
+		  ".align 8\n\t"					\
225
+		  "\n4:\n\t"						\
226
+		  ".previous\n\t" : :					\
227
+		  "i" ( __einfo_errno ( einfo) ),			\
228
+		  "i" ( __LINE__ ) );					\
229
+	__einfo_errno ( einfo ); } )
90
 
230
 
91
 /**
231
 /**
92
  * @defgroup pxeerrors PXE error codes
232
  * @defgroup pxeerrors PXE error codes
199
 
339
 
200
 /** @} */
340
 /** @} */
201
 
341
 
342
+/** Derive PXENV_STATUS code from iPXE error number */
343
+#define PXENV_STATUS( rc ) ( (-(rc)) & 0x00ff )
344
+
202
 /**
345
 /**
203
  * @defgroup posixerrors POSIX error codes
346
  * @defgroup posixerrors POSIX error codes
204
  *
347
  *
205
  * The names and meanings (but not the values) of these error codes
348
  * The names and meanings (but not the values) of these error codes
206
- * are defined by POSIX.  We choose to assign unique values which
207
- * incorporate the closest equivalent PXE error code, so that code may
208
- * simply use ENOMEM, rather than having to use the cumbersome
209
- * (ENOMEM|PXENV_STATUS_OUT_OF_RESOURCES).
349
+ * are defined by POSIX.
210
  *
350
  *
211
  * @{
351
  * @{
212
  */
352
  */
213
 
353
 
214
 /** Operation completed successfully */
354
 /** Operation completed successfully */
215
-#define ENOERR			( ERRFILE | PXENV_STATUS_SUCCESS | 0x00000000 )
355
+#define ENOERR __einfo_error ( EINFO_ENOERR )
356
+#define EINFO_ENOERR __einfo ( PXENV_STATUS_SUCCESS, 0x00, 0, \
357
+			       "Operation completed successfully" )
216
 
358
 
217
-/** Arg list too long */
218
-#define E2BIG		       ( ERRFILE | PXENV_STATUS_BAD_FUNC | 0x01000000 )
359
+/** Argument list too long */
360
+#define E2BIG __einfo_error ( EINFO_E2BIG )
361
+#define EINFO_E2BIG __einfo ( PXENV_STATUS_BAD_FUNC, 0x01, 0, \
362
+			      "Argument list too long" )
219
 
363
 
220
 /** Permission denied */
364
 /** Permission denied */
221
-#define EACCES	  ( ERRFILE | PXENV_STATUS_TFTP_ACCESS_VIOLATION | 0x02000000 )
365
+#define EACCES __einfo_error ( EINFO_EACCES )
366
+#define EINFO_EACCES __einfo ( PXENV_STATUS_TFTP_ACCESS_VIOLATION, 0x02, 0, \
367
+			       "Permission denied" )
222
 
368
 
223
-/** Address in use */
224
-#define EADDRINUSE	       ( ERRFILE | PXENV_STATUS_UDP_OPEN | 0x03000000 )
369
+/** Address already in use */
370
+#define EADDRINUSE __einfo_error ( EINFO_EADDRINUSE )
371
+#define EINFO_EADDRINUSE __einfo ( PXENV_STATUS_UDP_OPEN, 0x03, 0, \
372
+				   "Address already in use" )
225
 
373
 
226
 /** Address not available */
374
 /** Address not available */
227
-#define EADDRNOTAVAIL	       ( ERRFILE | PXENV_STATUS_UDP_OPEN | 0x04000000 )
375
+#define EADDRNOTAVAIL __einfo_error ( EINFO_EADDRNOTAVAIL )
376
+#define EINFO_EADDRNOTAVAIL __einfo ( PXENV_STATUS_UDP_OPEN, 0x04, 0, \
377
+				      "Address not available" )
228
 
378
 
229
 /** Address family not supported */
379
 /** Address family not supported */
230
-#define EAFNOSUPPORT	    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x05000000 )
380
+#define EAFNOSUPPORT __einfo_error ( EINFO_EAFNOSUPPORT )
381
+#define EINFO_EAFNOSUPPORT __einfo ( PXENV_STATUS_UNSUPPORTED, 0x05, 0, \
382
+				     "Address family not supported" )
231
 
383
 
232
 /** Resource temporarily unavailable */
384
 /** Resource temporarily unavailable */
233
-#define EAGAIN			( ERRFILE | PXENV_STATUS_FAILURE | 0x06000000 )
385
+#define EAGAIN __einfo_error ( EINFO_EAGAIN )
386
+#define EINFO_EAGAIN __einfo ( PXENV_STATUS_FAILURE, 0x06, 0, \
387
+			       "Resource temporarily unavailable" )
234
 
388
 
235
 /** Connection already in progress */
389
 /** Connection already in progress */
236
-#define EALREADY	       ( ERRFILE | PXENV_STATUS_UDP_OPEN | 0x07000000 )
390
+#define EALREADY __einfo_error ( EINFO_EALREADY )
391
+#define EINFO_EALREADY __einfo ( PXENV_STATUS_UDP_OPEN, 0x07, 0, \
392
+				 "Connection already in progress" )
237
 
393
 
238
 /** Bad file descriptor */
394
 /** Bad file descriptor */
239
-#define EBADF		    ( ERRFILE | PXENV_STATUS_TFTP_CLOSED | 0x08000000 )
395
+#define EBADF __einfo_error ( EINFO_EBADF )
396
+#define EINFO_EBADF __einfo ( PXENV_STATUS_TFTP_CLOSED, 0x08, 0, \
397
+			      "Bad file descriptor" )
240
 
398
 
241
 /** Bad message */
399
 /** Bad message */
242
-#define EBADMSG			( ERRFILE | PXENV_STATUS_FAILURE | 0x09000000 )
400
+#define EBADMSG __einfo_error ( EINFO_EBADMSG )
401
+#define EINFO_EBADMSG __einfo ( PXENV_STATUS_FAILURE, 0x09, 0, \
402
+				"Bad message" )
243
 
403
 
244
-/** Resource busy */
245
-#define EBUSY	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x0a000000 )
404
+/** Device or resource busy */
405
+#define EBUSY __einfo_error ( EINFO_EBUSY )
406
+#define EINFO_EBUSY __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x0a, 0, \
407
+			      "Device or resource busy" )
246
 
408
 
247
 /** Operation canceled */
409
 /** Operation canceled */
248
-#define ECANCELED \
249
-	     ( ERRFILE | PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE | 0x0b000000 )
410
+#define ECANCELED __einfo_error ( EINFO_ECANCELED )
411
+#define EINFO_ECANCELED __einfo ( PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE, \
412
+				  0x0b, 0, "Operation canceled" )
250
 
413
 
251
 /** No child processes */
414
 /** No child processes */
252
-#define ECHILD	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x0c000000 )
415
+#define ECHILD __einfo_error ( EINFO_ECHILD )
416
+#define EINFO_ECHILD __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x0c, 0, \
417
+			       "No child processes" )
253
 
418
 
254
 /** Connection aborted */
419
 /** Connection aborted */
255
-#define ECONNABORTED \
256
-       ( ERRFILE | PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x0d000000 )
420
+#define ECONNABORTED __einfo_error ( EINFO_ECONNABORTED )
421
+#define EINFO_ECONNABORTED						  \
422
+	__einfo ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION, 0x0d, 0, \
423
+		  "Connection aborted" )
257
 
424
 
258
 /** Connection refused */
425
 /** Connection refused */
259
-#define ECONNREFUSED \
260
-	    ( ERRFILE | PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION | 0x0e000000 )
426
+#define ECONNREFUSED __einfo_error ( EINFO_ECONNREFUSED )
427
+#define EINFO_ECONNREFUSED __einfo ( PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION, \
428
+				     0x0e, 0, "Connection refused" )
261
 
429
 
262
 /** Connection reset */
430
 /** Connection reset */
263
-#define ECONNRESET \
264
-       ( ERRFILE | PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x0f000000 )
431
+#define ECONNRESET __einfo_error ( EINFO_ECONNRESET )
432
+#define EINFO_ECONNRESET						  \
433
+	__einfo ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION, 0x0f, 0, \
434
+		  "Connection reset" )
265
 
435
 
266
 /** Resource deadlock avoided */
436
 /** Resource deadlock avoided */
267
-#define EDEADLK			( ERRFILE | PXENV_STATUS_FAILURE | 0x10000000 )
437
+#define EDEADLK __einfo_error ( EINFO_EDEADLK )
438
+#define EINFO_EDEADLK __einfo ( PXENV_STATUS_FAILURE, 0x10, 0, \
439
+				"Resource deadlock avoided" )
268
 
440
 
269
 /** Destination address required */
441
 /** Destination address required */
270
-#define EDESTADDRREQ	       ( ERRFILE | PXENV_STATUS_BAD_FUNC | 0x11000000 )
442
+#define EDESTADDRREQ __einfo_error ( EINFO_EDESTADDRREQ )
443
+#define EINFO_EDESTADDRREQ __einfo ( PXENV_STATUS_BAD_FUNC, 0x11, 0, \
444
+				     "Destination address required" )
271
 
445
 
272
-/** Domain error */
273
-#define EDOM			( ERRFILE | PXENV_STATUS_FAILURE | 0x12000000 )
446
+/** Mathematics argument out of domain of function */
447
+#define EDOM __einfo_error ( EINFO_EDOM )
448
+#define EINFO_EDOM __einfo ( PXENV_STATUS_FAILURE, 0x12, 0, \
449
+			     "Mathematics argument out of domain of function" )
274
 
450
 
275
-/** Reserved */
276
-#define EDQUOT			( ERRFILE | PXENV_STATUS_FAILURE | 0x13000000 )
451
+/** Disk quota exceeded */
452
+#define EDQUOT __einfo_error ( EINFO_EDQUOT )
453
+#define EINFO_EDQUOT __einfo ( PXENV_STATUS_FAILURE, 0x13, 0, \
454
+			       "Disk quote exceeded" )
277
 
455
 
278
 /** File exists */
456
 /** File exists */
279
-#define EEXIST			( ERRFILE | PXENV_STATUS_FAILURE | 0x14000000 )
457
+#define EEXIST __einfo_error ( EINFO_EEXIST )
458
+#define EINFO_EEXIST __einfo ( PXENV_STATUS_FAILURE, 0x14, 0, \
459
+			       "File exists" )
280
 
460
 
281
 /** Bad address */
461
 /** Bad address */
282
-#define EFAULT		  ( ERRFILE | PXENV_STATUS_MCOPY_PROBLEM | 0x15000000 )
462
+#define EFAULT __einfo_error ( EINFO_EFAULT )
463
+#define EINFO_EFAULT __einfo ( PXENV_STATUS_MCOPY_PROBLEM, 0x15, 0, \
464
+			       "Bad address" )
283
 
465
 
284
 /** File too large */
466
 /** File too large */
285
-#define EFBIG		  ( ERRFILE | PXENV_STATUS_MCOPY_PROBLEM | 0x16000000 )
467
+#define EFBIG __einfo_error ( EINFO_EFBIG )
468
+#define EINFO_EFBIG __einfo ( PXENV_STATUS_MCOPY_PROBLEM, 0x16, 0, \
469
+			      "File too large" )
286
 
470
 
287
 /** Host is unreachable */
471
 /** Host is unreachable */
288
-#define EHOSTUNREACH	    ( ERRFILE | PXENV_STATUS_ARP_TIMEOUT | 0x17000000 )
472
+#define EHOSTUNREACH __einfo_error ( EINFO_EHOSTUNREACH )
473
+#define EINFO_EHOSTUNREACH __einfo ( PXENV_STATUS_ARP_TIMEOUT, 0x17, 0, \
474
+				     "Host is unreachable" )
289
 
475
 
290
 /** Identifier removed */
476
 /** Identifier removed */
291
-#define EIDRM			( ERRFILE | PXENV_STATUS_FAILURE | 0x18000000 )
477
+#define EIDRM __einfo_error ( EINFO_EIDRM )
478
+#define EINFO_EIDRM __einfo ( PXENV_STATUS_FAILURE, 0x18, 0, \
479
+			      "Identifier removed" )
292
 
480
 
293
 /** Illegal byte sequence */
481
 /** Illegal byte sequence */
294
-#define EILSEQ			( ERRFILE | PXENV_STATUS_FAILURE | 0x19000000 )
482
+#define EILSEQ __einfo_error ( EINFO_EILSEQ )
483
+#define EINFO_EILSEQ __einfo ( PXENV_STATUS_FAILURE, 0x19, 0, \
484
+			       "Illegal byte sequence" )
295
 
485
 
296
 /** Operation in progress */
486
 /** Operation in progress */
297
-#define EINPROGRESS		( ERRFILE | PXENV_STATUS_FAILURE | 0x1a000000 )
487
+#define EINPROGRESS __einfo_error ( EINFO_EINPROGRESS )
488
+#define EINFO_EINPROGRESS __einfo ( PXENV_STATUS_FAILURE, 0x1a, 0, \
489
+				    "Operation in progress" )
298
 
490
 
299
 /** Interrupted function call */
491
 /** Interrupted function call */
300
-#define EINTR			( ERRFILE | PXENV_STATUS_FAILURE | 0x1b000000 )
492
+#define EINTR __einfo_error ( EINFO_EINTR )
493
+#define EINFO_EINTR __einfo ( PXENV_STATUS_FAILURE, 0x1b, 0, \
494
+			      "Interrupted function call" )
301
 
495
 
302
 /** Invalid argument */
496
 /** Invalid argument */
303
-#define EINVAL		       ( ERRFILE | PXENV_STATUS_BAD_FUNC | 0x1c000000 )
497
+#define EINVAL __einfo_error ( EINFO_EINVAL )
498
+#define EINFO_EINVAL __einfo ( PXENV_STATUS_BAD_FUNC, 0x1c, 0, \
499
+			       "Invalid argument" )
304
 
500
 
305
 /** Input/output error */
501
 /** Input/output error */
306
-#define EIO \
307
-       ( ERRFILE | PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION | 0x1d000000 )
502
+#define EIO __einfo_error ( EINFO_EIO )
503
+#define EINFO_EIO __einfo ( PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION, \
504
+			    0x1d, 0, "Input/output error" )
308
 
505
 
309
 /** Socket is connected */
506
 /** Socket is connected */
310
-#define EISCONN		       ( ERRFILE | PXENV_STATUS_UDP_OPEN | 0x1e000000 )
507
+#define EISCONN __einfo_error ( EINFO_EISCONN )
508
+#define EINFO_EISCONN __einfo ( PXENV_STATUS_UDP_OPEN, 0x1e, 0, \
509
+				"Socket is connected" )
311
 
510
 
312
 /** Is a directory */
511
 /** Is a directory */
313
-#define EISDIR			( ERRFILE | PXENV_STATUS_FAILURE | 0x1f000000 )
512
+#define EISDIR __einfo_error ( EINFO_EISDIR )
513
+#define EINFO_EISDIR __einfo ( PXENV_STATUS_FAILURE, 0x1f, 0, \
514
+			       "Is a directory" )
314
 
515
 
315
 /** Too many levels of symbolic links */
516
 /** Too many levels of symbolic links */
316
-#define ELOOP			( ERRFILE | PXENV_STATUS_FAILURE | 0x20000000 )
517
+#define ELOOP __einfo_error ( EINFO_ELOOP )
518
+#define EINFO_ELOOP __einfo ( PXENV_STATUS_FAILURE, 0x20, 0, \
519
+			      "Too many levels of symbolic links" )
317
 
520
 
318
 /** Too many open files */
521
 /** Too many open files */
319
-#define EMFILE	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x21000000 )
522
+#define EMFILE __einfo_error ( EINFO_EMFILE )
523
+#define EINFO_EMFILE __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x21, 0, \
524
+			       "Too many open files" )
320
 
525
 
321
 /** Too many links */
526
 /** Too many links */
322
-#define EMLINK			( ERRFILE | PXENV_STATUS_FAILURE | 0x22000000 )
527
+#define EMLINK __einfo_error ( EINFO_EMLINK )
528
+#define EINFO_EMLINK __einfo ( PXENV_STATUS_FAILURE, 0x22, 0, \
529
+			       "Too many links" )
323
 
530
 
324
-/** Inappropriate message buffer length */
325
-#define EMSGSIZE	       ( ERRFILE | PXENV_STATUS_BAD_FUNC | 0x23000000 )
531
+/** Message too long */
532
+#define EMSGSIZE __einfo_error ( EINFO_EMSGSIZE )
533
+#define EINFO_EMSGSIZE __einfo ( PXENV_STATUS_BAD_FUNC, 0x23, 0, \
534
+				 "Message too long" )
326
 
535
 
327
-/** Reserved */
328
-#define EMULTIHOP		( ERRFILE | PXENV_STATUS_FAILURE | 0x24000000 )
536
+/** Multihop attempted */
537
+#define EMULTIHOP __einfo_error ( EINFO_EMULTIHOP )
538
+#define EINFO_EMULTIHOP __einfo ( PXENV_STATUS_FAILURE, 0x24, 0, \
539
+				  "Multihop attempted" )
329
 
540
 
330
 /** Filename too long */
541
 /** Filename too long */
331
-#define ENAMETOOLONG		( ERRFILE | PXENV_STATUS_FAILURE | 0x25000000 )
542
+#define ENAMETOOLONG __einfo_error ( EINFO_ENAMETOOLONG )
543
+#define EINFO_ENAMETOOLONG __einfo ( PXENV_STATUS_FAILURE, 0x25, 0, \
544
+				     "Filename too long" )
332
 
545
 
333
 /** Network is down */
546
 /** Network is down */
334
-#define ENETDOWN	    ( ERRFILE | PXENV_STATUS_ARP_TIMEOUT | 0x26000000 )
547
+#define ENETDOWN __einfo_error ( EINFO_ENETDOWN )
548
+#define EINFO_ENETDOWN __einfo ( PXENV_STATUS_ARP_TIMEOUT, 0x26, 0, \
549
+				 "Network is down" )
335
 
550
 
336
 /** Connection aborted by network */
551
 /** Connection aborted by network */
337
-#define ENETRESET		( ERRFILE | PXENV_STATUS_FAILURE | 0x27000000 )
552
+#define ENETRESET __einfo_error ( EINFO_ENETRESET )
553
+#define EINFO_ENETRESET __einfo ( PXENV_STATUS_FAILURE, 0x27, 0, \
554
+				  "Connection aborted by network" )
338
 
555
 
339
 /** Network unreachable */
556
 /** Network unreachable */
340
-#define ENETUNREACH	    ( ERRFILE | PXENV_STATUS_ARP_TIMEOUT | 0x28000000 )
557
+#define ENETUNREACH __einfo_error ( EINFO_ENETUNREACH )
558
+#define EINFO_ENETUNREACH __einfo ( PXENV_STATUS_ARP_TIMEOUT, 0x28, 0, \
559
+				    "Network unreachable" )
341
 
560
 
342
 /** Too many open files in system */
561
 /** Too many open files in system */
343
-#define ENFILE	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x29000000 )
562
+#define ENFILE __einfo_error ( EINFO_ENFILE )
563
+#define EINFO_ENFILE __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x29, 0, \
564
+			       "Too many open files in system" )
344
 
565
 
345
 /** No buffer space available */
566
 /** No buffer space available */
346
-#define ENOBUFS	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x2a000000 )
567
+#define ENOBUFS __einfo_error ( EINFO_ENOBUFS )
568
+#define EINFO_ENOBUFS __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x2a, 0, \
569
+				"No buffer space available" )
347
 
570
 
348
 /** No message is available on the STREAM head read queue */
571
 /** No message is available on the STREAM head read queue */
349
-#define ENODATA			( ERRFILE | PXENV_STATUS_FAILURE | 0x2b000000 )
572
+#define ENODATA __einfo_error ( EINFO_ENODATA )
573
+#define EINFO_ENODATA				 \
574
+	__einfo ( PXENV_STATUS_FAILURE, 0x2b, 0, \
575
+		  "No message is available on the STREAM head read queue" )
350
 
576
 
351
 /** No such device */
577
 /** No such device */
352
-#define ENODEV	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x2c000000 )
578
+#define ENODEV __einfo_error ( EINFO_ENODEV )
579
+#define EINFO_ENODEV __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x2c, 0, \
580
+			       "No such device" )
353
 
581
 
354
 /** No such file or directory */
582
 /** No such file or directory */
355
-#define ENOENT	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x2d000000 )
583
+#define ENOENT __einfo_error ( EINFO_ENOENT )
584
+#define EINFO_ENOENT __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x2d, 0, \
585
+			       "No such file or directory" )
356
 
586
 
357
 /** Exec format error */
587
 /** Exec format error */
358
-#define ENOEXEC			( ERRFILE | PXENV_STATUS_FAILURE | 0x2e000000 )
588
+#define ENOEXEC __einfo_error ( EINFO_ENOEXEC )
589
+#define EINFO_ENOEXEC __einfo ( PXENV_STATUS_FAILURE, 0x2e, 0, \
590
+				"Exec format error" )
359
 
591
 
360
 /** No locks available */
592
 /** No locks available */
361
-#define ENOLCK			( ERRFILE | PXENV_STATUS_FAILURE | 0x2f000000 )
593
+#define ENOLCK __einfo_error ( EINFO_ENOLCK )
594
+#define EINFO_ENOLCK __einfo ( PXENV_STATUS_FAILURE, 0x2f, 0, \
595
+			       "No locks available" )
362
 
596
 
363
-/** Reserved */
364
-#define ENOLINK			( ERRFILE | PXENV_STATUS_FAILURE | 0x30000000 )
597
+/** Link has been severed */
598
+#define ENOLINK __einfo_error ( EINFO_ENOLINK )
599
+#define EINFO_ENOLINK __einfo ( PXENV_STATUS_FAILURE, 0x30, 0, \
600
+				"Link has been severed" )
365
 
601
 
366
 /** Not enough space */
602
 /** Not enough space */
367
-#define ENOMEM	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x31000000 )
603
+#define ENOMEM __einfo_error ( EINFO_ENOMEM )
604
+#define EINFO_ENOMEM __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x31, 0, \
605
+			       "Not enough space" )
368
 
606
 
369
 /** No message of the desired type */
607
 /** No message of the desired type */
370
-#define ENOMSG			( ERRFILE | PXENV_STATUS_FAILURE | 0x32000000 )
608
+#define ENOMSG __einfo_error ( EINFO_ENOMSG )
609
+#define EINFO_ENOMSG __einfo ( PXENV_STATUS_FAILURE, 0x32, 0, \
610
+			       "No message of the desired type" )
371
 
611
 
372
 /** Protocol not available */
612
 /** Protocol not available */
373
-#define ENOPROTOOPT	    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x33000000 )
613
+#define ENOPROTOOPT __einfo_error ( EINFO_ENOPROTOOPT )
614
+#define EINFO_ENOPROTOOPT __einfo ( PXENV_STATUS_UNSUPPORTED, 0x33, 0, \
615
+				    "Protocol not available" )
374
 
616
 
375
 /** No space left on device */
617
 /** No space left on device */
376
-#define ENOSPC	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x34000000 )
618
+#define ENOSPC __einfo_error ( EINFO_ENOSPC )
619
+#define EINFO_ENOSPC __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x34, 0, \
620
+			       "No space left on device" )
377
 
621
 
378
 /** No STREAM resources */
622
 /** No STREAM resources */
379
-#define ENOSR	       ( ERRFILE | PXENV_STATUS_OUT_OF_RESOURCES | 0x35000000 )
623
+#define ENOSR __einfo_error ( EINFO_ENOSR )
624
+#define EINFO_ENOSR __einfo ( PXENV_STATUS_OUT_OF_RESOURCES, 0x35, 0, \
625
+			      "No STREAM resources" )
380
 
626
 
381
 /** Not a STREAM */
627
 /** Not a STREAM */
382
-#define ENOSTR			( ERRFILE | PXENV_STATUS_FAILURE | 0x36000000 )
628
+#define ENOSTR __einfo_error ( EINFO_ENOSTR )
629
+#define EINFO_ENOSTR __einfo ( PXENV_STATUS_FAILURE, 0x36, 0, \
630
+			       "Not a STREAM" )
383
 
631
 
384
 /** Function not implemented */
632
 /** Function not implemented */
385
-#define ENOSYS		    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x37000000 )
633
+#define ENOSYS __einfo_error ( EINFO_ENOSYS )
634
+#define EINFO_ENOSYS __einfo ( PXENV_STATUS_UNSUPPORTED, 0x37, 0, \
635
+			       "Function not implemented" )
386
 
636
 
387
 /** The socket is not connected */
637
 /** The socket is not connected */
388
-#define ENOTCONN		( ERRFILE | PXENV_STATUS_FAILURE | 0x38000000 )
638
+#define ENOTCONN __einfo_error ( EINFO_ENOTCONN )
639
+#define EINFO_ENOTCONN __einfo ( PXENV_STATUS_FAILURE, 0x38, 0, \
640
+				 "The socket is not connected" )
389
 
641
 
390
 /** Not a directory */
642
 /** Not a directory */
391
-#define ENOTDIR			( ERRFILE | PXENV_STATUS_FAILURE | 0x39000000 )
643
+#define ENOTDIR __einfo_error ( EINFO_ENOTDIR )
644
+#define EINFO_ENOTDIR __einfo ( PXENV_STATUS_FAILURE, 0x39, 0, \
645
+				"Not a directory" )
392
 
646
 
393
 /** Directory not empty */
647
 /** Directory not empty */
394
-#define ENOTEMPTY		( ERRFILE | PXENV_STATUS_FAILURE | 0x3a000000 )
648
+#define ENOTEMPTY __einfo_error ( EINFO_ENOTEMPTY )
649
+#define EINFO_ENOTEMPTY __einfo ( PXENV_STATUS_FAILURE, 0x3a, 0, \
650
+				  "Directory not empty" )
395
 
651
 
396
 /** Not a socket */
652
 /** Not a socket */
397
-#define ENOTSOCK		( ERRFILE | PXENV_STATUS_FAILURE | 0x3b000000 )
653
+#define ENOTSOCK __einfo_error ( EINFO_ENOTSOCK )
654
+#define EINFO_ENOTSOCK __einfo ( PXENV_STATUS_FAILURE, 0x3b, 0, \
655
+				 "Not a socket" )
398
 
656
 
399
-/** Not supported */
400
-#define ENOTSUP		    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x3c000000 )
657
+/** Operation not supported */
658
+#define ENOTSUP __einfo_error ( EINFO_ENOTSUP )
659
+#define EINFO_ENOTSUP __einfo ( PXENV_STATUS_UNSUPPORTED, 0x3c, 0, \
660
+				"Operation not supported" )
401
 
661
 
402
 /** Inappropriate I/O control operation */
662
 /** Inappropriate I/O control operation */
403
-#define ENOTTY			( ERRFILE | PXENV_STATUS_FAILURE | 0x3d000000 )
663
+#define ENOTTY __einfo_error ( EINFO_ENOTTY )
664
+#define EINFO_ENOTTY __einfo ( PXENV_STATUS_FAILURE, 0x3d, 0, \
665
+			       "Inappropriate I/O control operation" )
404
 
666
 
405
 /** No such device or address */
667
 /** No such device or address */
406
-#define ENXIO	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x3e000000 )
668
+#define ENXIO __einfo_error ( EINFO_ENXIO )
669
+#define EINFO_ENXIO __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x3e, 0, \
670
+			      "No such device or address" )
407
 
671
 
408
 /** Operation not supported on socket */
672
 /** Operation not supported on socket */
409
-#define EOPNOTSUPP	    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x3f000000 )
673
+#define EOPNOTSUPP __einfo_error ( EINFO_EOPNOTSUPP )
674
+#define EINFO_EOPNOTSUPP __einfo ( PXENV_STATUS_UNSUPPORTED, 0x3f, 0, \
675
+				   "Operation not supported on socket" )
410
 
676
 
411
 /** Value too large to be stored in data type */
677
 /** Value too large to be stored in data type */
412
-#define EOVERFLOW		( ERRFILE | PXENV_STATUS_FAILURE | 0x40000000 )
678
+#define EOVERFLOW __einfo_error ( EINFO_EOVERFLOW )
679
+#define EINFO_EOVERFLOW __einfo ( PXENV_STATUS_FAILURE, 0x40, 0, \
680
+				  "Value too large to be stored in data type" )
413
 
681
 
414
 /** Operation not permitted */
682
 /** Operation not permitted */
415
-#define EPERM	  ( ERRFILE | PXENV_STATUS_TFTP_ACCESS_VIOLATION | 0x41000000 )
683
+#define EPERM __einfo_error ( EINFO_EPERM )
684
+#define EINFO_EPERM __einfo ( PXENV_STATUS_TFTP_ACCESS_VIOLATION, 0x41, 0, \
685
+			      "Operation not permitted" )
416
 
686
 
417
 /** Broken pipe */
687
 /** Broken pipe */
418
-#define EPIPE			( ERRFILE | PXENV_STATUS_FAILURE | 0x42000000 )
688
+#define EPIPE __einfo_error ( EINFO_EPIPE )
689
+#define EINFO_EPIPE __einfo ( PXENV_STATUS_FAILURE, 0x42, 0, \
690
+			      "Broken pipe" )
419
 
691
 
420
 /** Protocol error */
692
 /** Protocol error */
421
-#define EPROTO			( ERRFILE | PXENV_STATUS_FAILURE | 0x43000000 )
693
+#define EPROTO __einfo_error ( EINFO_EPROTO )
694
+#define EINFO_EPROTO __einfo ( PXENV_STATUS_FAILURE, 0x43, 0, \
695
+			       "Protocol error" )
422
 
696
 
423
 /** Protocol not supported */
697
 /** Protocol not supported */
424
-#define EPROTONOSUPPORT	    ( ERRFILE | PXENV_STATUS_UNSUPPORTED | 0x44000000 )
698
+#define EPROTONOSUPPORT __einfo_error ( EINFO_EPROTONOSUPPORT )
699
+#define EINFO_EPROTONOSUPPORT __einfo ( PXENV_STATUS_UNSUPPORTED, 0x44, 0, \
700
+					"Protocol not supported" )
425
 
701
 
426
 /** Protocol wrong type for socket */
702
 /** Protocol wrong type for socket */
427
-#define EPROTOTYPE		( ERRFILE | PXENV_STATUS_FAILURE | 0x45000000 )
703
+#define EPROTOTYPE __einfo_error ( EINFO_EPROTOTYPE )
704
+#define EINFO_EPROTOTYPE __einfo ( PXENV_STATUS_FAILURE, 0x45, 0, \
705
+				   "Protocol wrong type for socket" )
428
 
706
 
429
 /** Result too large */
707
 /** Result too large */
430
-#define ERANGE			( ERRFILE | PXENV_STATUS_FAILURE | 0x46000000 )
708
+#define ERANGE __einfo_error ( EINFO_ERANGE )
709
+#define EINFO_ERANGE __einfo ( PXENV_STATUS_FAILURE, 0x46, 0, \
710
+			       "Result too large" )
431
 
711
 
432
 /** Read-only file system */
712
 /** Read-only file system */
433
-#define EROFS			( ERRFILE | PXENV_STATUS_FAILURE | 0x47000000 )
713
+#define EROFS __einfo_error ( EINFO_EROFS )
714
+#define EINFO_EROFS __einfo ( PXENV_STATUS_FAILURE, 0x47, 0, \
715
+			      "Read-only file system" )
434
 
716
 
435
 /** Invalid seek */
717
 /** Invalid seek */
436
-#define ESPIPE			( ERRFILE | PXENV_STATUS_FAILURE | 0x48000000 )
718
+#define ESPIPE __einfo_error ( EINFO_ESPIPE )
719
+#define EINFO_ESPIPE __einfo ( PXENV_STATUS_FAILURE, 0x48, 0, \
720
+			       "Invalid seek" )
437
 
721
 
438
 /** No such process */
722
 /** No such process */
439
-#define ESRCH	    ( ERRFILE | PXENV_STATUS_TFTP_FILE_NOT_FOUND | 0x49000000 )
723
+#define ESRCH __einfo_error ( EINFO_ESRCH )
724
+#define EINFO_ESRCH __einfo ( PXENV_STATUS_TFTP_FILE_NOT_FOUND, 0x49, 0, \
725
+			      "No such process" )
440
 
726
 
441
 /** Stale file handle */
727
 /** Stale file handle */
442
-#define ESTALE			( ERRFILE | PXENV_STATUS_FAILURE | 0x4a000000 )
728
+#define ESTALE __einfo_error ( EINFO_ESTALE )
729
+#define EINFO_ESTALE __einfo ( PXENV_STATUS_FAILURE, 0x4a, 0, \
730
+			       "Stale file handle" )
443
 
731
 
444
-/** STREAM ioctl() timeout */
445
-#define ETIME			( ERRFILE | PXENV_STATUS_FAILURE | 0x4b000000 )
732
+/** Timer expired */
733
+#define ETIME __einfo_error ( EINFO_ETIME )
734
+#define EINFO_ETIME __einfo ( PXENV_STATUS_FAILURE, 0x4b, 0, \
735
+			      "Timer expired" )
446
 
736
 
447
-/** Operation timed out */
448
-#define ETIMEDOUT     ( ERRFILE | PXENV_STATUS_TFTP_READ_TIMEOUT | 0x4c000000 )
737
+/** Connection timed out */
738
+#define ETIMEDOUT __einfo_error ( EINFO_ETIMEDOUT )
739
+#define EINFO_ETIMEDOUT __einfo ( PXENV_STATUS_TFTP_READ_TIMEOUT, 0x4c, 0, \
740
+				  "Connection timed out" )
449
 
741
 
450
 /** Text file busy */
742
 /** Text file busy */
451
-#define ETXTBSY			( ERRFILE | PXENV_STATUS_FAILURE | 0x4d000000 )
743
+#define ETXTBSY __einfo_error ( EINFO_ETXTBSY )
744
+#define EINFO_ETXTBSY __einfo ( PXENV_STATUS_FAILURE, 0x4d, 0, \
745
+				"Text file busy" )
452
 
746
 
453
-/** Operation would block (different from EAGAIN!) */
454
-#define EWOULDBLOCK	      ( ERRFILE | PXENV_STATUS_TFTP_OPEN | 0x4e000000 )
747
+/** Operation would block */
748
+#define EWOULDBLOCK __einfo_error ( EINFO_EWOULDBLOCK )
749
+#define EINFO_EWOULDBLOCK __einfo ( PXENV_STATUS_TFTP_OPEN, 0x4e, 0, \
750
+				    "Operation would block" )
455
 
751
 
456
 /** Improper link */
752
 /** Improper link */
457
-#define EXDEV			( ERRFILE | PXENV_STATUS_FAILURE | 0x4f000000 )
458
-
459
-/** @} */
460
-
461
-/**
462
- * @defgroup euniq Per-file error disambiguators
463
- *
464
- * Files which use the same error number multiple times should
465
- * probably define their own error subspace using these
466
- * disambiguators.  For example:
467
- *
468
- *     #define ETCP_HEADER_TOO_SHORT	EUNIQ_01
469
- *     #define ETCP_BAD_CHECKSUM	EUNIQ_02
470
- *
471
- * @{
472
- */
473
-
474
-#define EUNIQ_01	0x00000100
475
-#define EUNIQ_02	0x00000200
476
-#define EUNIQ_03	0x00000300
477
-#define EUNIQ_04	0x00000400
478
-#define EUNIQ_05	0x00000500
479
-#define EUNIQ_06	0x00000600
480
-#define EUNIQ_07	0x00000700
481
-#define EUNIQ_08	0x00000800
482
-#define EUNIQ_09	0x00000900
483
-#define EUNIQ_0A	0x00000a00
484
-#define EUNIQ_0B	0x00000b00
485
-#define EUNIQ_0C	0x00000c00
486
-#define EUNIQ_0D	0x00000d00
487
-#define EUNIQ_0E	0x00000e00
488
-#define EUNIQ_0F	0x00000f00
489
-#define EUNIQ_10	0x00001000
490
-#define EUNIQ_11	0x00001100
491
-#define EUNIQ_12	0x00001200
492
-#define EUNIQ_13	0x00001300
493
-#define EUNIQ_14	0x00001400
494
-#define EUNIQ_15	0x00001500
495
-#define EUNIQ_16	0x00001600
496
-#define EUNIQ_17	0x00001700
497
-#define EUNIQ_18	0x00001800
498
-#define EUNIQ_19	0x00001900
499
-#define EUNIQ_1A	0x00001a00
500
-#define EUNIQ_1B	0x00001b00
501
-#define EUNIQ_1C	0x00001c00
502
-#define EUNIQ_1D	0x00001d00
503
-#define EUNIQ_1E	0x00001e00
504
-#define EUNIQ_1F	0x00001f00
753
+#define EXDEV __einfo_error ( EINFO_EXDEV )
754
+#define EINFO_EXDEV __einfo ( PXENV_STATUS_FAILURE, 0x4f, 0, \
755
+			      "Improper link" )
505
 
756
 
506
 /** @} */
757
 /** @} */
507
 
758
 

+ 5
- 0
src/include/ipxe/errortab.h View File

20
 
20
 
21
 #define __errortab __table_entry ( ERRORTAB, 01 )
21
 #define __errortab __table_entry ( ERRORTAB, 01 )
22
 
22
 
23
+#define __einfo_errortab( einfo ) {			\
24
+	.errno = __einfo_errno ( einfo ),		\
25
+	.text = __einfo_desc ( einfo ),			\
26
+	}
27
+
23
 #endif /* _IPXE_ERRORTAB_H */
28
 #endif /* _IPXE_ERRORTAB_H */

+ 1
- 0
src/include/ipxe/ieee80211.h View File

1
 #ifndef _IPXE_IEEE80211_H
1
 #ifndef _IPXE_IEEE80211_H
2
 #define _IPXE_IEEE80211_H
2
 #define _IPXE_IEEE80211_H
3
 
3
 
4
+#include <stddef.h>
4
 #include <ipxe/if_ether.h>	/* for ETH_ALEN */
5
 #include <ipxe/if_ether.h>	/* for ETH_ALEN */
5
 #include <endian.h>
6
 #include <endian.h>
6
 
7
 

+ 633
- 0
src/include/ipxe/net80211_err.h View File

1
+#ifndef _IPXE_NET80211_ERR_H
2
+#define _IPXE_NET80211_ERR_H
3
+
4
+#include <errno.h>
5
+#include <ipxe/ieee80211.h>
6
+
7
+/*
8
+ * The iPXE 802.11 MAC layer.
9
+ *
10
+ * Copyright (c) 2009 Joshua Oreman <oremanj@rwcr.net>.
11
+ */
12
+
13
+FILE_LICENCE ( GPL2_OR_LATER );
14
+
15
+/** @file
16
+ *
17
+ * The iPXE 802.11 MAC layer errors.
18
+ */
19
+
20
+/* Disambiguate the EINVAL's a bit */
21
+#define EINVAL_PKT_TOO_SHORT __einfo_error ( EINFO_EINVAL_PKT_TOO_SHORT )
22
+#define EINFO_EINVAL_PKT_TOO_SHORT __einfo_uniqify \
23
+	( EINFO_EINVAL, 0x01, "Packet too short" )
24
+#define EINVAL_PKT_VERSION __einfo_error ( EINFO_EINVAL_PKT_VERSION )
25
+#define EINFO_EINVAL_PKT_VERSION __einfo_uniqify \
26
+	( EINFO_EINVAL, 0x02, "Packet 802.11 version not supported" )
27
+#define EINVAL_PKT_NOT_DATA __einfo_error ( EINFO_EINVAL_PKT_NOT_DATA )
28
+#define EINFO_EINVAL_PKT_NOT_DATA __einfo_uniqify \
29
+	( EINFO_EINVAL, 0x03, "Packet not a data packet" )
30
+#define EINVAL_PKT_NOT_FROMDS __einfo_error ( EINFO_EINVAL_PKT_NOT_FROMDS )
31
+#define EINFO_EINVAL_PKT_NOT_FROMDS __einfo_uniqify \
32
+	( EINFO_EINVAL, 0x04, "Packet not from an Access Point" )
33
+#define EINVAL_PKT_LLC_HEADER __einfo_error ( EINFO_EINVAL_PKT_LLC_HEADER )
34
+#define EINFO_EINVAL_PKT_LLC_HEADER __einfo_uniqify \
35
+	( EINFO_EINVAL, 0x05, "Packet has invalid LLC header" )
36
+#define EINVAL_CRYPTO_REQUEST __einfo_error ( EINFO_EINVAL_CRYPTO_REQUEST )
37
+#define EINFO_EINVAL_CRYPTO_REQUEST __einfo_uniqify \
38
+	( EINFO_EINVAL, 0x06, "Packet decryption error" )
39
+#define EINVAL_ACTIVE_SCAN __einfo_error ( EINFO_EINVAL_ACTIVE_SCAN )
40
+#define EINFO_EINVAL_ACTIVE_SCAN __einfo_uniqify \
41
+	( EINFO_EINVAL, 0x07, "Invalid active scan requested" )
42
+
43
+/*
44
+ * 802.11 error codes: The AP can give us a status code explaining why
45
+ * authentication failed, or a reason code explaining why we were
46
+ * deauthenticated/disassociated. These codes range from 0-63 (the
47
+ * field is 16 bits wide, but only up to 45 or so are defined yet; we
48
+ * allow up to 63 for extensibility). This is encoded into an error
49
+ * code as such:
50
+ *
51
+ *                                      status & 0x1f goes here --vv--
52
+ *   Status code 0-31:  ECONNREFUSED | EUNIQ_(status & 0x1f) (0e1a6038)
53
+ *   Status code 32-63: EHOSTUNREACH | EUNIQ_(status & 0x1f) (171a6011)
54
+ *   Reason code 0-31:  ECONNRESET | EUNIQ_(reason & 0x1f)   (0f1a6039)
55
+ *   Reason code 32-63: ENETRESET | EUNIQ_(reason & 0x1f)    (271a6001)
56
+ *
57
+ * The POSIX error codes more or less convey the appropriate message
58
+ * (status codes occur when we can't associate at all, reason codes
59
+ * when we lose association unexpectedly) and let us extract the
60
+ * complete 802.11 error code from the rc value.
61
+ *
62
+ * The error messages follow the 802.11 standard as much as is
63
+ * feasible, but most have been abbreviated to fit the 50-character
64
+ * limit imposed by strerror().
65
+ */
66
+
67
+/* 802.11 status codes (IEEE Std 802.11-2007, Table 7-23) */
68
+
69
+#define ECONNREFUSED_FAILURE __einfo_error				\
70
+	( EINFO_ECONNREFUSED_FAILURE )
71
+#define EINFO_ECONNREFUSED_FAILURE __einfo_uniqify			\
72
+	( EINFO_ECONNREFUSED,						\
73
+	  ( IEEE80211_STATUS_FAILURE & 0x1f ),				\
74
+	  "Unspecified failure" )
75
+
76
+#define ECONNREFUSED_CAPAB_UNSUPP __einfo_error				\
77
+	( EINFO_ECONNREFUSED_CAPAB_UNSUPP )
78
+#define EINFO_ECONNREFUSED_CAPAB_UNSUPP __einfo_uniqify			\
79
+	( EINFO_ECONNREFUSED,						\
80
+	  ( IEEE80211_STATUS_CAPAB_UNSUPP & 0x1f ),			\
81
+	  "Cannot support all requested capabilities" )
82
+
83
+#define ECONNREFUSED_REASSOC_INVALID __einfo_error			\
84
+	( EINFO_ECONNREFUSED_REASSOC_INVALID )
85
+#define EINFO_ECONNREFUSED_REASSOC_INVALID __einfo_uniqify		\
86
+	( EINFO_ECONNREFUSED,						\
87
+	  ( IEEE80211_STATUS_REASSOC_INVALID & 0x1f ),			\
88
+	  "Reassociation denied due to lack of association" )
89
+
90
+#define ECONNREFUSED_ASSOC_DENIED __einfo_error				\
91
+	( EINFO_ECONNREFUSED_ASSOC_DENIED )
92
+#define EINFO_ECONNREFUSED_ASSOC_DENIED __einfo_uniqify			\
93
+	( EINFO_ECONNREFUSED,						\
94
+	  ( IEEE80211_STATUS_ASSOC_DENIED & 0x1f ),			\
95
+	  "Association denied for another reason" )
96
+
97
+#define ECONNREFUSED_AUTH_ALGO_UNSUPP __einfo_error			\
98
+	( EINFO_ECONNREFUSED_AUTH_ALGO_UNSUPP )
99
+#define EINFO_ECONNREFUSED_AUTH_ALGO_UNSUPP __einfo_uniqify		\
100
+	( EINFO_ECONNREFUSED,						\
101
+	  ( IEEE80211_STATUS_AUTH_ALGO_UNSUPP & 0x1f ),			\
102
+	  "Authentication algorithm unsupported" )
103
+
104
+#define ECONNREFUSED_AUTH_SEQ_INVALID __einfo_error			\
105
+	( EINFO_ECONNREFUSED_AUTH_SEQ_INVALID )
106
+#define EINFO_ECONNREFUSED_AUTH_SEQ_INVALID __einfo_uniqify		\
107
+	( EINFO_ECONNREFUSED,						\
108
+	  ( IEEE80211_STATUS_AUTH_SEQ_INVALID & 0x1f ),			\
109
+	  "Authentication sequence number unexpected" )
110
+
111
+#define ECONNREFUSED_AUTH_CHALL_INVALID __einfo_error			\
112
+	( EINFO_ECONNREFUSED_AUTH_CHALL_INVALID )
113
+#define EINFO_ECONNREFUSED_AUTH_CHALL_INVALID __einfo_uniqify		\
114
+	( EINFO_ECONNREFUSED,					\
115
+	  ( IEEE80211_STATUS_AUTH_CHALL_INVALID & 0x1f ),		\
116
+	  "Authentication rejected due to challenge failure" )
117
+
118
+#define ECONNREFUSED_AUTH_TIMEOUT __einfo_error				\
119
+	( EINFO_ECONNREFUSED_AUTH_TIMEOUT )
120
+#define EINFO_ECONNREFUSED_AUTH_TIMEOUT __einfo_uniqify			\
121
+	( EINFO_ECONNREFUSED,						\
122
+	  ( IEEE80211_STATUS_AUTH_TIMEOUT & 0x1f ),			\
123
+	  "Authentication rejected due to timeout" )
124
+
125
+#define ECONNREFUSED_ASSOC_NO_ROOM __einfo_error			\
126
+	( EINFO_ECONNREFUSED_ASSOC_NO_ROOM )
127
+#define EINFO_ECONNREFUSED_ASSOC_NO_ROOM __einfo_uniqify		\
128
+	( EINFO_ECONNREFUSED,						\
129
+	  ( IEEE80211_STATUS_ASSOC_NO_ROOM & 0x1f ),			\
130
+	  "Association denied because AP is out of resources" )
131
+
132
+#define ECONNREFUSED_ASSOC_NEED_RATE __einfo_error			\
133
+	( EINFO_ECONNREFUSED_ASSOC_NEED_RATE )
134
+#define EINFO_ECONNREFUSED_ASSOC_NEED_RATE __einfo_uniqify		\
135
+	( EINFO_ECONNREFUSED,						\
136
+	  ( IEEE80211_STATUS_ASSOC_NEED_RATE & 0x1f ),			\
137
+	  "Association denied; basic rate support required" )
138
+
139
+#define ECONNREFUSED_ASSOC_NEED_SHORT_PMBL __einfo_error		\
140
+	( EINFO_ECONNREFUSED_ASSOC_NEED_SHORT_PMBL )
141
+#define EINFO_ECONNREFUSED_ASSOC_NEED_SHORT_PMBL __einfo_uniqify	\
142
+	( EINFO_ECONNREFUSED,						\
143
+	  ( IEEE80211_STATUS_ASSOC_NEED_SHORT_PMBL & 0x1f ),		\
144
+	  "Association denied; short preamble support req'd" )
145
+
146
+#define ECONNREFUSED_ASSOC_NEED_PBCC __einfo_error			\
147
+	( EINFO_ECONNREFUSED_ASSOC_NEED_PBCC )
148
+#define EINFO_ECONNREFUSED_ASSOC_NEED_PBCC __einfo_uniqify		\
149
+	( EINFO_ECONNREFUSED,						\
150
+	  ( IEEE80211_STATUS_ASSOC_NEED_PBCC & 0x1f ),			\
151
+	  "Association denied; PBCC modulation support req'd" )
152
+
153
+#define ECONNREFUSED_ASSOC_NEED_CHAN_AGILITY __einfo_error		\
154
+	( EINFO_ECONNREFUSED_ASSOC_NEED_CHAN_AGILITY )
155
+#define EINFO_ECONNREFUSED_ASSOC_NEED_CHAN_AGILITY __einfo_uniqify	\
156
+	( EINFO_ECONNREFUSED,						\
157
+	  ( IEEE80211_STATUS_ASSOC_NEED_CHAN_AGILITY & 0x1f ),		\
158
+	  "Association denied; Channel Agility support req'd" )
159
+
160
+#define ECONNREFUSED_ASSOC_NEED_SPECTRUM_MGMT __einfo_error		\
161
+	( EINFO_ECONNREFUSED_ASSOC_NEED_SPECTRUM_MGMT )
162
+#define EINFO_ECONNREFUSED_ASSOC_NEED_SPECTRUM_MGMT __einfo_uniqify	\
163
+	( EINFO_ECONNREFUSED,						\
164
+	  ( IEEE80211_STATUS_ASSOC_NEED_SPECTRUM_MGMT & 0x1f ),		\
165
+	  "Association denied; Spectrum Management required" )
166
+
167
+#define ECONNREFUSED_ASSOC_BAD_POWER __einfo_error			\
168
+	( EINFO_ECONNREFUSED_ASSOC_BAD_POWER )
169
+#define EINFO_ECONNREFUSED_ASSOC_BAD_POWER __einfo_uniqify		\
170
+	( EINFO_ECONNREFUSED,						\
171
+	  ( IEEE80211_STATUS_ASSOC_BAD_POWER & 0x1f ),			\
172
+	  "Association denied; Power Capability unacceptable" )
173
+
174
+#define ECONNREFUSED_ASSOC_BAD_CHANNELS __einfo_error			\
175
+	( EINFO_ECONNREFUSED_ASSOC_BAD_CHANNELS )
176
+#define EINFO_ECONNREFUSED_ASSOC_BAD_CHANNELS __einfo_uniqify		\
177
+	( EINFO_ECONNREFUSED,						\
178
+	  ( IEEE80211_STATUS_ASSOC_BAD_CHANNELS & 0x1f ),		\
179
+	  "Association denied; Supported Channels unacceptable" )
180
+
181
+#define ECONNREFUSED_ASSOC_NEED_SHORT_SLOT __einfo_error		\
182
+	( EINFO_ECONNREFUSED_ASSOC_NEED_SHORT_SLOT )
183
+#define EINFO_ECONNREFUSED_ASSOC_NEED_SHORT_SLOT __einfo_uniqify	\
184
+	( EINFO_ECONNREFUSED,						\
185
+	  ( IEEE80211_STATUS_ASSOC_NEED_SHORT_SLOT & 0x1f ),		\
186
+	  "Association denied; Short Slot Tume support req'd" )
187
+
188
+#define ECONNREFUSED_ASSOC_NEED_DSSS_OFDM __einfo_error			\
189
+	( EINFO_ECONNREFUSED_ASSOC_NEED_DSSS_OFDM )
190
+#define EINFO_ECONNREFUSED_ASSOC_NEED_DSSS_OFDM __einfo_uniqify		\
191
+	( EINFO_ECONNREFUSED,						\
192
+	  ( IEEE80211_STATUS_ASSOC_NEED_DSSS_OFDM & 0x1f ),		\
193
+	  "Association denied; DSSS-OFDM support required" )
194
+
195
+#define EHOSTUNREACH_QOS_FAILURE __einfo_error				\
196
+	( EINFO_EHOSTUNREACH_QOS_FAILURE )
197
+#define EINFO_EHOSTUNREACH_QOS_FAILURE __einfo_uniqify			\
198
+	( EINFO_EHOSTUNREACH,						\
199
+	  ( IEEE80211_STATUS_QOS_FAILURE & 0x1f ),			\
200
+	  "Unspecified, QoS-related failure" )
201
+
202
+#define EHOSTUNREACH_QOS_NO_ROOM __einfo_error				\
203
+	( EINFO_EHOSTUNREACH_QOS_NO_ROOM )
204
+#define EINFO_EHOSTUNREACH_QOS_NO_ROOM __einfo_uniqify			\
205
+	( EINFO_EHOSTUNREACH,						\
206
+	  ( IEEE80211_STATUS_QOS_NO_ROOM & 0x1f ),			\
207
+	  "Association denied; QoS AP out of QoS resources" )
208
+
209
+#define EHOSTUNREACH_LINK_IS_HORRIBLE __einfo_error			\
210
+	( EINFO_EHOSTUNREACH_LINK_IS_HORRIBLE )
211
+#define EINFO_EHOSTUNREACH_LINK_IS_HORRIBLE __einfo_uniqify		\
212
+	( EINFO_EHOSTUNREACH,						\
213
+	  ( IEEE80211_STATUS_LINK_IS_HORRIBLE & 0x1f ),			\
214
+	  "Association denied due to excessively poor link" )
215
+
216
+#define EHOSTUNREACH_ASSOC_NEED_QOS __einfo_error			\
217
+	( EINFO_EHOSTUNREACH_ASSOC_NEED_QOS )
218
+#define EINFO_EHOSTUNREACH_ASSOC_NEED_QOS __einfo_uniqify		\
219
+	( EINFO_EHOSTUNREACH,						\
220
+	  ( IEEE80211_STATUS_ASSOC_NEED_QOS & 0x1f ),			\
221
+	  "Association denied; QoS support required" )
222
+
223
+#define EHOSTUNREACH_REQUEST_DECLINED __einfo_error			\
224
+	( EINFO_EHOSTUNREACH_REQUEST_DECLINED )
225
+#define EINFO_EHOSTUNREACH_REQUEST_DECLINED __einfo_uniqify		\
226
+	( EINFO_EHOSTUNREACH,						\
227
+	  ( IEEE80211_STATUS_REQUEST_DECLINED & 0x1f ),			\
228
+	  "The request has been declined" )
229
+
230
+#define EHOSTUNREACH_REQUEST_INVALID __einfo_error			\
231
+	( EINFO_EHOSTUNREACH_REQUEST_INVALID )
232
+#define EINFO_EHOSTUNREACH_REQUEST_INVALID __einfo_uniqify		\
233
+	( EINFO_EHOSTUNREACH,						\
234
+	  ( IEEE80211_STATUS_REQUEST_INVALID & 0x1f ),			\
235
+	  "Request unsuccessful due to invalid parameters" )
236
+
237
+#define EHOSTUNREACH_TS_NOT_CREATED_AGAIN __einfo_error			\
238
+	( EINFO_EHOSTUNREACH_TS_NOT_CREATED_AGAIN )
239
+#define EINFO_EHOSTUNREACH_TS_NOT_CREATED_AGAIN __einfo_uniqify		\
240
+	( EINFO_EHOSTUNREACH,						\
241
+	  ( IEEE80211_STATUS_TS_NOT_CREATED_AGAIN & 0x1f ),		\
242
+	  "TS not created due to bad specification" )
243
+
244
+#define EHOSTUNREACH_INVALID_IE __einfo_error				\
245
+	( EINFO_EHOSTUNREACH_INVALID_IE )
246
+#define EINFO_EHOSTUNREACH_INVALID_IE __einfo_uniqify			\
247
+	( EINFO_EHOSTUNREACH,						\
248
+	  ( IEEE80211_STATUS_INVALID_IE & 0x1f ),			\
249
+	  "Invalid information element" )
250
+
251
+#define EHOSTUNREACH_GROUP_CIPHER_INVALID __einfo_error			\
252
+	( EINFO_EHOSTUNREACH_GROUP_CIPHER_INVALID )
253
+#define EINFO_EHOSTUNREACH_GROUP_CIPHER_INVALID __einfo_uniqify		\
254
+	( EINFO_EHOSTUNREACH,						\
255
+	  ( IEEE80211_STATUS_GROUP_CIPHER_INVALID & 0x1f ),		\
256
+	  "Invalid group cipher" )
257
+
258
+#define EHOSTUNREACH_PAIR_CIPHER_INVALID __einfo_error			\
259
+	( EINFO_EHOSTUNREACH_PAIR_CIPHER_INVALID )
260
+#define EINFO_EHOSTUNREACH_PAIR_CIPHER_INVALID __einfo_uniqify		\
261
+	( EINFO_EHOSTUNREACH,						\
262
+	  ( IEEE80211_STATUS_PAIR_CIPHER_INVALID & 0x1f ),		\
263
+	  "Invalid pairwise cipher" )
264
+
265
+#define EHOSTUNREACH_AKMP_INVALID __einfo_error				\
266
+	( EINFO_EHOSTUNREACH_AKMP_INVALID )
267
+#define EINFO_EHOSTUNREACH_AKMP_INVALID __einfo_uniqify			\
268
+	( EINFO_EHOSTUNREACH,						\
269
+	  ( IEEE80211_STATUS_AKMP_INVALID & 0x1f ),			\
270
+	  "Invalid AKMP" )
271
+
272
+#define EHOSTUNREACH_RSN_VERSION_UNSUPP __einfo_error			\
273
+	( EINFO_EHOSTUNREACH_RSN_VERSION_UNSUPP )
274
+#define EINFO_EHOSTUNREACH_RSN_VERSION_UNSUPP __einfo_uniqify		\
275
+	( EINFO_EHOSTUNREACH,						\
276
+	  ( IEEE80211_STATUS_RSN_VERSION_UNSUPP & 0x1f ),		\
277
+	  "Unsupported RSN information element version" )
278
+
279
+#define EHOSTUNREACH_RSN_CAPAB_INVALID __einfo_error			\
280
+	( EINFO_EHOSTUNREACH_RSN_CAPAB_INVALID )
281
+#define EINFO_EHOSTUNREACH_RSN_CAPAB_INVALID __einfo_uniqify		\
282
+	( EINFO_EHOSTUNREACH,						\
283
+	  ( IEEE80211_STATUS_RSN_CAPAB_INVALID & 0x1f ),		\
284
+	  "Invalid RSN information element capabilities" )
285
+
286
+#define EHOSTUNREACH_CIPHER_REJECTED __einfo_error			\
287
+	( EINFO_EHOSTUNREACH_CIPHER_REJECTED )
288
+#define EINFO_EHOSTUNREACH_CIPHER_REJECTED __einfo_uniqify		\
289
+	( EINFO_EHOSTUNREACH,						\
290
+	  ( IEEE80211_STATUS_CIPHER_REJECTED & 0x1f ),			\
291
+	  "Cipher suite rejected because of security policy" )
292
+
293
+#define EHOSTUNREACH_TS_NOT_CREATED_WAIT __einfo_error			\
294
+	( EINFO_EHOSTUNREACH_TS_NOT_CREATED_WAIT )
295
+#define EINFO_EHOSTUNREACH_TS_NOT_CREATED_WAIT __einfo_uniqify		\
296
+	( EINFO_EHOSTUNREACH,						\
297
+	  ( IEEE80211_STATUS_TS_NOT_CREATED_WAIT & 0x1f ),		\
298
+	  "TS not created due to insufficient delay" )
299
+
300
+#define EHOSTUNREACH_DIRECT_LINK_FORBIDDEN __einfo_error		\
301
+	( EINFO_EHOSTUNREACH_DIRECT_LINK_FORBIDDEN )
302
+#define EINFO_EHOSTUNREACH_DIRECT_LINK_FORBIDDEN __einfo_uniqify	\
303
+	( EINFO_EHOSTUNREACH,						\
304
+	  ( IEEE80211_STATUS_DIRECT_LINK_FORBIDDEN & 0x1f ),		\
305
+	  "Direct link is not allowed in the BSS by policy" )
306
+
307
+#define EHOSTUNREACH_DEST_NOT_PRESENT __einfo_error			\
308
+	( EINFO_EHOSTUNREACH_DEST_NOT_PRESENT )
309
+#define EINFO_EHOSTUNREACH_DEST_NOT_PRESENT __einfo_uniqify		\
310
+	( EINFO_EHOSTUNREACH,						\
311
+	  ( IEEE80211_STATUS_DEST_NOT_PRESENT & 0x1f ),			\
312
+	  "The Destination STA is not present within the BSS" )
313
+
314
+#define EHOSTUNREACH_DEST_NOT_QOS __einfo_error				\
315
+	( EINFO_EHOSTUNREACH_DEST_NOT_QOS )
316
+#define EINFO_EHOSTUNREACH_DEST_NOT_QOS __einfo_uniqify			\
317
+	( EINFO_EHOSTUNREACH,						\
318
+	  ( IEEE80211_STATUS_DEST_NOT_QOS & 0x1f ),			\
319
+	  "The Destination STA is not a QoS STA" )
320
+
321
+#define EHOSTUNREACH_ASSOC_LISTEN_TOO_HIGH __einfo_error		\
322
+	( EINFO_EHOSTUNREACH_ASSOC_LISTEN_TOO_HIGH )
323
+#define EINFO_EHOSTUNREACH_ASSOC_LISTEN_TOO_HIGH __einfo_uniqify	\
324
+	( EINFO_EHOSTUNREACH,						\
325
+	  ( IEEE80211_STATUS_ASSOC_LISTEN_TOO_HIGH & 0x1f ),		\
326
+	  "Association denied; Listen Interval is too large" )
327
+
328
+/* 802.11 reason codes (IEEE Std 802.11-2007, Table 7-22) */
329
+
330
+#define ECONNRESET_UNSPECIFIED __einfo_error				\
331
+	( EINFO_ECONNRESET_UNSPECIFIED )
332
+#define EINFO_ECONNRESET_UNSPECIFIED __einfo_uniqify			\
333
+	( EINFO_ECONNRESET,						\
334
+	  ( IEEE80211_REASON_UNSPECIFIED & 0x1f ),			\
335
+	  "Unspecified reason" )
336
+
337
+#define ECONNRESET_AUTH_NO_LONGER_VALID __einfo_error			\
338
+	( EINFO_ECONNRESET_AUTH_NO_LONGER_VALID )
339
+#define EINFO_ECONNRESET_AUTH_NO_LONGER_VALID __einfo_uniqify		\
340
+	( EINFO_ECONNRESET,						\
341
+	  ( IEEE80211_REASON_AUTH_NO_LONGER_VALID & 0x1f ),		\
342
+	  "Previous authentication no longer valid" )
343
+
344
+#define ECONNRESET_LEAVING __einfo_error				\
345
+	( EINFO_ECONNRESET_LEAVING )
346
+#define EINFO_ECONNRESET_LEAVING __einfo_uniqify			\
347
+	( EINFO_ECONNRESET,						\
348
+	  ( IEEE80211_REASON_LEAVING & 0x1f ),				\
349
+	  "Deauthenticated due to leaving network" )
350
+
351
+#define ECONNRESET_INACTIVITY __einfo_error				\
352
+	( EINFO_ECONNRESET_INACTIVITY )
353
+#define EINFO_ECONNRESET_INACTIVITY __einfo_uniqify			\
354
+	( EINFO_ECONNRESET,						\
355
+	  ( IEEE80211_REASON_INACTIVITY & 0x1f ),			\
356
+	  "Disassociated due to inactivity" )
357
+
358
+#define ECONNRESET_OUT_OF_RESOURCES __einfo_error			\
359
+	( EINFO_ECONNRESET_OUT_OF_RESOURCES )
360
+#define EINFO_ECONNRESET_OUT_OF_RESOURCES __einfo_uniqify		\
361
+	( EINFO_ECONNRESET,						\
362
+	  ( IEEE80211_REASON_OUT_OF_RESOURCES & 0x1f ),			\
363
+	  "Disassociated because AP is out of resources" )
364
+
365
+#define ECONNRESET_NEED_AUTH __einfo_error				\
366
+	( EINFO_ECONNRESET_NEED_AUTH )
367
+#define EINFO_ECONNRESET_NEED_AUTH __einfo_uniqify			\
368
+	( EINFO_ECONNRESET,						\
369
+	  ( IEEE80211_REASON_NEED_AUTH & 0x1f ),			\
370
+	  "Class 2 frame received from nonauthenticated STA" )
371
+
372
+#define ECONNRESET_NEED_ASSOC __einfo_error				\
373
+	( EINFO_ECONNRESET_NEED_ASSOC )
374
+#define EINFO_ECONNRESET_NEED_ASSOC __einfo_uniqify			\
375
+	( EINFO_ECONNRESET,						\
376
+	  ( IEEE80211_REASON_NEED_ASSOC & 0x1f ),			\
377
+	  "Class 3 frame received from nonassociated STA" )
378
+
379
+#define ECONNRESET_LEAVING_TO_ROAM __einfo_error			\
380
+	( EINFO_ECONNRESET_LEAVING_TO_ROAM )
381
+#define EINFO_ECONNRESET_LEAVING_TO_ROAM __einfo_uniqify		\
382
+	( EINFO_ECONNRESET,						\
383
+	  ( IEEE80211_REASON_LEAVING_TO_ROAM & 0x1f ),			\
384
+	  "Disassociated due to roaming" )
385
+
386
+#define ECONNRESET_REASSOC_INVALID __einfo_error			\
387
+	( EINFO_ECONNRESET_REASSOC_INVALID )
388
+#define EINFO_ECONNRESET_REASSOC_INVALID __einfo_uniqify		\
389
+	( EINFO_ECONNRESET,						\
390
+	  ( IEEE80211_REASON_REASSOC_INVALID & 0x1f ),			\
391
+	  "STA requesting (re)association not authenticated" )
392
+
393
+#define ECONNRESET_BAD_POWER __einfo_error				\
394
+	( EINFO_ECONNRESET_BAD_POWER )
395
+#define EINFO_ECONNRESET_BAD_POWER __einfo_uniqify			\
396
+	( EINFO_ECONNRESET,						\
397
+	  ( IEEE80211_REASON_BAD_POWER & 0x1f ),			\
398
+	  "Disassociated; Power Capability unacceptable" )
399
+
400
+#define ECONNRESET_BAD_CHANNELS __einfo_error				\
401
+	( EINFO_ECONNRESET_BAD_CHANNELS )
402
+#define EINFO_ECONNRESET_BAD_CHANNELS __einfo_uniqify			\
403
+	( EINFO_ECONNRESET,						\
404
+	  ( IEEE80211_REASON_BAD_CHANNELS & 0x1f ),			\
405
+	  "Disassociated; Supported Channels unacceptable" )
406
+
407
+#define ECONNRESET_INVALID_IE __einfo_error				\
408
+	( EINFO_ECONNRESET_INVALID_IE )
409
+#define EINFO_ECONNRESET_INVALID_IE __einfo_uniqify			\
410
+	( EINFO_ECONNRESET,						\
411
+	  ( IEEE80211_REASON_INVALID_IE & 0x1f ),			\
412
+	  "Invalid information element" )
413
+
414
+#define ECONNRESET_MIC_FAILURE __einfo_error				\
415
+	( EINFO_ECONNRESET_MIC_FAILURE )
416
+#define EINFO_ECONNRESET_MIC_FAILURE __einfo_uniqify			\
417
+	( EINFO_ECONNRESET,						\
418
+	  ( IEEE80211_REASON_MIC_FAILURE & 0x1f ),			\
419
+	  "Message integrity code (MIC) failure" )
420
+
421
+#define ECONNRESET_4WAY_TIMEOUT __einfo_error				\
422
+	( EINFO_ECONNRESET_4WAY_TIMEOUT )
423
+#define EINFO_ECONNRESET_4WAY_TIMEOUT __einfo_uniqify			\
424
+	( EINFO_ECONNRESET,						\
425
+	  ( IEEE80211_REASON_4WAY_TIMEOUT & 0x1f ),			\
426
+	  "4-Way Handshake timeout" )
427
+
428
+#define ECONNRESET_GROUPKEY_TIMEOUT __einfo_error			\
429
+	( EINFO_ECONNRESET_GROUPKEY_TIMEOUT )
430
+#define EINFO_ECONNRESET_GROUPKEY_TIMEOUT __einfo_uniqify		\
431
+	( EINFO_ECONNRESET,						\
432
+	  ( IEEE80211_REASON_GROUPKEY_TIMEOUT & 0x1f ),			\
433
+	  "Group Key Handshake timeout" )
434
+
435
+#define ECONNRESET_4WAY_INVALID __einfo_error				\
436
+	( EINFO_ECONNRESET_4WAY_INVALID )
437
+#define EINFO_ECONNRESET_4WAY_INVALID __einfo_uniqify			\
438
+	( EINFO_ECONNRESET,						\
439
+	  ( IEEE80211_REASON_4WAY_INVALID & 0x1f ),			\
440
+	  "4-Way Handshake information element changed unduly" )
441
+
442
+#define ECONNRESET_GROUP_CIPHER_INVALID __einfo_error			\
443
+	( EINFO_ECONNRESET_GROUP_CIPHER_INVALID )
444
+#define EINFO_ECONNRESET_GROUP_CIPHER_INVALID __einfo_uniqify		\
445
+	( EINFO_ECONNRESET,						\
446
+	  ( IEEE80211_REASON_GROUP_CIPHER_INVALID & 0x1f ),		\
447
+	  "Invalid group cipher" )
448
+
449
+#define ECONNRESET_PAIR_CIPHER_INVALID __einfo_error			\
450
+	( EINFO_ECONNRESET_PAIR_CIPHER_INVALID )
451
+#define EINFO_ECONNRESET_PAIR_CIPHER_INVALID __einfo_uniqify		\
452
+	( EINFO_ECONNRESET,						\
453
+	  ( IEEE80211_REASON_PAIR_CIPHER_INVALID & 0x1f ),		\
454
+	  "Invalid pairwise cipher" )
455
+
456
+#define ECONNRESET_AKMP_INVALID __einfo_error				\
457
+	( EINFO_ECONNRESET_AKMP_INVALID )
458
+#define EINFO_ECONNRESET_AKMP_INVALID __einfo_uniqify			\
459
+	( EINFO_ECONNRESET,						\
460
+	  ( IEEE80211_REASON_AKMP_INVALID & 0x1f ),			\
461
+	  "Invalid AKMP" )
462
+
463
+#define ECONNRESET_RSN_VERSION_INVALID __einfo_error			\
464
+	( EINFO_ECONNRESET_RSN_VERSION_INVALID )
465
+#define EINFO_ECONNRESET_RSN_VERSION_INVALID __einfo_uniqify		\
466
+	( EINFO_ECONNRESET,						\
467
+	  ( IEEE80211_REASON_RSN_VERSION_INVALID & 0x1f ),		\
468
+	  "Unsupported RSN information element version" )
469
+
470
+#define ECONNRESET_RSN_CAPAB_INVALID __einfo_error			\
471
+	( EINFO_ECONNRESET_RSN_CAPAB_INVALID )
472
+#define EINFO_ECONNRESET_RSN_CAPAB_INVALID __einfo_uniqify		\
473
+	( EINFO_ECONNRESET,						\
474
+	  ( IEEE80211_REASON_RSN_CAPAB_INVALID & 0x1f ),		\
475
+	  "Invalid RSN information element capabilities" )
476
+
477
+#define ECONNRESET_8021X_FAILURE __einfo_error				\
478
+	( EINFO_ECONNRESET_8021X_FAILURE )
479
+#define EINFO_ECONNRESET_8021X_FAILURE __einfo_uniqify			\
480
+	( EINFO_ECONNRESET,						\
481
+	  ( IEEE80211_REASON_8021X_FAILURE & 0x1f ),			\
482
+	  "IEEE 802.1X authentication failed" )
483
+
484
+#define ECONNRESET_CIPHER_REJECTED __einfo_error			\
485
+	( EINFO_ECONNRESET_CIPHER_REJECTED )
486
+#define EINFO_ECONNRESET_CIPHER_REJECTED __einfo_uniqify		\
487
+	( EINFO_ECONNRESET,						\
488
+	  ( IEEE80211_REASON_CIPHER_REJECTED & 0x1f ),			\
489
+	  "Cipher suite rejected because of security policy" )
490
+
491
+#define ENETRESET_QOS_UNSPECIFIED __einfo_error				\
492
+	( EINFO_ENETRESET_QOS_UNSPECIFIED )
493
+#define EINFO_ENETRESET_QOS_UNSPECIFIED __einfo_uniqify			\
494
+	( EINFO_ENETRESET,						\
495
+	  ( IEEE80211_REASON_QOS_UNSPECIFIED & 0x1f ),			\
496
+	  "Disassociated for unspecified, QoS-related reason" )
497
+
498
+#define ENETRESET_QOS_OUT_OF_RESOURCES __einfo_error			\
499
+	( EINFO_ENETRESET_QOS_OUT_OF_RESOURCES )
500
+#define EINFO_ENETRESET_QOS_OUT_OF_RESOURCES __einfo_uniqify		\
501
+	( EINFO_ENETRESET,						\
502
+	  ( IEEE80211_REASON_QOS_OUT_OF_RESOURCES & 0x1f ),		\
503
+	  "Disassociated; QoS AP is out of QoS resources" )
504
+
505
+#define ENETRESET_LINK_IS_HORRIBLE __einfo_error			\
506
+	( EINFO_ENETRESET_LINK_IS_HORRIBLE )
507
+#define EINFO_ENETRESET_LINK_IS_HORRIBLE __einfo_uniqify		\
508
+	( EINFO_ENETRESET,						\
509
+	  ( IEEE80211_REASON_LINK_IS_HORRIBLE & 0x1f ),			\
510
+	  "Disassociated due to excessively poor link" )
511
+
512
+#define ENETRESET_INVALID_TXOP __einfo_error				\
513
+	( EINFO_ENETRESET_INVALID_TXOP )
514
+#define EINFO_ENETRESET_INVALID_TXOP __einfo_uniqify			\
515
+	( EINFO_ENETRESET,						\
516
+	  ( IEEE80211_REASON_INVALID_TXOP & 0x1f ),			\
517
+	  "Disassociated due to TXOP limit violation" )
518
+
519
+#define ENETRESET_REQUESTED_LEAVING __einfo_error			\
520
+	( EINFO_ENETRESET_REQUESTED_LEAVING )
521
+#define EINFO_ENETRESET_REQUESTED_LEAVING __einfo_uniqify		\
522
+	( EINFO_ENETRESET,						\
523
+	  ( IEEE80211_REASON_REQUESTED_LEAVING & 0x1f ),		\
524
+	  "Requested; STA is leaving the BSS (or resetting)" )
525
+
526
+#define ENETRESET_REQUESTED_NO_USE __einfo_error			\
527
+	( EINFO_ENETRESET_REQUESTED_NO_USE )
528
+#define EINFO_ENETRESET_REQUESTED_NO_USE __einfo_uniqify		\
529
+	( EINFO_ENETRESET,						\
530
+	  ( IEEE80211_REASON_REQUESTED_NO_USE & 0x1f ),			\
531
+	  "Requested; does not want to use the mechanism" )
532
+
533
+#define ENETRESET_REQUESTED_NEED_SETUP __einfo_error			\
534
+	( EINFO_ENETRESET_REQUESTED_NEED_SETUP )
535
+#define EINFO_ENETRESET_REQUESTED_NEED_SETUP __einfo_uniqify		\
536
+	( EINFO_ENETRESET,						\
537
+	  ( IEEE80211_REASON_REQUESTED_NEED_SETUP & 0x1f ),		\
538
+	  "Requested; setup is required" )
539
+
540
+#define ENETRESET_REQUESTED_TIMEOUT __einfo_error			\
541
+	( EINFO_ENETRESET_REQUESTED_TIMEOUT )
542
+#define EINFO_ENETRESET_REQUESTED_TIMEOUT __einfo_uniqify		\
543
+	( EINFO_ENETRESET,						\
544
+	  ( IEEE80211_REASON_REQUESTED_TIMEOUT & 0x1f ),		\
545
+	  "Requested from peer STA due to timeout" )
546
+
547
+#define ENETRESET_CIPHER_UNSUPPORTED __einfo_error			\
548
+	( EINFO_ENETRESET_CIPHER_UNSUPPORTED )
549
+#define EINFO_ENETRESET_CIPHER_UNSUPPORTED __einfo_uniqify		\
550
+	( EINFO_ENETRESET,						\
551
+	  ( IEEE80211_REASON_CIPHER_UNSUPPORTED & 0x1f ),		\
552
+	  "Peer STA does not support requested cipher suite" )
553
+
554
+/** Make return status code from 802.11 status code */
555
+#define E80211_STATUS( stat )						\
556
+	EUNIQ ( ( ( stat & 0x20 ) ? EHOSTUNREACH : ECONNREFUSED ),	\
557
+		( stat &0x1f ),						\
558
+		ECONNREFUSED_FAILURE,					\
559
+		ECONNREFUSED_CAPAB_UNSUPP,				\
560
+		ECONNREFUSED_REASSOC_INVALID,				\
561
+		ECONNREFUSED_ASSOC_DENIED,				\
562
+		ECONNREFUSED_AUTH_ALGO_UNSUPP,				\
563
+		ECONNREFUSED_AUTH_SEQ_INVALID,				\
564
+		ECONNREFUSED_AUTH_CHALL_INVALID,			\
565
+		ECONNREFUSED_AUTH_TIMEOUT,				\
566
+		ECONNREFUSED_ASSOC_NO_ROOM,				\
567
+		ECONNREFUSED_ASSOC_NEED_RATE,				\
568
+		ECONNREFUSED_ASSOC_NEED_SHORT_PMBL,			\
569
+		ECONNREFUSED_ASSOC_NEED_PBCC,				\
570
+		ECONNREFUSED_ASSOC_NEED_CHAN_AGILITY,			\
571
+		ECONNREFUSED_ASSOC_NEED_SPECTRUM_MGMT,			\
572
+		ECONNREFUSED_ASSOC_BAD_POWER,				\
573
+		ECONNREFUSED_ASSOC_BAD_CHANNELS,			\
574
+		ECONNREFUSED_ASSOC_NEED_SHORT_SLOT,			\
575
+		ECONNREFUSED_ASSOC_NEED_DSSS_OFDM,			\
576
+		EHOSTUNREACH_QOS_FAILURE,				\
577
+		EHOSTUNREACH_QOS_NO_ROOM,				\
578
+		EHOSTUNREACH_LINK_IS_HORRIBLE,				\
579
+		EHOSTUNREACH_ASSOC_NEED_QOS,				\
580
+		EHOSTUNREACH_REQUEST_DECLINED,				\
581
+		EHOSTUNREACH_REQUEST_INVALID,				\
582
+		EHOSTUNREACH_TS_NOT_CREATED_AGAIN,			\
583
+		EHOSTUNREACH_INVALID_IE,				\
584
+		EHOSTUNREACH_GROUP_CIPHER_INVALID,			\
585
+		EHOSTUNREACH_PAIR_CIPHER_INVALID,			\
586
+		EHOSTUNREACH_AKMP_INVALID,				\
587
+		EHOSTUNREACH_RSN_VERSION_UNSUPP,			\
588
+		EHOSTUNREACH_RSN_CAPAB_INVALID,				\
589
+		EHOSTUNREACH_CIPHER_REJECTED,				\
590
+		EHOSTUNREACH_TS_NOT_CREATED_WAIT,			\
591
+		EHOSTUNREACH_DIRECT_LINK_FORBIDDEN,			\
592
+		EHOSTUNREACH_DEST_NOT_PRESENT,				\
593
+		EHOSTUNREACH_DEST_NOT_QOS,				\
594
+		EHOSTUNREACH_ASSOC_LISTEN_TOO_HIGH )
595
+
596
+/** Make return status code from 802.11 reason code */
597
+#define E80211_REASON( reas )						\
598
+	EUNIQ ( ( ( reas & 0x20 ) ? ENETRESET : ECONNRESET ),		\
599
+		( reas & 0x1f ),					\
600
+		ECONNRESET_UNSPECIFIED,					\
601
+		ECONNRESET_AUTH_NO_LONGER_VALID,			\
602
+		ECONNRESET_LEAVING,					\
603
+		ECONNRESET_INACTIVITY,					\
604
+		ECONNRESET_OUT_OF_RESOURCES,				\
605
+		ECONNRESET_NEED_AUTH,					\
606
+		ECONNRESET_NEED_ASSOC,					\
607
+		ECONNRESET_LEAVING_TO_ROAM,				\
608
+		ECONNRESET_REASSOC_INVALID,				\
609
+		ECONNRESET_BAD_POWER,					\
610
+		ECONNRESET_BAD_CHANNELS,				\
611
+		ECONNRESET_INVALID_IE,					\
612
+		ECONNRESET_MIC_FAILURE,					\
613
+		ECONNRESET_4WAY_TIMEOUT,				\
614
+		ECONNRESET_GROUPKEY_TIMEOUT,				\
615
+		ECONNRESET_4WAY_INVALID,				\
616
+		ECONNRESET_GROUP_CIPHER_INVALID,			\
617
+		ECONNRESET_PAIR_CIPHER_INVALID,				\
618
+		ECONNRESET_AKMP_INVALID,				\
619
+		ECONNRESET_RSN_VERSION_INVALID,				\
620
+		ECONNRESET_RSN_CAPAB_INVALID,				\
621
+		ECONNRESET_8021X_FAILURE,				\
622
+		ECONNRESET_CIPHER_REJECTED,				\
623
+		ENETRESET_QOS_UNSPECIFIED,				\
624
+		ENETRESET_QOS_OUT_OF_RESOURCES,				\
625
+		ENETRESET_LINK_IS_HORRIBLE,				\
626
+		ENETRESET_INVALID_TXOP,					\
627
+		ENETRESET_REQUESTED_LEAVING,				\
628
+		ENETRESET_REQUESTED_NO_USE,				\
629
+		ENETRESET_REQUESTED_NEED_SETUP,				\
630
+		ENETRESET_REQUESTED_TIMEOUT,				\
631
+		ENETRESET_CIPHER_UNSUPPORTED )
632
+
633
+#endif /* _IPXE_NET80211_ERR_H */

+ 16
- 40
src/net/80211/net80211.c View File

23
 #include <string.h>
23
 #include <string.h>
24
 #include <byteswap.h>
24
 #include <byteswap.h>
25
 #include <stdlib.h>
25
 #include <stdlib.h>
26
+#include <unistd.h>
27
+#include <errno.h>
26
 #include <ipxe/settings.h>
28
 #include <ipxe/settings.h>
27
 #include <ipxe/if_arp.h>
29
 #include <ipxe/if_arp.h>
28
 #include <ipxe/ethernet.h>
30
 #include <ipxe/ethernet.h>
32
 #include <ipxe/sec80211.h>
34
 #include <ipxe/sec80211.h>
33
 #include <ipxe/timer.h>
35
 #include <ipxe/timer.h>
34
 #include <ipxe/nap.h>
36
 #include <ipxe/nap.h>
35
-#include <unistd.h>
36
-#include <errno.h>
37
+#include <ipxe/errortab.h>
38
+#include <ipxe/net80211_err.h>
37
 
39
 
38
 /** @file
40
 /** @file
39
  *
41
  *
40
  * 802.11 device management
42
  * 802.11 device management
41
  */
43
  */
42
 
44
 
43
-/* Disambiguate the EINVAL's a bit */
44
-#define EINVAL_PKT_TOO_SHORT	( EINVAL | EUNIQ_01 )
45
-#define EINVAL_PKT_VERSION	( EINVAL | EUNIQ_02 )
46
-#define EINVAL_PKT_NOT_DATA	( EINVAL | EUNIQ_03 )
47
-#define EINVAL_PKT_NOT_FROMDS	( EINVAL | EUNIQ_04 )
48
-#define EINVAL_PKT_LLC_HEADER	( EINVAL | EUNIQ_05 )
49
-#define EINVAL_CRYPTO_REQUEST	( EINVAL | EUNIQ_06 )
50
-#define EINVAL_ACTIVE_SCAN	( EINVAL | EUNIQ_07 )
51
-
52
-/*
53
- * 802.11 error codes: The AP can give us a status code explaining why
54
- * authentication failed, or a reason code explaining why we were
55
- * deauthenticated/disassociated. These codes range from 0-63 (the
56
- * field is 16 bits wide, but only up to 45 or so are defined yet; we
57
- * allow up to 63 for extensibility). This is encoded into an error
58
- * code as such:
59
- *
60
- *                                      status & 0x1f goes here --vv--
61
- *   Status code 0-31:  ECONNREFUSED | EUNIQ_(status & 0x1f) (0e1a6038)
62
- *   Status code 32-63: EHOSTUNREACH | EUNIQ_(status & 0x1f) (171a6011)
63
- *   Reason code 0-31:  ECONNRESET | EUNIQ_(reason & 0x1f)   (0f1a6039)
64
- *   Reason code 32-63: ENETRESET | EUNIQ_(reason & 0x1f)    (271a6001)
65
- *
66
- * The POSIX error codes more or less convey the appropriate message
67
- * (status codes occur when we can't associate at all, reason codes
68
- * when we lose association unexpectedly) and let us extract the
69
- * complete 802.11 error code from the rc value.
70
- */
71
-
72
-/** Make return status code from 802.11 status code */
73
-#define E80211_STATUS( stat )  ( ((stat & 0x20)? EHOSTUNREACH : ECONNREFUSED) \
74
-					| ((stat & 0x1f) << 8) )
75
-
76
-/** Make return status code from 802.11 reason code */
77
-#define E80211_REASON( reas )  ( ((reas & 0x20)? ENETRESET : ECONNRESET) \
78
-					| ((reas & 0x1f) << 8) )
79
-
80
-
81
 /** List of 802.11 devices */
45
 /** List of 802.11 devices */
82
 static struct list_head net80211_devices = LIST_HEAD_INIT ( net80211_devices );
46
 static struct list_head net80211_devices = LIST_HEAD_INIT ( net80211_devices );
83
 
47
 
2838
 	/* Pass completion onward */
2802
 	/* Pass completion onward */
2839
 	netdev_tx_complete_err ( dev->netdev, iob, rc );
2803
 	netdev_tx_complete_err ( dev->netdev, iob, rc );
2840
 }
2804
 }
2805
+
2806
+/** Common 802.11 errors */
2807
+struct errortab common_wireless_errors[] __errortab = {
2808
+	__einfo_errortab ( EINFO_EINVAL_CRYPTO_REQUEST ),
2809
+	__einfo_errortab ( EINFO_ECONNRESET_UNSPECIFIED ),
2810
+	__einfo_errortab ( EINFO_ECONNRESET_INACTIVITY ),
2811
+	__einfo_errortab ( EINFO_ECONNRESET_4WAY_TIMEOUT ),
2812
+	__einfo_errortab ( EINFO_ECONNRESET_8021X_FAILURE ),
2813
+	__einfo_errortab ( EINFO_ECONNREFUSED_FAILURE ),
2814
+	__einfo_errortab ( EINFO_ECONNREFUSED_ASSOC_DENIED ),
2815
+	__einfo_errortab ( EINFO_ECONNREFUSED_AUTH_ALGO_UNSUPP ),
2816
+};

+ 15
- 1
src/net/80211/sec80211.c View File

34
  * static data in this file.
34
  * static data in this file.
35
  */
35
  */
36
 
36
 
37
+/* Unsupported cryptosystem error numbers */
38
+#define ENOTSUP_WEP __einfo_error ( EINFO_ENOTSUP_WEP )
39
+#define EINFO_ENOTSUP_WEP __einfo_uniqify ( EINFO_ENOTSUP, \
40
+	( 0x10 | NET80211_CRYPT_WEP ), "WEP not supported" )
41
+#define ENOTSUP_TKIP __einfo_error ( EINFO_ENOTSUP_TKIP )
42
+#define EINFO_ENOTSUP_TKIP __einfo_uniqify ( EINFO_ENOTSUP, \
43
+	( 0x10 | NET80211_CRYPT_TKIP ), "TKIP not supported" )
44
+#define ENOTSUP_CCMP __einfo_error ( EINFO_ENOTSUP_CCMP )
45
+#define EINFO_ENOTSUP_CCMP __einfo_uniqify ( EINFO_ENOTSUP, \
46
+	( 0x10 | NET80211_CRYPT_CCMP ), "CCMP not supported" )
47
+#define ENOTSUP_CRYPT( crypt )		     \
48
+	EUNIQ ( ENOTSUP, ( 0x10 | (crypt) ), \
49
+		ENOTSUP_WEP, ENOTSUP_TKIP, ENOTSUP_CCMP )
50
+
37
 /** Mapping from net80211 crypto/secprot types to RSN OUI descriptors */
51
 /** Mapping from net80211 crypto/secprot types to RSN OUI descriptors */
38
 struct descriptor_map {
52
 struct descriptor_map {
39
 	/** Value of net80211_crypto_alg or net80211_security_proto */
53
 	/** Value of net80211_crypto_alg or net80211_security_proto */
130
 
144
 
131
 	if ( ! crypto ) {
145
 	if ( ! crypto ) {
132
 		DBG ( "802.11-Sec no support for cryptosystem %d\n", crypt );
146
 		DBG ( "802.11-Sec no support for cryptosystem %d\n", crypt );
133
-		return -( ENOTSUP | EUNIQ_10 | ( crypt << 8 ) );
147
+		return -ENOTSUP_CRYPT ( crypt );
134
 	}
148
 	}
135
 
149
 
136
 	*which = crypto;
150
 	*which = crypto;

+ 8
- 4
src/net/infiniband.c View File

50
 static struct list_head open_ib_devices = LIST_HEAD_INIT ( open_ib_devices );
50
 static struct list_head open_ib_devices = LIST_HEAD_INIT ( open_ib_devices );
51
 
51
 
52
 /* Disambiguate the various possible EINPROGRESSes */
52
 /* Disambiguate the various possible EINPROGRESSes */
53
-#define EINPROGRESS_INIT ( EINPROGRESS | EUNIQ_01 )
54
-#define EINPROGRESS_ARMED ( EINPROGRESS | EUNIQ_02 )
53
+#define EINPROGRESS_INIT __einfo_error ( EINFO_EINPROGRESS_INIT )
54
+#define EINFO_EINPROGRESS_INIT __einfo_uniqify \
55
+	( EINFO_EINPROGRESS, 0x01, "Initialising" )
56
+#define EINPROGRESS_ARMED __einfo_error ( EINFO_EINPROGRESS_ARMED )
57
+#define EINFO_EINPROGRESS_ARMED __einfo_uniqify \
58
+	( EINFO_EINPROGRESS, 0x02, "Armed" )
55
 
59
 
56
 /** Human-readable message for the link statuses */
60
 /** Human-readable message for the link statuses */
57
 struct errortab infiniband_errors[] __errortab = {
61
 struct errortab infiniband_errors[] __errortab = {
58
-	{ EINPROGRESS_INIT, "Initialising" },
59
-	{ EINPROGRESS_ARMED, "Armed" },
62
+	__einfo_errortab ( EINFO_EINPROGRESS_INIT ),
63
+	__einfo_errortab ( EINFO_EINPROGRESS_ARMED ),
60
 };
64
 };
61
 
65
 
62
 /***************************************************************************
66
 /***************************************************************************

+ 9
- 4
src/net/infiniband/ib_srp.c View File

46
  */
46
  */
47
 
47
 
48
 /* Disambiguate the various possible EINVALs */
48
 /* Disambiguate the various possible EINVALs */
49
-#define EINVAL_BYTE_STRING_LEN ( EINVAL | EUNIQ_01 )
50
-#define EINVAL_BYTE_STRING ( EINVAL | EUNIQ_02 )
51
-#define EINVAL_INTEGER ( EINVAL | EUNIQ_03 )
52
-#define EINVAL_RP_TOO_SHORT ( EINVAL | EUNIQ_04 )
49
+#define EINVAL_BYTE_STRING_LEN __einfo_error ( EINFO_EINVAL_BYTE_STRING_LEN )
50
+#define EINFO_EINVAL_BYTE_STRING_LEN __einfo_uniqify \
51
+	( EINFO_EINVAL, 0x01, "Invalid byte string length" )
52
+#define EINVAL_INTEGER __einfo_error ( EINFO_EINVAL_INTEGER )
53
+#define EINFO_EINVAL_INTEGER __einfo_uniqify \
54
+	( EINFO_EINVAL, 0x03, "Invalid integer" )
55
+#define EINVAL_RP_TOO_SHORT __einfo_error ( EINFO_EINVAL_RP_TOO_SHORT )
56
+#define EINFO_EINVAL_RP_TOO_SHORT __einfo_uniqify \
57
+	( EINFO_EINVAL, 0x04, "Root path too short" )
53
 
58
 
54
 /** IB SRP parse flags */
59
 /** IB SRP parse flags */
55
 enum ib_srp_parse_flags {
60
 enum ib_srp_parse_flags {

+ 9
- 11
src/net/netdevice.c View File

46
 static struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
46
 static struct list_head open_net_devices = LIST_HEAD_INIT ( open_net_devices );
47
 
47
 
48
 /** Default link status code */
48
 /** Default link status code */
49
-#define EUNKNOWN_LINK_STATUS EINPROGRESS
49
+#define EUNKNOWN_LINK_STATUS __einfo_error ( EINFO_EUNKNOWN_LINK_STATUS )
50
+#define EINFO_EUNKNOWN_LINK_STATUS \
51
+	__einfo_uniqify ( EINFO_EINPROGRESS, 0x01, "Unknown" )
50
 
52
 
51
 /** Human-readable message for the default link status */
53
 /** Human-readable message for the default link status */
52
 struct errortab netdev_errors[] __errortab = {
54
 struct errortab netdev_errors[] __errortab = {
53
-	{ EUNKNOWN_LINK_STATUS, "Unknown" },
55
+	__einfo_errortab ( EINFO_EUNKNOWN_LINK_STATUS ),
54
 };
56
 };
55
 
57
 
56
 /**
58
 /**
60
  */
62
  */
61
 void netdev_link_down ( struct net_device *netdev ) {
63
 void netdev_link_down ( struct net_device *netdev ) {
62
 
64
 
63
-	switch ( netdev->link_rc ) {
64
-	case 0:
65
-	case -EUNKNOWN_LINK_STATUS:
65
+	/* Avoid clobbering a more detailed link status code, if one
66
+	 * is already set.
67
+	 */
68
+	if ( ( netdev->link_rc == 0 ) ||
69
+	     ( netdev->link_rc == -EUNKNOWN_LINK_STATUS ) ) {
66
 		netdev->link_rc = -ENOTCONN;
70
 		netdev->link_rc = -ENOTCONN;
67
-		break;
68
-	default:
69
-		/* Avoid clobbering a more detailed link status code,
70
-		 * if one is already set.
71
-		 */
72
-		break;
73
 	}
71
 	}
74
 }
72
 }
75
 
73
 

+ 44
- 11
src/net/tcp/iscsi.c View File

48
 FEATURE ( FEATURE_PROTOCOL, "iSCSI", DHCP_EB_FEATURE_ISCSI, 1 );
48
 FEATURE ( FEATURE_PROTOCOL, "iSCSI", DHCP_EB_FEATURE_ISCSI, 1 );
49
 
49
 
50
 /* Disambiguate the various error causes */
50
 /* Disambiguate the various error causes */
51
-#define EACCES_INCORRECT_TARGET_USERNAME ( EACCES | EUNIQ_01 )
52
-#define EACCES_INCORRECT_TARGET_PASSWORD ( EACCES | EUNIQ_02 )
53
-#define ENOTSUP_INITIATOR_STATUS ( ENOTSUP | EUNIQ_01 )
54
-#define ENOTSUP_OPCODE ( ENOTSUP | EUNIQ_02 )
55
-#define ENOTSUP_DISCOVERY ( ENOTSUP | EUNIQ_03 )
56
-#define EPERM_INITIATOR_AUTHENTICATION ( EPERM | EUNIQ_01 )
57
-#define EPERM_INITIATOR_AUTHORISATION ( EPERM | EUNIQ_02 )
58
-#define EPROTO_INVALID_CHAP_ALGORITHM ( EPROTO | EUNIQ_01 )
59
-#define EPROTO_INVALID_CHAP_IDENTIFIER ( EPROTO | EUNIQ_02 )
60
-#define EPROTO_INVALID_LARGE_BINARY ( EPROTO | EUNIQ_03 )
61
-#define EPROTO_INVALID_CHAP_RESPONSE ( EPROTO | EUNIQ_04 )
51
+#define EACCES_INCORRECT_TARGET_USERNAME \
52
+	__einfo_error ( EINFO_EACCES_INCORRECT_TARGET_USERNAME )
53
+#define EINFO_EACCES_INCORRECT_TARGET_USERNAME \
54
+	__einfo_uniqify ( EINFO_EACCES, 0x01, "Incorrect target username" )
55
+#define EACCES_INCORRECT_TARGET_PASSWORD \
56
+	__einfo_error ( EINFO_EACCES_INCORRECT_TARGET_PASSWORD )
57
+#define EINFO_EACCES_INCORRECT_TARGET_PASSWORD \
58
+	__einfo_uniqify ( EINFO_EACCES, 0x02, "Incorrect target password" )
59
+#define ENOTSUP_INITIATOR_STATUS \
60
+	__einfo_error ( EINFO_ENOTSUP_INITIATOR_STATUS )
61
+#define EINFO_ENOTSUP_INITIATOR_STATUS \
62
+	__einfo_uniqify ( EINFO_ENOTSUP, 0x01, "Unsupported initiator status" )
63
+#define ENOTSUP_OPCODE \
64
+	__einfo_error ( EINFO_ENOTSUP_OPCODE )
65
+#define EINFO_ENOTSUP_OPCODE \
66
+	__einfo_uniqify ( EINFO_ENOTSUP, 0x02, "Unsupported opcode" )
67
+#define ENOTSUP_DISCOVERY \
68
+	__einfo_error ( EINFO_ENOTSUP_DISCOVERY )
69
+#define EINFO_ENOTSUP_DISCOVERY \
70
+	__einfo_uniqify ( EINFO_ENOTSUP, 0x03, "Discovery not supported" )
71
+#define EPERM_INITIATOR_AUTHENTICATION \
72
+	__einfo_error ( EINFO_EPERM_INITIATOR_AUTHENTICATION )
73
+#define EINFO_EPERM_INITIATOR_AUTHENTICATION \
74
+	__einfo_uniqify ( EINFO_EPERM, 0x01, "Initiator authentication failed" )
75
+#define EPERM_INITIATOR_AUTHORISATION \
76
+	__einfo_error ( EINFO_EPERM_INITIATOR_AUTHORISATION )
77
+#define EINFO_EPERM_INITIATOR_AUTHORISATION \
78
+	__einfo_uniqify ( EINFO_EPERM, 0x02, "Initiator not authorised" )
79
+#define EPROTO_INVALID_CHAP_ALGORITHM \
80
+	__einfo_error ( EINFO_EPROTO_INVALID_CHAP_ALGORITHM )
81
+#define EINFO_EPROTO_INVALID_CHAP_ALGORITHM \
82
+	__einfo_uniqify ( EINFO_EPROTO, 0x01, "Invalid CHAP algorithm" )
83
+#define EPROTO_INVALID_CHAP_IDENTIFIER \
84
+	__einfo_error ( EINFO_EPROTO_INVALID_CHAP_IDENTIFIER )
85
+#define EINFO_EPROTO_INVALID_CHAP_IDENTIFIER \
86
+	__einfo_uniqify ( EINFO_EPROTO, 0x02, "Invalid CHAP identifier" )
87
+#define EPROTO_INVALID_LARGE_BINARY \
88
+	__einfo_error ( EINFO_EPROTO_INVALID_LARGE_BINARY )
89
+#define EINFO_EPROTO_INVALID_LARGE_BINARY \
90
+	__einfo_uniqify ( EINFO_EPROTO, 0x03, "Invalid large binary" )
91
+#define EPROTO_INVALID_CHAP_RESPONSE \
92
+	__einfo_error ( EINFO_EPROTO_INVALID_CHAP_RESPONSE )
93
+#define EINFO_EPROTO_INVALID_CHAP_RESPONSE \
94
+	__einfo_uniqify ( EINFO_EPROTO, 0x04, "Invalid CHAP response" )
62
 
95
 
63
 /** iSCSI initiator name (explicitly specified) */
96
 /** iSCSI initiator name (explicitly specified) */
64
 static char *iscsi_explicit_initiator_iqn;
97
 static char *iscsi_explicit_initiator_iqn;

+ 44
- 27
src/net/udp/tftp.c View File

48
 FEATURE ( FEATURE_PROTOCOL, "TFTP", DHCP_EB_FEATURE_TFTP, 1 );
48
 FEATURE ( FEATURE_PROTOCOL, "TFTP", DHCP_EB_FEATURE_TFTP, 1 );
49
 
49
 
50
 /* TFTP-specific error codes */
50
 /* TFTP-specific error codes */
51
-#define ETFTP_INVALID_BLKSIZE	EUNIQ_01
52
-#define ETFTP_INVALID_TSIZE	EUNIQ_02
53
-#define ETFTP_MC_NO_PORT	EUNIQ_03
54
-#define ETFTP_MC_NO_MC		EUNIQ_04
55
-#define ETFTP_MC_INVALID_MC	EUNIQ_05
56
-#define ETFTP_MC_INVALID_IP	EUNIQ_06
57
-#define ETFTP_MC_INVALID_PORT	EUNIQ_07
51
+#define EINVAL_BLKSIZE 	__einfo_error ( EINFO_EINVAL_BLKSIZE )
52
+#define EINFO_EINVAL_BLKSIZE __einfo_uniqify \
53
+	( EINFO_EINVAL, 0x01, "Invalid blksize" )
54
+#define EINVAL_TSIZE __einfo_error ( EINFO_EINVAL_TSIZE )
55
+#define EINFO_EINVAL_TSIZE __einfo_uniqify \
56
+	( EINFO_EINVAL, 0x02, "Invalid tsize" )
57
+#define EINVAL_MC_NO_PORT __einfo_error ( EINFO_EINVAL_MC_NO_PORT )
58
+#define EINFO_EINVAL_MC_NO_PORT __einfo_uniqify \
59
+	( EINFO_EINVAL, 0x03, "Missing multicast port" )
60
+#define EINVAL_MC_NO_MC __einfo_error ( EINFO_EINVAL_MC_NO_MC )
61
+#define EINFO_EINVAL_MC_NO_MC __einfo_uniqify \
62
+	( EINFO_EINVAL, 0x04, "Missing multicast mc" )
63
+#define EINVAL_MC_INVALID_MC __einfo_error ( EINFO_EINVAL_MC_INVALID_MC )
64
+#define EINFO_EINVAL_MC_INVALID_MC __einfo_uniqify \
65
+	( EINFO_EINVAL, 0x05, "Missing multicast IP" )
66
+#define EINVAL_MC_INVALID_IP __einfo_error ( EINFO_EINVAL_MC_INVALID_IP )
67
+#define EINFO_EINVAL_MC_INVALID_IP __einfo_uniqify \
68
+	( EINFO_EINVAL, 0x06, "Invalid multicast IP" )
69
+#define EINVAL_MC_INVALID_PORT __einfo_error ( EINFO_EINVAL_MC_INVALID_PORT )
70
+#define EINFO_EINVAL_MC_INVALID_PORT __einfo_uniqify \
71
+	( EINFO_EINVAL, 0x07, "Invalid multicast port" )
58
 
72
 
59
 /**
73
 /**
60
  * A TFTP request
74
  * A TFTP request
560
 	if ( *end ) {
574
 	if ( *end ) {
561
 		DBGC ( tftp, "TFTP %p got invalid blksize \"%s\"\n",
575
 		DBGC ( tftp, "TFTP %p got invalid blksize \"%s\"\n",
562
 		       tftp, value );
576
 		       tftp, value );
563
-		return -( EINVAL | ETFTP_INVALID_BLKSIZE );
577
+		return -EINVAL_BLKSIZE;
564
 	}
578
 	}
565
 	DBGC ( tftp, "TFTP %p blksize=%d\n", tftp, tftp->blksize );
579
 	DBGC ( tftp, "TFTP %p blksize=%d\n", tftp, tftp->blksize );
566
 
580
 
582
 	if ( *end ) {
596
 	if ( *end ) {
583
 		DBGC ( tftp, "TFTP %p got invalid tsize \"%s\"\n",
597
 		DBGC ( tftp, "TFTP %p got invalid tsize \"%s\"\n",
584
 		       tftp, value );
598
 		       tftp, value );
585
-		return -( EINVAL | ETFTP_INVALID_TSIZE );
599
+		return -EINVAL_TSIZE;
586
 	}
600
 	}
587
 	DBGC ( tftp, "TFTP %p tsize=%ld\n", tftp, tftp->tsize );
601
 	DBGC ( tftp, "TFTP %p tsize=%ld\n", tftp, tftp->tsize );
588
 
602
 
616
 	port = strchr ( addr, ',' );
630
 	port = strchr ( addr, ',' );
617
 	if ( ! port ) {
631
 	if ( ! port ) {
618
 		DBGC ( tftp, "TFTP %p multicast missing port,mc\n", tftp );
632
 		DBGC ( tftp, "TFTP %p multicast missing port,mc\n", tftp );
619
-		return -( EINVAL | ETFTP_MC_NO_PORT );
633
+		return -EINVAL_MC_NO_PORT;
620
 	}
634
 	}
621
 	*(port++) = '\0';
635
 	*(port++) = '\0';
622
 	mc = strchr ( port, ',' );
636
 	mc = strchr ( port, ',' );
623
 	if ( ! mc ) {
637
 	if ( ! mc ) {
624
 		DBGC ( tftp, "TFTP %p multicast missing mc\n", tftp );
638
 		DBGC ( tftp, "TFTP %p multicast missing mc\n", tftp );
625
-		return -( EINVAL | ETFTP_MC_NO_MC );
639
+		return -EINVAL_MC_NO_MC;
626
 	}
640
 	}
627
 	*(mc++) = '\0';
641
 	*(mc++) = '\0';
628
 
642
 
631
 		tftp->flags &= ~TFTP_FL_SEND_ACK;
645
 		tftp->flags &= ~TFTP_FL_SEND_ACK;
632
 	if ( *mc_end ) {
646
 	if ( *mc_end ) {
633
 		DBGC ( tftp, "TFTP %p multicast invalid mc %s\n", tftp, mc );
647
 		DBGC ( tftp, "TFTP %p multicast invalid mc %s\n", tftp, mc );
634
-		return -( EINVAL | ETFTP_MC_INVALID_MC );
648
+		return -EINVAL_MC_INVALID_MC;
635
 	}
649
 	}
636
 	DBGC ( tftp, "TFTP %p is%s the master client\n",
650
 	DBGC ( tftp, "TFTP %p is%s the master client\n",
637
 	       tftp, ( ( tftp->flags & TFTP_FL_SEND_ACK ) ? "" : " not" ) );
651
 	       tftp, ( ( tftp->flags & TFTP_FL_SEND_ACK ) ? "" : " not" ) );
640
 		if ( inet_aton ( addr, &socket.sin.sin_addr ) == 0 ) {
654
 		if ( inet_aton ( addr, &socket.sin.sin_addr ) == 0 ) {
641
 			DBGC ( tftp, "TFTP %p multicast invalid IP address "
655
 			DBGC ( tftp, "TFTP %p multicast invalid IP address "
642
 			       "%s\n", tftp, addr );
656
 			       "%s\n", tftp, addr );
643
-			return -( EINVAL | ETFTP_MC_INVALID_IP );
657
+			return -EINVAL_MC_INVALID_IP;
644
 		}
658
 		}
645
 		DBGC ( tftp, "TFTP %p multicast IP address %s\n",
659
 		DBGC ( tftp, "TFTP %p multicast IP address %s\n",
646
 		       tftp, inet_ntoa ( socket.sin.sin_addr ) );
660
 		       tftp, inet_ntoa ( socket.sin.sin_addr ) );
648
 		if ( *port_end ) {
662
 		if ( *port_end ) {
649
 			DBGC ( tftp, "TFTP %p multicast invalid port %s\n",
663
 			DBGC ( tftp, "TFTP %p multicast invalid port %s\n",
650
 			       tftp, port );
664
 			       tftp, port );
651
-			return -( EINVAL | ETFTP_MC_INVALID_PORT );
665
+			return -EINVAL_MC_INVALID_PORT;
652
 		}
666
 		}
653
 		DBGC ( tftp, "TFTP %p multicast port %d\n",
667
 		DBGC ( tftp, "TFTP %p multicast port %d\n",
654
 		       tftp, ntohs ( socket.sin.sin_port ) );
668
 		       tftp, ntohs ( socket.sin.sin_port ) );
872
 	return rc;
886
 	return rc;
873
 }
887
 }
874
 
888
 
875
-/** Translation between TFTP errors and internal error numbers */
876
-static const int tftp_errors[] = {
877
-	[TFTP_ERR_FILE_NOT_FOUND]	= ENOENT,
878
-	[TFTP_ERR_ACCESS_DENIED]	= EACCES,
879
-	[TFTP_ERR_ILLEGAL_OP]		= ENOTSUP,
880
-};
889
+/**
890
+ * Convert TFTP error code to return status code
891
+ *
892
+ * @v errcode		TFTP error code
893
+ * @ret rc		Return status code
894
+ */
895
+static int tftp_errcode_to_rc ( unsigned int errcode ) {
896
+	switch ( errcode ) {
897
+	case TFTP_ERR_FILE_NOT_FOUND:	return -ENOENT;
898
+	case TFTP_ERR_ACCESS_DENIED:	return -EACCES;
899
+	case TFTP_ERR_ILLEGAL_OP:	return -ENOTTY;
900
+	default:			return -ENOTSUP;
901
+	}
902
+}
881
 
903
 
882
 /**
904
 /**
883
  * Receive ERROR
905
  * Receive ERROR
889
  */
911
  */
890
 static int tftp_rx_error ( struct tftp_request *tftp, void *buf, size_t len ) {
912
 static int tftp_rx_error ( struct tftp_request *tftp, void *buf, size_t len ) {
891
 	struct tftp_error *error = buf;
913
 	struct tftp_error *error = buf;
892
-	unsigned int err;
893
-	int rc = 0;
914
+	int rc;
894
 
915
 
895
 	/* Sanity check */
916
 	/* Sanity check */
896
 	if ( len < sizeof ( *error ) ) {
917
 	if ( len < sizeof ( *error ) ) {
903
 	       "\"%s\"\n", tftp, ntohs ( error->errcode ), error->errmsg );
924
 	       "\"%s\"\n", tftp, ntohs ( error->errcode ), error->errmsg );
904
 	
925
 	
905
 	/* Determine final operation result */
926
 	/* Determine final operation result */
906
-	err = ntohs ( error->errcode );
907
-	if ( err < ( sizeof ( tftp_errors ) / sizeof ( tftp_errors[0] ) ) )
908
-		rc = -tftp_errors[err];
909
-	if ( ! rc )
910
-		rc = -ENOTSUP;
927
+	rc = tftp_errcode_to_rc ( ntohs ( error->errcode ) );
911
 
928
 
912
 	/* Close TFTP request */
929
 	/* Close TFTP request */
913
 	tftp_done ( tftp, rc );
930
 	tftp_done ( tftp, rc );

+ 0
- 18
src/usr/iwmgmt.c View File

26
 #include <ipxe/ethernet.h>
26
 #include <ipxe/ethernet.h>
27
 #include <usr/ifmgmt.h>
27
 #include <usr/ifmgmt.h>
28
 #include <usr/iwmgmt.h>
28
 #include <usr/iwmgmt.h>
29
-#include <ipxe/errortab.h>
30
 
29
 
31
 /** @file
30
 /** @file
32
  *
31
  *
225
 		 dev->netdev->name, strerror ( rc ) );
224
 		 dev->netdev->name, strerror ( rc ) );
226
 	return rc;
225
 	return rc;
227
 }
226
 }
228
-
229
-
230
-/* Record error codes as though they come from the 802.11 stack */
231
-#undef ERRFILE
232
-#define ERRFILE ERRFILE_net80211
233
-
234
-/** Common 802.11 errors */
235
-struct errortab common_wireless_errors[] __errortab = {
236
-	{ EINVAL | EUNIQ_06, "Packet decryption error" },
237
-	{ ECONNRESET | EUNIQ_01, "Unspecified reason" },
238
-	{ ECONNRESET | EUNIQ_04, "Disassociated due to inactivity" },
239
-	{ ECONNRESET | EUNIQ_0F, "4-Way Handshake timeout" },
240
-	{ ECONNRESET | EUNIQ_17, "IEEE 802.1X authentication failed" },
241
-	{ ECONNREFUSED | EUNIQ_01, "Unspecified failure" },
242
-	{ ECONNREFUSED | EUNIQ_0C, "Association denied" },
243
-	{ ECONNREFUSED | EUNIQ_0D, "Authentication method not supported" },
244
-};

+ 1
- 0
src/util/.gitignore View File

6
 elf2efi64
6
 elf2efi64
7
 efirom
7
 efirom
8
 iccfix
8
 iccfix
9
+einfo

+ 167
- 0
src/util/einfo.c View File

1
+/*
2
+ * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
+ */
18
+
19
+#include <stddef.h>
20
+#include <stdint.h>
21
+#include <stdlib.h>
22
+#include <stdio.h>
23
+#include <errno.h>
24
+#include <sys/types.h>
25
+#include <sys/stat.h>
26
+#include <sys/mman.h>
27
+#include <unistd.h>
28
+#include <fcntl.h>
29
+#include <getopt.h>
30
+
31
+#define eprintf(...) fprintf ( stderr, __VA_ARGS__ )
32
+
33
+/** Command-line options */
34
+struct options {
35
+};
36
+
37
+/** Error usage information */
38
+struct einfo {
39
+	uint32_t size;
40
+	uint32_t error;
41
+	uint32_t desc;
42
+	uint32_t file;
43
+	uint32_t line;
44
+} __attribute__ (( packed ));
45
+
46
+/**
47
+ * Process einfo file
48
+ *
49
+ * @v infile		Filename
50
+ * @v opts		Command-line options
51
+ */
52
+static void einfo ( const char *infile, struct options *opts ) {
53
+	int fd;
54
+	struct stat stat;
55
+	size_t len;
56
+	void *start;
57
+	struct einfo *einfo;
58
+
59
+	/* Open einfo file */
60
+	if ( ( fd = open ( infile, O_RDONLY ) ) < 0 ) {
61
+		eprintf ( "Cannot open \"%s\": %s\n",
62
+			  infile, strerror ( errno ) );
63
+		exit ( 1 );
64
+	}
65
+
66
+	/* Get file size */
67
+	if ( fstat ( fd, &stat ) < 0 ) {
68
+		eprintf ( "Cannot stat \"%s\": %s\n",
69
+			  infile, strerror ( errno ) );
70
+		exit ( 1 );
71
+	}
72
+	len = stat.st_size;
73
+
74
+	if ( len ) {
75
+
76
+		/* Map file */
77
+		if ( ( start = mmap ( NULL, len, PROT_READ, MAP_SHARED,
78
+				      fd, 0 ) ) == MAP_FAILED ) {
79
+			eprintf ( "Cannot mmap \"%s\": %s\n",
80
+				  infile, strerror ( errno ) );
81
+			exit ( 1 );
82
+		}
83
+
84
+		/* Iterate over einfo records */
85
+		for ( einfo = start ; ( ( void * ) einfo ) < ( start + len ) ;
86
+		      einfo = ( ( ( void * ) einfo ) + einfo->size ) ) {
87
+			printf ( "%08x\t%s\t%d\t%s\n", einfo->error,
88
+				 ( ( ( void * ) einfo ) + einfo->file ),
89
+				 einfo->line,
90
+				 ( ( ( void * ) einfo ) + einfo->desc ) );
91
+		}
92
+
93
+	}
94
+
95
+	/* Unmap and close file */
96
+	munmap ( start, len );
97
+	close ( fd );
98
+}
99
+
100
+/**
101
+ * Print help
102
+ *
103
+ * @v program_name	Program name
104
+ */
105
+static void print_help ( const char *program_name ) {
106
+	eprintf ( "Syntax: %s file1.einfo [file2.einfo...]\n",
107
+		  program_name );
108
+}
109
+
110
+/**
111
+ * Parse command-line options
112
+ *
113
+ * @v argc		Argument count
114
+ * @v argv		Argument list
115
+ * @v opts		Options structure to populate
116
+ */
117
+static int parse_options ( const int argc, char **argv,
118
+			   struct options *opts ) {
119
+	char *end;
120
+	int c;
121
+
122
+	while (1) {
123
+		int option_index = 0;
124
+		static struct option long_options[] = {
125
+			{ "help", 0, NULL, 'h' },
126
+			{ 0, 0, 0, 0 }
127
+		};
128
+
129
+		if ( ( c = getopt_long ( argc, argv, "s:h",
130
+					 long_options,
131
+					 &option_index ) ) == -1 ) {
132
+			break;
133
+		}
134
+
135
+		switch ( c ) {
136
+		case 'h':
137
+			print_help ( argv[0] );
138
+			exit ( 0 );
139
+		case '?':
140
+		default:
141
+			exit ( 2 );
142
+		}
143
+	}
144
+	return optind;
145
+}
146
+
147
+int main ( int argc, char **argv ) {
148
+	struct options opts = {
149
+	};
150
+	unsigned int infile_index;
151
+	const char *infile;
152
+
153
+	/* Parse command-line arguments */
154
+	infile_index = parse_options ( argc, argv, &opts );
155
+	if ( argc <= infile_index ) {
156
+		print_help ( argv[0] );
157
+		exit ( 2 );
158
+	}
159
+
160
+	/* Process each einfo file */
161
+	for ( ; infile_index < argc ; infile_index++ ) {
162
+		infile = argv[infile_index];
163
+		einfo ( infile, &opts );
164
+	}
165
+
166
+	return 0;
167
+}

Loading…
Cancel
Save