Browse code

network: Extend the fallback gai_strerror implementation to handle more error codes

This is useful if a proper getaddrinfo is loaded dynamically on
windows, while using the fallback implementation of gai_strerror.

Signed-off-by: Martin Storsjö <martin@martin.st>

Martin Storsjö authored on 2012/06/25 18:44:18
Showing 2 changed files
... ...
@@ -110,17 +110,33 @@ struct addrinfo {
110 110
 #endif
111 111
 
112 112
 /* getaddrinfo constants */
113
+#ifndef EAI_AGAIN
114
+#define EAI_AGAIN 2
115
+#endif
116
+#ifndef EAI_BADFLAGS
117
+#define EAI_BADFLAGS 3
118
+#endif
113 119
 #ifndef EAI_FAIL
114 120
 #define EAI_FAIL 4
115 121
 #endif
116
-
117 122
 #ifndef EAI_FAMILY
118 123
 #define EAI_FAMILY 5
119 124
 #endif
120
-
125
+#ifndef EAI_MEMORY
126
+#define EAI_MEMORY 6
127
+#endif
128
+#ifndef EAI_NODATA
129
+#define EAI_NODATA 7
130
+#endif
121 131
 #ifndef EAI_NONAME
122 132
 #define EAI_NONAME 8
123 133
 #endif
134
+#ifndef EAI_SERVICE
135
+#define EAI_SERVICE 9
136
+#endif
137
+#ifndef EAI_SOCKTYPE
138
+#define EAI_SOCKTYPE 10
139
+#endif
124 140
 
125 141
 #ifndef AI_PASSIVE
126 142
 #define AI_PASSIVE 1
... ...
@@ -243,9 +243,17 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
243 243
 const char *ff_gai_strerror(int ecode)
244 244
 {
245 245
     switch(ecode) {
246
+    case EAI_AGAIN  : return "Temporary failure in name resolution";
247
+    case EAI_BADFLAGS: return "Invalid flags for ai_flags";
246 248
     case EAI_FAIL   : return "A non-recoverable error occurred";
247 249
     case EAI_FAMILY : return "The address family was not recognized or the address length was invalid for the specified family";
250
+    case EAI_MEMORY : return "Memory allocation failure";
251
+#if EAI_NODATA != EAI_NONAME
252
+    case EAI_NODATA : return "No address associated with hostname";
253
+#endif
248 254
     case EAI_NONAME : return "The name does not resolve for the supplied parameters";
255
+    case EAI_SERVICE: return "servname not supported for ai_socktype";
256
+    case EAI_SOCKTYPE: return "ai_socktype not supported";
249 257
     }
250 258
 
251 259
     return "Unknown error";