Changeset a46e56b in mainline for uspace/srv/net/inetsrv/inetsrv.c
- Timestamp:
- 2018-03-22T06:49:35Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 77f0a1d
- Parents:
- 3e242d2
- git-author:
- Jakub Jermar <jakub@…> (2018-03-21 23:29:06)
- git-committer:
- Jakub Jermar <jakub@…> (2018-03-22 06:49:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/inetsrv.c
r3e242d2 ra46e56b 120 120 } 121 121 122 static void inet_callback_create_srv(inet_client_t *client, cap_call_handle_t c allid,122 static void inet_callback_create_srv(inet_client_t *client, cap_call_handle_t chandle, 123 123 ipc_call_t *call) 124 124 { … … 127 127 async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE); 128 128 if (sess == NULL) { 129 async_answer_0(c allid, ENOMEM);129 async_answer_0(chandle, ENOMEM); 130 130 return; 131 131 } 132 132 133 133 client->sess = sess; 134 async_answer_0(c allid, EOK);134 async_answer_0(chandle, EOK); 135 135 } 136 136 … … 230 230 } 231 231 232 static void inet_get_srcaddr_srv(inet_client_t *client, cap_call_handle_t i id,232 static void inet_get_srcaddr_srv(inet_client_t *client, cap_call_handle_t icall_handle, 233 233 ipc_call_t *icall) 234 234 { … … 237 237 uint8_t tos = IPC_GET_ARG1(*icall); 238 238 239 cap_call_handle_t c allid;239 cap_call_handle_t chandle; 240 240 size_t size; 241 if (!async_data_write_receive(&c allid, &size)) {242 async_answer_0(c allid, EREFUSED);243 async_answer_0(i id, EREFUSED);241 if (!async_data_write_receive(&chandle, &size)) { 242 async_answer_0(chandle, EREFUSED); 243 async_answer_0(icall_handle, EREFUSED); 244 244 return; 245 245 } 246 246 247 247 if (size != sizeof(inet_addr_t)) { 248 async_answer_0(c allid, EINVAL);249 async_answer_0(i id, EINVAL);248 async_answer_0(chandle, EINVAL); 249 async_answer_0(icall_handle, EINVAL); 250 250 return; 251 251 } 252 252 253 253 inet_addr_t remote; 254 errno_t rc = async_data_write_finalize(c allid, &remote, size);255 if (rc != EOK) { 256 async_answer_0(c allid, rc);257 async_answer_0(i id, rc);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); 258 258 } 259 259 … … 261 261 rc = inet_get_srcaddr(&remote, tos, &local); 262 262 if (rc != EOK) { 263 async_answer_0(i id, rc);264 return; 265 } 266 267 if (!async_data_read_receive(&c allid, &size)) {268 async_answer_0(c allid, EREFUSED);269 async_answer_0(i id, EREFUSED);263 async_answer_0(icall_handle, rc); 264 return; 265 } 266 267 if (!async_data_read_receive(&chandle, &size)) { 268 async_answer_0(chandle, EREFUSED); 269 async_answer_0(icall_handle, EREFUSED); 270 270 return; 271 271 } 272 272 273 273 if (size != sizeof(inet_addr_t)) { 274 async_answer_0(c allid, EINVAL);275 async_answer_0(i id, EINVAL);276 return; 277 } 278 279 rc = async_data_read_finalize(c allid, &local, size);280 if (rc != EOK) { 281 async_answer_0(c allid, rc);282 async_answer_0(i id, rc);283 return; 284 } 285 286 async_answer_0(i id, rc);287 } 288 289 static void inet_send_srv(inet_client_t *client, cap_call_handle_t i id,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 290 ipc_call_t *icall) 291 291 { … … 300 300 int df = IPC_GET_ARG4(*icall); 301 301 302 cap_call_handle_t c allid;302 cap_call_handle_t chandle; 303 303 size_t size; 304 if (!async_data_write_receive(&c allid, &size)) {305 async_answer_0(c allid, EREFUSED);306 async_answer_0(i id, EREFUSED);304 if (!async_data_write_receive(&chandle, &size)) { 305 async_answer_0(chandle, EREFUSED); 306 async_answer_0(icall_handle, EREFUSED); 307 307 return; 308 308 } 309 309 310 310 if (size != sizeof(inet_addr_t)) { 311 async_answer_0(c allid, EINVAL);312 async_answer_0(i id, EINVAL);313 return; 314 } 315 316 errno_t rc = async_data_write_finalize(c allid, &dgram.src, size);317 if (rc != EOK) { 318 async_answer_0(c allid, rc);319 async_answer_0(i id, rc);320 } 321 322 if (!async_data_write_receive(&c allid, &size)) {323 async_answer_0(c allid, EREFUSED);324 async_answer_0(i id, EREFUSED);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(&chandle, &size)) { 323 async_answer_0(chandle, EREFUSED); 324 async_answer_0(icall_handle, EREFUSED); 325 325 return; 326 326 } 327 327 328 328 if (size != sizeof(inet_addr_t)) { 329 async_answer_0(c allid, EINVAL);330 async_answer_0(i id, EINVAL);331 return; 332 } 333 334 rc = async_data_write_finalize(c allid, &dgram.dest, size);335 if (rc != EOK) { 336 async_answer_0(c allid, rc);337 async_answer_0(i id, rc);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); 338 338 } 339 339 … … 341 341 &dgram.size); 342 342 if (rc != EOK) { 343 async_answer_0(i id, rc);343 async_answer_0(icall_handle, rc); 344 344 return; 345 345 } … … 348 348 349 349 free(dgram.data); 350 async_answer_0(i id, rc);351 } 352 353 static void inet_set_proto_srv(inet_client_t *client, cap_call_handle_t c allid,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 354 ipc_call_t *call) 355 355 { … … 360 360 361 361 if (proto > UINT8_MAX) { 362 async_answer_0(c allid, EINVAL);362 async_answer_0(chandle, EINVAL); 363 363 return; 364 364 } 365 365 366 366 client->protocol = proto; 367 async_answer_0(c allid, EOK);367 async_answer_0(chandle, EOK); 368 368 } 369 369 … … 387 387 } 388 388 389 static void inet_default_conn(cap_call_handle_t i id, ipc_call_t *icall, void *arg)389 static void inet_default_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg) 390 390 { 391 391 inet_client_t client; … … 394 394 395 395 /* Accept the connection */ 396 async_answer_0(i id, EOK);396 async_answer_0(icall_handle, EOK); 397 397 398 398 inet_client_init(&client); … … 400 400 while (true) { 401 401 ipc_call_t call; 402 cap_call_handle_t c allid= async_get_call(&call);402 cap_call_handle_t chandle = async_get_call(&call); 403 403 sysarg_t method = IPC_GET_IMETHOD(call); 404 404 405 405 if (!method) { 406 406 /* The other side has hung up */ 407 async_answer_0(c allid, EOK);407 async_answer_0(chandle, EOK); 408 408 return; 409 409 } … … 411 411 switch (method) { 412 412 case INET_CALLBACK_CREATE: 413 inet_callback_create_srv(&client, c allid, &call);413 inet_callback_create_srv(&client, chandle, &call); 414 414 break; 415 415 case INET_GET_SRCADDR: 416 inet_get_srcaddr_srv(&client, c allid, &call);416 inet_get_srcaddr_srv(&client, chandle, &call); 417 417 break; 418 418 case INET_SEND: 419 inet_send_srv(&client, c allid, &call);419 inet_send_srv(&client, chandle, &call); 420 420 break; 421 421 case INET_SET_PROTO: 422 inet_set_proto_srv(&client, c allid, &call);422 inet_set_proto_srv(&client, chandle, &call); 423 423 break; 424 424 default: 425 async_answer_0(c allid, EINVAL);425 async_answer_0(chandle, EINVAL); 426 426 } 427 427 }
Note:
See TracChangeset
for help on using the changeset viewer.