Changeset 984a9ba in mainline for uspace/srv/net/inetsrv/inetsrv.c
- Timestamp:
- 2018-07-05T09:34:09Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 63d46341
- Parents:
- 76f566d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/inetsrv.c
r76f566d r984a9ba 82 82 static LIST_INITIALIZE(client_list); 83 83 84 static void inet_default_conn( cap_call_handle_t,ipc_call_t *, void *);84 static void inet_default_conn(ipc_call_t *, void *); 85 85 86 86 static errno_t inet_init(void) … … 120 120 } 121 121 122 static void inet_callback_create_srv(inet_client_t *client, cap_call_handle_t chandle, 123 ipc_call_t *call) 122 static void inet_callback_create_srv(inet_client_t *client, ipc_call_t *call) 124 123 { 125 124 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_callback_create_srv()"); … … 127 126 async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE); 128 127 if (sess == NULL) { 129 async_answer_0(c handle, ENOMEM);128 async_answer_0(call, ENOMEM); 130 129 return; 131 130 } 132 131 133 132 client->sess = sess; 134 async_answer_0(c handle, EOK);133 async_answer_0(call, EOK); 135 134 } 136 135 … … 230 229 } 231 230 232 static void inet_get_srcaddr_srv(inet_client_t *client, cap_call_handle_t icall_handle, 233 ipc_call_t *icall) 231 static void inet_get_srcaddr_srv(inet_client_t *client, ipc_call_t *icall) 234 232 { 235 233 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_get_srcaddr_srv()"); … … 237 235 uint8_t tos = IPC_GET_ARG1(*icall); 238 236 239 cap_call_handle_t chandle;237 ipc_call_t call; 240 238 size_t size; 241 if (!async_data_write_receive(&c handle, &size)) {242 async_answer_0( chandle, EREFUSED);243 async_answer_0(icall _handle, EREFUSED);239 if (!async_data_write_receive(&call, &size)) { 240 async_answer_0(&call, EREFUSED); 241 async_answer_0(icall, EREFUSED); 244 242 return; 245 243 } 246 244 247 245 if (size != sizeof(inet_addr_t)) { 248 async_answer_0( chandle, EINVAL);249 async_answer_0(icall _handle, EINVAL);246 async_answer_0(&call, EINVAL); 247 async_answer_0(icall, EINVAL); 250 248 return; 251 249 } 252 250 253 251 inet_addr_t remote; 254 errno_t rc = async_data_write_finalize( chandle, &remote, size);255 if (rc != EOK) { 256 async_answer_0( chandle, rc);257 async_answer_0(icall _handle, rc);252 errno_t rc = async_data_write_finalize(&call, &remote, size); 253 if (rc != EOK) { 254 async_answer_0(&call, rc); 255 async_answer_0(icall, rc); 258 256 } 259 257 … … 261 259 rc = inet_get_srcaddr(&remote, tos, &local); 262 260 if (rc != EOK) { 263 async_answer_0(icall _handle, rc);264 return; 265 } 266 267 if (!async_data_read_receive(&c handle, &size)) {268 async_answer_0( chandle, EREFUSED);269 async_answer_0(icall _handle, EREFUSED);261 async_answer_0(icall, rc); 262 return; 263 } 264 265 if (!async_data_read_receive(&call, &size)) { 266 async_answer_0(&call, EREFUSED); 267 async_answer_0(icall, EREFUSED); 270 268 return; 271 269 } 272 270 273 271 if (size != sizeof(inet_addr_t)) { 274 async_answer_0(chandle, EINVAL); 275 async_answer_0(icall_handle, EINVAL); 276 return; 277 } 278 279 rc = async_data_read_finalize(chandle, &local, size); 280 if (rc != EOK) { 281 async_answer_0(chandle, rc); 282 async_answer_0(icall_handle, rc); 283 return; 284 } 285 286 async_answer_0(icall_handle, rc); 287 } 288 289 static void inet_send_srv(inet_client_t *client, cap_call_handle_t icall_handle, 290 ipc_call_t *icall) 272 async_answer_0(&call, EINVAL); 273 async_answer_0(icall, EINVAL); 274 return; 275 } 276 277 rc = async_data_read_finalize(&call, &local, size); 278 if (rc != EOK) { 279 async_answer_0(&call, rc); 280 async_answer_0(icall, rc); 281 return; 282 } 283 284 async_answer_0(icall, rc); 285 } 286 287 static void inet_send_srv(inet_client_t *client, ipc_call_t *icall) 291 288 { 292 289 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_send_srv()"); … … 300 297 int df = IPC_GET_ARG4(*icall); 301 298 302 cap_call_handle_t chandle;299 ipc_call_t call; 303 300 size_t size; 304 if (!async_data_write_receive(&c handle, &size)) {305 async_answer_0( chandle, EREFUSED);306 async_answer_0(icall _handle, EREFUSED);301 if (!async_data_write_receive(&call, &size)) { 302 async_answer_0(&call, EREFUSED); 303 async_answer_0(icall, EREFUSED); 307 304 return; 308 305 } 309 306 310 307 if (size != sizeof(inet_addr_t)) { 311 async_answer_0( chandle, EINVAL);312 async_answer_0(icall _handle, EINVAL);313 return; 314 } 315 316 errno_t rc = async_data_write_finalize( chandle, &dgram.src, size);317 if (rc != EOK) { 318 async_answer_0( chandle, rc);319 async_answer_0(icall _handle, rc);320 } 321 322 if (!async_data_write_receive(&c handle, &size)) {323 async_answer_0( chandle, EREFUSED);324 async_answer_0(icall _handle, EREFUSED);308 async_answer_0(&call, EINVAL); 309 async_answer_0(icall, EINVAL); 310 return; 311 } 312 313 errno_t rc = async_data_write_finalize(&call, &dgram.src, size); 314 if (rc != EOK) { 315 async_answer_0(&call, rc); 316 async_answer_0(icall, rc); 317 } 318 319 if (!async_data_write_receive(&call, &size)) { 320 async_answer_0(&call, EREFUSED); 321 async_answer_0(icall, EREFUSED); 325 322 return; 326 323 } 327 324 328 325 if (size != sizeof(inet_addr_t)) { 329 async_answer_0( chandle, EINVAL);330 async_answer_0(icall _handle, EINVAL);331 return; 332 } 333 334 rc = async_data_write_finalize( chandle, &dgram.dest, size);335 if (rc != EOK) { 336 async_answer_0( chandle, rc);337 async_answer_0(icall _handle, rc);326 async_answer_0(&call, EINVAL); 327 async_answer_0(icall, EINVAL); 328 return; 329 } 330 331 rc = async_data_write_finalize(&call, &dgram.dest, size); 332 if (rc != EOK) { 333 async_answer_0(&call, rc); 334 async_answer_0(icall, rc); 338 335 } 339 336 … … 341 338 &dgram.size); 342 339 if (rc != EOK) { 343 async_answer_0(icall _handle, rc);340 async_answer_0(icall, rc); 344 341 return; 345 342 } … … 348 345 349 346 free(dgram.data); 350 async_answer_0(icall_handle, rc); 351 } 352 353 static void inet_set_proto_srv(inet_client_t *client, cap_call_handle_t chandle, 354 ipc_call_t *call) 347 async_answer_0(icall, rc); 348 } 349 350 static void inet_set_proto_srv(inet_client_t *client, ipc_call_t *call) 355 351 { 356 352 sysarg_t proto; … … 360 356 361 357 if (proto > UINT8_MAX) { 362 async_answer_0(c handle, EINVAL);358 async_answer_0(call, EINVAL); 363 359 return; 364 360 } 365 361 366 362 client->protocol = proto; 367 async_answer_0(c handle, EOK);363 async_answer_0(call, EOK); 368 364 } 369 365 … … 387 383 } 388 384 389 static void inet_default_conn( cap_call_handle_t icall_handle,ipc_call_t *icall, void *arg)385 static void inet_default_conn(ipc_call_t *icall, void *arg) 390 386 { 391 387 inet_client_t client; … … 394 390 395 391 /* Accept the connection */ 396 async_answer_0(icall _handle, EOK);392 async_answer_0(icall, EOK); 397 393 398 394 inet_client_init(&client); … … 400 396 while (true) { 401 397 ipc_call_t call; 402 cap_call_handle_t chandle =async_get_call(&call);398 async_get_call(&call); 403 399 sysarg_t method = IPC_GET_IMETHOD(call); 404 400 405 401 if (!method) { 406 402 /* The other side has hung up */ 407 async_answer_0( chandle, EOK);403 async_answer_0(&call, EOK); 408 404 return; 409 405 } … … 411 407 switch (method) { 412 408 case INET_CALLBACK_CREATE: 413 inet_callback_create_srv(&client, chandle,&call);409 inet_callback_create_srv(&client, &call); 414 410 break; 415 411 case INET_GET_SRCADDR: 416 inet_get_srcaddr_srv(&client, chandle,&call);412 inet_get_srcaddr_srv(&client, &call); 417 413 break; 418 414 case INET_SEND: 419 inet_send_srv(&client, chandle,&call);415 inet_send_srv(&client, &call); 420 416 break; 421 417 case INET_SET_PROTO: 422 inet_set_proto_srv(&client, chandle,&call);418 inet_set_proto_srv(&client, &call); 423 419 break; 424 420 default: 425 async_answer_0( chandle, EINVAL);421 async_answer_0(&call, EINVAL); 426 422 } 427 423 }
Note:
See TracChangeset
for help on using the changeset viewer.