Changes in uspace/srv/net/udp/assoc.c [695b6ff:451481c8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/assoc.c
r695b6ff r451481c8 82 82 if (lsock != NULL) 83 83 assoc->ident.local = *lsock; 84 85 84 if (fsock != NULL) 86 85 assoc->ident.foreign = *fsock; … … 186 185 } 187 186 188 /** Set IP link in association.189 *190 * @param assoc Association191 * @param iplink IP link192 */193 void udp_assoc_set_iplink(udp_assoc_t *assoc, service_id_t iplink)194 {195 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_set_iplink(%p, %zu)",196 assoc, iplink);197 fibril_mutex_lock(&assoc->lock);198 assoc->ident.iplink = iplink;199 fibril_mutex_unlock(&assoc->lock);200 }201 202 187 /** Set foreign socket in association. 203 188 * … … 266 251 sp.foreign = *fsock; 267 252 268 if ((inet_addr_is_any(&sp.foreign.addr)) || 269 (sp.foreign.port == UDP_PORT_ANY)) 253 if (sp.foreign.addr.ipv4 == 0 || sp.foreign.port == 0) 270 254 return EINVAL; 271 255 … … 295 279 296 280 fibril_mutex_lock(&assoc->lock); 297 while (list_empty(&assoc->rcv_queue) && !assoc->reset) {281 while (list_empty(&assoc->rcv_queue)) { 298 282 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - waiting"); 299 283 fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock); 300 }301 302 if (assoc->reset) {303 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - association was reset");304 fibril_mutex_unlock(&assoc->lock);305 return ECONNABORTED;306 284 } 307 285 … … 345 323 } 346 324 347 /** Reset association.348 *349 * This causes any pendingreceive operations to return immediately with350 * UDP_ERESET.351 */352 void udp_assoc_reset(udp_assoc_t *assoc)353 {354 fibril_mutex_lock(&assoc->lock);355 assoc->reset = true;356 fibril_condvar_broadcast(&assoc->rcv_queue_cv);357 fibril_mutex_unlock(&assoc->lock);358 }359 360 325 static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp, 361 326 udp_msg_t *msg) … … 386 351 static bool udp_socket_match(udp_sock_t *sock, udp_sock_t *patt) 387 352 { 388 log_msg(LOG_DEFAULT, LVL_DEBUG, 389 "udp_socket_match(sock=(%u), pat=(%u))", sock->port, patt->port);390 391 if ( (!inet_addr_is_any(&patt->addr))&&392 (!inet_addr_compare(&patt->addr, &sock->addr)))353 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_socket_match(sock=(%x,%u), pat=(%x,%u))", 354 sock->addr.ipv4, sock->port, patt->addr.ipv4, patt->port); 355 356 if (patt->addr.ipv4 != UDP_IPV4_ANY && 357 patt->addr.ipv4 != sock->addr.ipv4) 393 358 return false; 394 395 if ( (patt->port != UDP_PORT_ANY)&&396 (patt->port != sock->port))359 360 if (patt->port != UDP_PORT_ANY && 361 patt->port != sock->port) 397 362 return false; 398 363 399 364 log_msg(LOG_DEFAULT, LVL_DEBUG, " -> match"); 400 365 401 366 return true; 402 367 } … … 430 395 { 431 396 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_find_ref(%p)", sp); 432 397 433 398 fibril_mutex_lock(&assoc_list_lock); 434 435 list_foreach(assoc_list, link, udp_assoc_t, assoc) { 399 400 list_foreach(assoc_list, link) { 401 udp_assoc_t *assoc = list_get_instance(link, udp_assoc_t, link); 436 402 udp_sockpair_t *asp = &assoc->ident; 437 403 log_msg(LOG_DEFAULT, LVL_DEBUG, "compare with assoc (f:(%x,%u), l:(%x,%u))", 404 asp->foreign.addr.ipv4, asp->foreign.port, 405 asp->local.addr.ipv4, asp->local.port); 406 438 407 /* Skip unbound associations */ 439 408 if (asp->local.port == UDP_PORT_ANY) 440 409 continue; 441 410 442 411 if (udp_sockpair_match(sp, asp)) { 443 412 log_msg(LOG_DEFAULT, LVL_DEBUG, "Returning assoc %p", assoc); … … 447 416 } 448 417 } 449 418 450 419 fibril_mutex_unlock(&assoc_list_lock); 451 420 return NULL;
Note:
See TracChangeset
for help on using the changeset viewer.