Преглед на файлове

[resolv] Use sock_aton() to allow parsing of arbitrary numeric addresses

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown преди 10 години
родител
ревизия
12605efded
променени са 1 файла, в които са добавени 4 реда и са изтрити 13 реда
  1. 4
    13
      src/core/resolv.c

+ 4
- 13
src/core/resolv.c Целия файл

23
 #include <stdlib.h>
23
 #include <stdlib.h>
24
 #include <string.h>
24
 #include <string.h>
25
 #include <errno.h>
25
 #include <errno.h>
26
-#include <ipxe/in.h>
27
 #include <ipxe/xfer.h>
26
 #include <ipxe/xfer.h>
28
 #include <ipxe/open.h>
27
 #include <ipxe/open.h>
29
 #include <ipxe/process.h>
28
 #include <ipxe/process.h>
29
+#include <ipxe/socket.h>
30
 #include <ipxe/resolv.h>
30
 #include <ipxe/resolv.h>
31
 
31
 
32
 /** @file
32
 /** @file
100
 static int numeric_resolv ( struct interface *resolv,
100
 static int numeric_resolv ( struct interface *resolv,
101
 			    const char *name, struct sockaddr *sa ) {
101
 			    const char *name, struct sockaddr *sa ) {
102
 	struct numeric_resolv *numeric;
102
 	struct numeric_resolv *numeric;
103
-	struct sockaddr_in *sin;
104
 
103
 
105
 	/* Allocate and initialise structure */
104
 	/* Allocate and initialise structure */
106
 	numeric = zalloc ( sizeof ( *numeric ) );
105
 	numeric = zalloc ( sizeof ( *numeric ) );
112
 		       &numeric->refcnt );
111
 		       &numeric->refcnt );
113
 	memcpy ( &numeric->sa, sa, sizeof ( numeric->sa ) );
112
 	memcpy ( &numeric->sa, sa, sizeof ( numeric->sa ) );
114
 
113
 
115
-	DBGC ( numeric, "NUMERIC %p attempting to resolve \"%s\"\n",
116
-	       numeric, name );
117
-
118
 	/* Attempt to resolve name */
114
 	/* Attempt to resolve name */
119
-	sin = ( ( struct sockaddr_in * ) &numeric->sa );
120
-	if ( inet_aton ( name, &sin->sin_addr ) != 0 ) {
121
-		sin->sin_family = AF_INET;
122
-	} else {
123
-		numeric->rc = -EINVAL;
124
-	}
115
+	numeric->rc = sock_aton ( name, &numeric->sa );
125
 
116
 
126
 	/* Attach to parent interface, mortalise self, and return */
117
 	/* Attach to parent interface, mortalise self, and return */
127
 	intf_plug_plug ( &numeric->resolv, resolv );
118
 	intf_plug_plug ( &numeric->resolv, resolv );
193
 static void resmux_child_resolv_done ( struct resolv_mux *mux,
184
 static void resmux_child_resolv_done ( struct resolv_mux *mux,
194
 				       struct sockaddr *sa ) {
185
 				       struct sockaddr *sa ) {
195
 
186
 
196
-	DBGC ( mux, "RESOLV %p resolved \"%s\" using method %s\n",
197
-	       mux, mux->name, mux->resolver->name );
187
+	DBGC ( mux, "RESOLV %p resolved \"%s\" to %s using method %s\n",
188
+	       mux, mux->name, sock_ntoa ( sa ), mux->resolver->name );
198
 
189
 
199
 	/* Pass resolution to parent */
190
 	/* Pass resolution to parent */
200
 	resolv_done ( &mux->parent, sa );
191
 	resolv_done ( &mux->parent, sa );

Loading…
Отказ
Запис