Changeset 8d48c7e in mainline for uspace/srv/net/udp/assoc.c
- Timestamp:
- 2015-06-02T16:00:42Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2c4bb828
- Parents:
- ab6326bc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/assoc.c
rab6326bc r8d48c7e 56 56 static udp_assoc_t *udp_assoc_find_ref(inet_ep2_t *); 57 57 static int udp_assoc_queue_msg(udp_assoc_t *, inet_ep2_t *, udp_msg_t *); 58 static bool udp_ep_match(inet_ep_t *, inet_ep_t *);59 static bool udp_ep2_match(inet_ep2_t *, inet_ep2_t *);60 58 61 59 /** Initialize associations. */ … … 393 391 } 394 392 395 /** Match endpoint with pattern. */396 static bool udp_ep_match(inet_ep_t *ep, inet_ep_t *patt)397 {398 char *sa, *pa;399 400 sa = pa = (char *)"?";401 (void) inet_addr_format(&ep->addr, &sa);402 (void) inet_addr_format(&patt->addr, &pa);403 404 log_msg(LOG_DEFAULT, LVL_NOTE,405 "udp_ep_match(ep=(%s,%u), pat=(%s,%u))",406 sa, ep->port, pa, patt->port);407 408 if ((!inet_addr_is_any(&patt->addr)) &&409 (!inet_addr_compare(&patt->addr, &ep->addr)))410 return false;411 412 log_msg(LOG_DEFAULT, LVL_NOTE, "addr OK");413 414 if ((patt->port != inet_port_any) &&415 (patt->port != ep->port))416 return false;417 418 log_msg(LOG_DEFAULT, LVL_NOTE, " -> match");419 420 return true;421 }422 423 /** Match endpoint pair with pattern. */424 static bool udp_ep2_match(inet_ep2_t *epp, inet_ep2_t *pattern)425 {426 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_ep2_match(%p, %p)", epp, pattern);427 428 if (!udp_ep_match(&epp->local, &pattern->local))429 return false;430 431 if (!udp_ep_match(&epp->remote, &pattern->remote))432 return false;433 434 log_msg(LOG_DEFAULT, LVL_DEBUG, "Endpoint pair matched.");435 return true;436 }437 438 439 393 /** Find association structure for specified endpoint pair. 440 394 * … … 448 402 static udp_assoc_t *udp_assoc_find_ref(inet_ep2_t *epp) 449 403 { 450 char *la, *ra; 404 int rc; 405 void *arg; 406 udp_assoc_t *assoc; 451 407 452 408 log_msg(LOG_DEFAULT, LVL_NOTE, "udp_assoc_find_ref(%p)", epp); 453 454 409 fibril_mutex_lock(&assoc_list_lock); 455 410 456 log_msg(LOG_DEFAULT, LVL_NOTE, "associations:"); 457 list_foreach(assoc_list, link, udp_assoc_t, assoc) { 458 inet_ep2_t *aepp = &assoc->ident; 459 460 la = ra = NULL; 461 462 (void) inet_addr_format(&aepp->local.addr, &la); 463 (void) inet_addr_format(&aepp->remote.addr, &ra); 464 465 log_msg(LOG_DEFAULT, LVL_NOTE, "find_ref:aepp=%p la=%s ra=%s", 466 aepp, la, ra); 467 /* Skip unbound associations */ 468 if (aepp->local.port == inet_port_any) { 469 log_msg(LOG_DEFAULT, LVL_NOTE, "skip unbound"); 470 continue; 471 } 472 473 if (udp_ep2_match(epp, aepp)) { 474 log_msg(LOG_DEFAULT, LVL_DEBUG, "Returning assoc %p", assoc); 475 udp_assoc_addref(assoc); 476 fibril_mutex_unlock(&assoc_list_lock); 477 return assoc; 478 } else { 479 log_msg(LOG_DEFAULT, LVL_NOTE, "not matched"); 480 } 481 } 482 483 log_msg(LOG_DEFAULT, LVL_NOTE, "associations END"); 411 rc = amap_find_match(amap, epp, &arg); 412 if (rc != EOK) { 413 assert(rc == ENOMEM); 414 fibril_mutex_unlock(&assoc_list_lock); 415 return NULL; 416 } 417 418 assoc = (udp_assoc_t *)arg; 419 udp_assoc_addref(assoc); 420 484 421 fibril_mutex_unlock(&assoc_list_lock); 485 return NULL;422 return assoc; 486 423 } 487 424
Note:
See TracChangeset
for help on using the changeset viewer.