8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- use ai = std:: io:: net:: addrinfo;
12
11
use libc:: c_int;
13
12
use libc;
14
13
use std:: mem;
15
14
use std:: ptr:: null;
16
15
use std:: rt:: task:: BlockedTask ;
16
+ use std:: rt:: rtio;
17
17
18
18
use net;
19
19
use super :: { Loop , UvError , Request , wait_until_woken_after, wakeup} ;
@@ -33,7 +33,9 @@ pub struct GetAddrInfoRequest;
33
33
34
34
impl GetAddrInfoRequest {
35
35
pub fn run ( loop_ : & Loop , node : Option < & str > , service : Option < & str > ,
36
- hints : Option < ai:: Hint > ) -> Result < Vec < ai:: Info > , UvError > {
36
+ hints : Option < rtio:: AddrinfoHint > )
37
+ -> Result < Vec < rtio:: AddrinfoInfo > , UvError >
38
+ {
37
39
assert ! ( node. is_some( ) || service. is_some( ) ) ;
38
40
let ( _c_node, c_node_ptr) = match node {
39
41
Some ( n) => {
@@ -54,20 +56,11 @@ impl GetAddrInfoRequest {
54
56
} ;
55
57
56
58
let hint = hints. map ( |hint| {
57
- let mut flags = 0 ;
58
- each_ai_flag ( |cval, aival| {
59
- if hint. flags & ( aival as uint ) != 0 {
60
- flags |= cval as i32 ;
61
- }
62
- } ) ;
63
- let socktype = 0 ;
64
- let protocol = 0 ;
65
-
66
59
libc:: addrinfo {
67
- ai_flags : flags ,
60
+ ai_flags : 0 ,
68
61
ai_family : hint. family as c_int ,
69
- ai_socktype : socktype ,
70
- ai_protocol : protocol ,
62
+ ai_socktype : 0 ,
63
+ ai_protocol : 0 ,
71
64
ai_addrlen : 0 ,
72
65
ai_canonname : null ( ) ,
73
66
ai_addr : null ( ) ,
@@ -119,22 +112,8 @@ impl Drop for Addrinfo {
119
112
}
120
113
}
121
114
122
- fn each_ai_flag ( _f : |c_int , ai:: Flag |) {
123
- /* FIXME: do we really want to support these?
124
- unsafe {
125
- f(uvll::rust_AI_ADDRCONFIG(), ai::AddrConfig);
126
- f(uvll::rust_AI_ALL(), ai::All);
127
- f(uvll::rust_AI_CANONNAME(), ai::CanonName);
128
- f(uvll::rust_AI_NUMERICHOST(), ai::NumericHost);
129
- f(uvll::rust_AI_NUMERICSERV(), ai::NumericServ);
130
- f(uvll::rust_AI_PASSIVE(), ai::Passive);
131
- f(uvll::rust_AI_V4MAPPED(), ai::V4Mapped);
132
- }
133
- */
134
- }
135
-
136
115
// Traverse the addrinfo linked list, producing a vector of Rust socket addresses
137
- pub fn accum_addrinfo ( addr : & Addrinfo ) -> Vec < ai :: Info > {
116
+ pub fn accum_addrinfo ( addr : & Addrinfo ) -> Vec < rtio :: AddrinfoInfo > {
138
117
unsafe {
139
118
let mut addr = addr. handle ;
140
119
@@ -143,35 +122,12 @@ pub fn accum_addrinfo(addr: &Addrinfo) -> Vec<ai::Info> {
143
122
let rustaddr = net:: sockaddr_to_addr ( mem:: transmute ( ( * addr) . ai_addr ) ,
144
123
( * addr) . ai_addrlen as uint ) ;
145
124
146
- let mut flags = 0 ;
147
- each_ai_flag ( |cval, aival| {
148
- if ( * addr) . ai_flags & cval != 0 {
149
- flags |= aival as uint ;
150
- }
151
- } ) ;
152
-
153
- /* FIXME: do we really want to support these
154
- let protocol = match (*addr).ai_protocol {
155
- p if p == uvll::rust_IPPROTO_UDP() => Some(ai::UDP),
156
- p if p == uvll::rust_IPPROTO_TCP() => Some(ai::TCP),
157
- _ => None,
158
- };
159
- let socktype = match (*addr).ai_socktype {
160
- p if p == uvll::rust_SOCK_STREAM() => Some(ai::Stream),
161
- p if p == uvll::rust_SOCK_DGRAM() => Some(ai::Datagram),
162
- p if p == uvll::rust_SOCK_RAW() => Some(ai::Raw),
163
- _ => None,
164
- };
165
- */
166
- let protocol = None ;
167
- let socktype = None ;
168
-
169
- addrs. push ( ai:: Info {
125
+ addrs. push ( rtio:: AddrinfoInfo {
170
126
address : rustaddr,
171
127
family : ( * addr) . ai_family as uint ,
172
- socktype : socktype ,
173
- protocol : protocol ,
174
- flags : flags ,
128
+ socktype : 0 ,
129
+ protocol : 0 ,
130
+ flags : 0 ,
175
131
} ) ;
176
132
if ( * addr) . ai_next . is_not_null ( ) {
177
133
addr = ( * addr) . ai_next ;
0 commit comments