소스 검색

[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 11 년 전
부모
커밋
12605efded
1개의 변경된 파일4개의 추가작업 그리고 13개의 파일을 삭제
  1. 4
    13
      src/core/resolv.c

+ 4
- 13
src/core/resolv.c 파일 보기

@@ -23,10 +23,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
23 23
 #include <stdlib.h>
24 24
 #include <string.h>
25 25
 #include <errno.h>
26
-#include <ipxe/in.h>
27 26
 #include <ipxe/xfer.h>
28 27
 #include <ipxe/open.h>
29 28
 #include <ipxe/process.h>
29
+#include <ipxe/socket.h>
30 30
 #include <ipxe/resolv.h>
31 31
 
32 32
 /** @file
@@ -100,7 +100,6 @@ static struct process_descriptor numeric_process_desc =
100 100
 static int numeric_resolv ( struct interface *resolv,
101 101
 			    const char *name, struct sockaddr *sa ) {
102 102
 	struct numeric_resolv *numeric;
103
-	struct sockaddr_in *sin;
104 103
 
105 104
 	/* Allocate and initialise structure */
106 105
 	numeric = zalloc ( sizeof ( *numeric ) );
@@ -112,16 +111,8 @@ static int numeric_resolv ( struct interface *resolv,
112 111
 		       &numeric->refcnt );
113 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 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 117
 	/* Attach to parent interface, mortalise self, and return */
127 118
 	intf_plug_plug ( &numeric->resolv, resolv );
@@ -193,8 +184,8 @@ static int resmux_try ( struct resolv_mux *mux ) {
193 184
 static void resmux_child_resolv_done ( struct resolv_mux *mux,
194 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 190
 	/* Pass resolution to parent */
200 191
 	resolv_done ( &mux->parent, sa );

Loading…
취소
저장