Changeset d8b47eca in mainline
- Timestamp:
- 2013-07-03T17:16:44Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 66366470, 882bc4b
- Parents:
- 1d24ad3
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet.c
r1d24ad3 rd8b47eca 108 108 int inet_send(inet_dgram_t *dgram, uint8_t ttl, inet_df_t df) 109 109 { 110 addr32_t src_v4; 111 addr128_t src_v6; 112 uint16_t src_af = inet_addr_get(&dgram->src, &src_v4, &src_v6); 113 114 addr32_t dest_v4; 115 addr128_t dest_v6; 116 uint16_t dest_af = inet_addr_get(&dgram->dest, &dest_v4, &dest_v6); 117 118 if (src_af != dest_af) 119 return EINVAL; 120 121 async_exch_t *exch; 110 async_exch_t *exch = async_exchange_begin(inet_sess); 111 122 112 ipc_call_t answer; 123 aid_t req; 124 int rc; 125 126 switch (src_af) { 127 case AF_INET: 128 exch = async_exchange_begin(inet_sess); 129 130 req = async_send_5(exch, INET_SEND, (sysarg_t) src_v4, 131 (sysarg_t) dest_v4, dgram->tos, ttl, df, &answer); 132 rc = async_data_write_start(exch, dgram->data, dgram->size); 133 113 aid_t req = async_send_3(exch, INET_SEND, dgram->tos, ttl, df, 114 &answer); 115 116 int rc = async_data_write_start(exch, &dgram->src, sizeof(inet_addr_t)); 117 if (rc != EOK) { 134 118 async_exchange_end(exch); 135 break; 136 case AF_INET6: 137 // FIXME TODO 138 return ENOTSUP; 139 default: 140 return EINVAL; 141 } 119 async_forget(req); 120 return rc; 121 } 122 123 rc = async_data_write_start(exch, &dgram->dest, sizeof(inet_addr_t)); 124 if (rc != EOK) { 125 async_exchange_end(exch); 126 async_forget(req); 127 return rc; 128 } 129 130 rc = async_data_write_start(exch, dgram->data, dgram->size); 131 132 async_exchange_end(exch); 142 133 143 134 if (rc != EOK) { … … 154 145 int inet_get_srcaddr(inet_addr_t *remote, uint8_t tos, inet_addr_t *local) 155 146 { 156 addr32_t remote_v4; 157 addr128_t remote_v6; 158 uint16_t remote_af = inet_addr_get(remote, &remote_v4, &remote_v6); 159 160 async_exch_t *exch; 161 int rc; 162 163 switch (remote_af) { 164 case AF_INET: 165 exch = async_exchange_begin(inet_sess); 166 167 sysarg_t local_v4; 168 rc = async_req_2_1(exch, INET_GET_SRCADDR, (sysarg_t) remote_v4, 169 tos, &local_v4); 170 147 async_exch_t *exch = async_exchange_begin(inet_sess); 148 149 ipc_call_t answer; 150 aid_t req = async_send_1(exch, INET_GET_SRCADDR, tos, &answer); 151 152 int rc = async_data_write_start(exch, remote, sizeof(inet_addr_t)); 153 if (rc != EOK) { 171 154 async_exchange_end(exch); 172 173 if (rc != EOK) 174 return rc; 175 176 inet_addr_set(local_v4, local); 177 return EOK; 178 case AF_INET6: 179 // FIXME TODO 180 return ENOTSUP; 181 default: 182 return EINVAL; 183 } 155 async_forget(req); 156 return rc; 157 } 158 159 rc = async_data_read_start(exch, local, sizeof(inet_addr_t)); 160 161 async_exchange_end(exch); 162 163 if (rc != EOK) { 164 async_forget(req); 165 return rc; 166 } 167 168 sysarg_t retval; 169 async_wait_for(req, &retval); 170 171 return (int) retval; 184 172 } 185 173 -
uspace/srv/net/dnsrsrv/dnsrsrv.c
r1d24ad3 rd8b47eca 197 197 198 198 int rc = async_data_write_finalize(callid, &dns_server_addr, size); 199 if (rc != EOK) 200 async_answer_0(callid, rc); 199 if (rc != EOK) { 200 async_answer_0(callid, rc); 201 async_answer_0(iid, rc); 202 } 201 203 202 204 async_answer_0(iid, (sysarg_t) rc); -
uspace/srv/net/ethip/atrans.c
r1d24ad3 rd8b47eca 49 49 static FIBRIL_CONDVAR_INITIALIZE(atrans_cv); 50 50 51 static ethip_atrans_t *atrans_find( uint32_t ip_addr)51 static ethip_atrans_t *atrans_find(addr32_t ip_addr) 52 52 { 53 53 list_foreach(atrans_list, link) { … … 62 62 } 63 63 64 int atrans_add( uint32_t ip_addr, addr48_t mac_addr)64 int atrans_add(addr32_t ip_addr, addr48_t mac_addr) 65 65 { 66 66 ethip_atrans_t *atrans; … … 88 88 } 89 89 90 int atrans_remove( uint32_t ip_addr)90 int atrans_remove(addr32_t ip_addr) 91 91 { 92 92 ethip_atrans_t *atrans; … … 106 106 } 107 107 108 int atrans_lookup( uint32_t ip_addr, addr48_t mac_addr)108 int atrans_lookup(addr32_t ip_addr, addr48_t mac_addr) 109 109 { 110 110 fibril_mutex_lock(&atrans_list_lock); -
uspace/srv/net/ethip/atrans.h
r1d24ad3 rd8b47eca 42 42 #include "ethip.h" 43 43 44 extern int atrans_add( uint32_t, addr48_t);45 extern int atrans_remove( uint32_t);46 extern int atrans_lookup( uint32_t, addr48_t);44 extern int atrans_add(addr32_t, addr48_t); 45 extern int atrans_remove(addr32_t); 46 extern int atrans_lookup(addr32_t, addr48_t); 47 47 extern int atrans_wait_timeout(suseconds_t); 48 48 -
uspace/srv/net/ethip/ethip.h
r1d24ad3 rd8b47eca 97 97 addr48_t sender_hw_addr; 98 98 /** Sender protocol address */ 99 uint32_t sender_proto_addr;99 addr32_t sender_proto_addr; 100 100 /** Target hardware address */ 101 101 addr48_t target_hw_addr; 102 102 /** Target protocol address */ 103 uint32_t target_proto_addr;103 addr32_t target_proto_addr; 104 104 } arp_eth_packet_t; 105 105 … … 107 107 typedef struct { 108 108 link_t atrans_list; 109 uint32_t ip_addr;109 addr32_t ip_addr; 110 110 addr48_t mac_addr; 111 111 } ethip_atrans_t; -
uspace/srv/net/ethip/std.h
r1d24ad3 rd8b47eca 70 70 addr48_t sender_hw_addr; 71 71 /** Sender protocol address */ 72 uint32_t sender_proto_addr;72 addr32_t sender_proto_addr; 73 73 /** Target hardware address */ 74 74 addr48_t target_hw_addr; 75 75 /** Target protocol address */ 76 uint32_t target_proto_addr;76 addr32_t target_proto_addr; 77 77 } __attribute__((packed)) arp_eth_packet_fmt_t; 78 78 -
uspace/srv/net/inetsrv/inetsrv.c
r1d24ad3 rd8b47eca 207 207 } 208 208 209 static void inet_get_srcaddr_srv(inet_client_t *client, ipc_callid_t callid,210 ipc_call_t * call)209 static void inet_get_srcaddr_srv(inet_client_t *client, ipc_callid_t iid, 210 ipc_call_t *icall) 211 211 { 212 212 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_get_srcaddr_srv()"); 213 213 214 addr32_t remote_v4 = IPC_GET_ARG1(*call); 215 uint8_t tos = IPC_GET_ARG2(*call); 214 uint8_t tos = IPC_GET_ARG1(*icall); 215 216 ipc_callid_t callid; 217 size_t size; 218 if (!async_data_write_receive(&callid, &size)) { 219 async_answer_0(callid, EREFUSED); 220 async_answer_0(iid, EREFUSED); 221 return; 222 } 223 224 if (size != sizeof(inet_addr_t)) { 225 async_answer_0(callid, EINVAL); 226 async_answer_0(iid, EINVAL); 227 return; 228 } 216 229 217 230 inet_addr_t remote; 218 inet_addr_set(remote_v4, &remote); 231 int rc = async_data_write_finalize(callid, &remote, size); 232 if (rc != EOK) { 233 async_answer_0(callid, rc); 234 async_answer_0(iid, rc); 235 } 219 236 220 237 inet_addr_t local; 221 int rc = inet_get_srcaddr(&remote, tos, &local); 238 rc = inet_get_srcaddr(&remote, tos, &local); 239 if (rc != EOK) { 240 async_answer_0(iid, rc); 241 return; 242 } 243 244 if (!async_data_read_receive(&callid, &size)) { 245 async_answer_0(callid, EREFUSED); 246 async_answer_0(iid, EREFUSED); 247 return; 248 } 249 250 if (size != sizeof(inet_addr_t)) { 251 async_answer_0(callid, EINVAL); 252 async_answer_0(iid, EINVAL); 253 return; 254 } 255 256 rc = async_data_read_finalize(callid, &local, size); 222 257 if (rc != EOK) { 223 258 async_answer_0(callid, rc); 224 return; 225 } 226 227 addr32_t local_v4; 228 uint16_t family = inet_addr_get(&local, &local_v4, NULL); 229 if (family != AF_INET) { 259 async_answer_0(iid, rc); 260 return; 261 } 262 263 async_answer_0(iid, rc); 264 } 265 266 static void inet_send_srv(inet_client_t *client, ipc_callid_t iid, 267 ipc_call_t *icall) 268 { 269 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_send_srv()"); 270 271 inet_dgram_t dgram; 272 273 dgram.tos = IPC_GET_ARG1(*icall); 274 275 uint8_t ttl = IPC_GET_ARG2(*icall); 276 int df = IPC_GET_ARG3(*icall); 277 278 ipc_callid_t callid; 279 size_t size; 280 if (!async_data_write_receive(&callid, &size)) { 281 async_answer_0(callid, EREFUSED); 282 async_answer_0(iid, EREFUSED); 283 return; 284 } 285 286 if (size != sizeof(inet_addr_t)) { 230 287 async_answer_0(callid, EINVAL); 231 return; 232 } 233 234 async_answer_1(callid, rc, (sysarg_t) local_v4); 235 } 236 237 static void inet_send_srv(inet_client_t *client, ipc_callid_t callid, 238 ipc_call_t *call) 239 { 240 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_send_srv()"); 241 242 addr32_t src_v4 = IPC_GET_ARG1(*call); 243 addr32_t dest_v4 = IPC_GET_ARG2(*call); 244 245 inet_dgram_t dgram; 246 247 inet_addr_set(src_v4, &dgram.src); 248 inet_addr_set(dest_v4, &dgram.dest); 249 dgram.tos = IPC_GET_ARG3(*call); 250 251 uint8_t ttl = IPC_GET_ARG4(*call); 252 int df = IPC_GET_ARG5(*call); 253 254 int rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, 288 async_answer_0(iid, EINVAL); 289 return; 290 } 291 292 int rc = async_data_write_finalize(callid, &dgram.src, size); 293 if (rc != EOK) { 294 async_answer_0(callid, rc); 295 async_answer_0(iid, rc); 296 } 297 298 if (!async_data_write_receive(&callid, &size)) { 299 async_answer_0(callid, EREFUSED); 300 async_answer_0(iid, EREFUSED); 301 return; 302 } 303 304 if (size != sizeof(inet_addr_t)) { 305 async_answer_0(callid, EINVAL); 306 async_answer_0(iid, EINVAL); 307 return; 308 } 309 310 rc = async_data_write_finalize(callid, &dgram.dest, size); 311 if (rc != EOK) { 312 async_answer_0(callid, rc); 313 async_answer_0(iid, rc); 314 } 315 316 rc = async_data_write_accept(&dgram.data, false, 0, 0, 0, 255 317 &dgram.size); 256 318 if (rc != EOK) { 257 async_answer_0( callid, rc);319 async_answer_0(iid, rc); 258 320 return; 259 321 } … … 262 324 263 325 free(dgram.data); 264 async_answer_0( callid, rc);326 async_answer_0(iid, rc); 265 327 } 266 328
Note:
See TracChangeset
for help on using the changeset viewer.