source: mainline/uspace/lib/nettl/src/amap.c@ 8974294

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 8974294 was 05b59393, checked in by jzr <zarevucky.jiri@…>, 8 years ago

Fix a couple of benign clang warnings.
No change in semantics.

  • Property mode set to 100644
File size: 19.1 KB
Line 
1/*
2 * Copyright (c) 2015 Jiri Svoboda
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libnettl
30 * @{
31 */
32
33/**
34 * @file Association map
35 *
36 * Manages allocations of endpoints / endpoint pairs (corresponding to
37 * UDP associations, TCP listeners and TCP connections)
38 *
39 * An association map contains different types of entries, based on which
40 * set of attributes (key) they specify. In order from most specific to the
41 * least specific one:
42 *
43 * - repla (remote endpoint, local address)
44 * - laddr (local address)
45 * - llink (local link)
46 * - unspec (unspecified)
47 *
48 * In the unspecified case only the local port is known and the entry matches
49 * all remote and local addresses.
50 */
51
52#include <adt/list.h>
53#include <errno.h>
54#include <inet/addr.h>
55#include <inet/inet.h>
56#include <io/log.h>
57#include <nettl/amap.h>
58#include <stdint.h>
59#include <stdlib.h>
60
61static portrng_flags_t aflags_to_pflags(amap_flags_t flags)
62{
63 // FIXME: either use a single type, or provide a proper conversion
64 return (portrng_flags_t) flags;
65}
66
67/** Create association map.
68 *
69 * @param rmap Place to store pointer to new association map
70 * @return EOk on success, ENOMEM if out of memory
71 */
72int amap_create(amap_t **rmap)
73{
74 amap_t *map;
75 int rc;
76
77 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_create()");
78
79 map = calloc(1, sizeof(amap_t));
80 if (map == NULL)
81 return ENOMEM;
82
83 rc = portrng_create(&map->unspec);
84 if (rc != EOK) {
85 assert(rc == ENOMEM);
86 free(map);
87 return ENOMEM;
88 }
89
90 list_initialize(&map->repla);
91 list_initialize(&map->laddr);
92 list_initialize(&map->llink);
93
94 *rmap = map;
95 return EOK;
96}
97
98/** Destroy association map.
99 *
100 * @param map Association map
101 */
102void amap_destroy(amap_t *map)
103{
104 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_destroy()");
105
106 assert(list_empty(&map->repla));
107 assert(list_empty(&map->laddr));
108 assert(list_empty(&map->llink));
109 free(map);
110}
111
112/** Find exact repla.
113 *
114 * Find repla (remote endpoint, local address) entry by exact match.
115 *
116 * @param map Association map
117 * @param rep Remote endpoint
118 * @param la Local address
119 * @param rrepla Place to store pointer to repla
120 *
121 * @return EOK on success, ENOENT if not found
122 */
123static int amap_repla_find(amap_t *map, inet_ep_t *rep, inet_addr_t *la,
124 amap_repla_t **rrepla)
125{
126 char *sraddr, *sladdr;
127
128 (void) inet_addr_format(&rep->addr, &sraddr);
129 (void) inet_addr_format(la, &sladdr);
130
131 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_repla_find(): rep=(%s,%" PRIu16
132 ") la=%s", sraddr, rep->port, sladdr);
133 free(sraddr);
134 free(sladdr);
135
136 list_foreach(map->repla, lamap, amap_repla_t, repla) {
137 (void) inet_addr_format(&repla->rep.addr, &sraddr);
138 (void) inet_addr_format(&repla->laddr, &sladdr);
139 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_repla_find(): "
140 "compare to rep=(%s, %" PRIu16 ") la=%s",
141 sraddr, repla->rep.port, sladdr);
142 free(sraddr);
143 free(sladdr);
144 if (inet_addr_compare(&repla->rep.addr, &rep->addr) &&
145 repla->rep.port == rep->port &&
146 inet_addr_compare(&repla->laddr, la)) {
147 *rrepla = repla;
148 return EOK;
149 }
150 }
151
152 *rrepla = NULL;
153 return ENOENT;
154}
155
156/** Insert repla.
157 *
158 * Insert new repla (remote endpoint, local address) entry to association map.
159 *
160 * @param amap Association map
161 * @param rep Remote endpoint
162 * @param la Local address
163 * @param rrepla Place to store pointer to new repla
164 *
165 * @return EOK on success, ENOMEM if out of memory
166 */
167static int amap_repla_insert(amap_t *map, inet_ep_t *rep, inet_addr_t *la,
168 amap_repla_t **rrepla)
169{
170 amap_repla_t *repla;
171 int rc;
172
173 repla = calloc(1, sizeof(amap_repla_t));
174 if (repla == NULL) {
175 *rrepla = NULL;
176 return ENOMEM;
177 }
178
179 rc = portrng_create(&repla->portrng);
180 if (rc != EOK) {
181 free(repla);
182 return ENOMEM;
183 }
184
185 repla->rep = *rep;
186 repla->laddr = *la;
187 list_append(&repla->lamap, &map->repla);
188
189 *rrepla = repla;
190 return EOK;
191}
192
193/** Remove repla from association map.
194 *
195 * Remove repla (remote endpoint, local address) from association map.
196 *
197 * @param map Association map
198 * @param repla Repla
199 */
200static void amap_repla_remove(amap_t *map, amap_repla_t *repla)
201{
202 list_remove(&repla->lamap);
203 portrng_destroy(repla->portrng);
204 free(repla);
205}
206
207/** Find exact laddr.
208 *
209 * Find laddr (local address) entry by exact match.
210 *
211 * @param map Association map
212 * @param addr Address
213 * @param rladdr Place to store pointer to laddr entry
214 *
215 * @return EOK on success, ENOENT if not found.
216 */
217static int amap_laddr_find(amap_t *map, inet_addr_t *addr,
218 amap_laddr_t **rladdr)
219{
220 list_foreach(map->laddr, lamap, amap_laddr_t, laddr) {
221 if (inet_addr_compare(&laddr->laddr, addr)) {
222 *rladdr = laddr;
223 return EOK;
224 }
225 }
226
227 *rladdr = NULL;
228 return ENOENT;
229}
230
231/** Insert laddr.
232 *
233 * Insert new laddr (local address) entry to association map.
234 *
235 * @param addr Local address
236 * @param rladdr Place to store pointer to new laddr
237 *
238 * @return EOK on success, ENOMEM if out of memory
239 */
240static int amap_laddr_insert(amap_t *map, inet_addr_t *addr,
241 amap_laddr_t **rladdr)
242{
243 amap_laddr_t *laddr;
244 int rc;
245
246 laddr = calloc(1, sizeof(amap_laddr_t));
247 if (laddr == NULL) {
248 *rladdr = NULL;
249 return ENOMEM;
250 }
251
252 rc = portrng_create(&laddr->portrng);
253 if (rc != EOK) {
254 free(laddr);
255 return ENOMEM;
256 }
257
258 laddr->laddr = *addr;
259 list_append(&laddr->lamap, &map->laddr);
260
261 *rladdr = laddr;
262 return EOK;
263}
264
265/** Remove laddr from association map.
266 *
267 * Remove laddr (local address) entry from association map.
268 *
269 * @param map Association map
270 * @param laddr Laddr entry
271 */
272static void amap_laddr_remove(amap_t *map, amap_laddr_t *laddr)
273{
274 list_remove(&laddr->lamap);
275 portrng_destroy(laddr->portrng);
276 free(laddr);
277}
278
279/** Find exact llink.
280 *
281 * Find llink (local link) entry by exact match.
282 *
283 * @param map Association map
284 * @param link_id Local link ID
285 * @param rllink Place to store pointer to llink entry
286 *
287 * @return EOK on success, ENOENT if not found.
288 */
289static int amap_llink_find(amap_t *map, sysarg_t link_id,
290 amap_llink_t **rllink)
291{
292 list_foreach(map->llink, lamap, amap_llink_t, llink) {
293 if (llink->llink == link_id) {
294 *rllink = llink;
295 return EOK;
296 }
297 }
298
299 *rllink = NULL;
300 return ENOENT;
301}
302
303/** Insert llink.
304 *
305 * Insert new llink (local link) entry to association map.
306 *
307 * @param link_id Local link
308 * @param rllink Place to store pointer to new llink
309 *
310 * @return EOK on success, ENOMEM if out of memory
311 */
312static int amap_llink_insert(amap_t *map, sysarg_t link_id,
313 amap_llink_t **rllink)
314{
315 amap_llink_t *llink;
316 int rc;
317
318 llink = calloc(1, sizeof(amap_llink_t));
319 if (llink == NULL) {
320 *rllink = NULL;
321 return ENOMEM;
322 }
323
324 rc = portrng_create(&llink->portrng);
325 if (rc != EOK) {
326 free(llink);
327 return ENOMEM;
328 }
329
330 llink->llink = link_id;
331 list_append(&llink->lamap, &map->llink);
332
333 *rllink = llink;
334 return EOK;
335}
336
337/** Remove llink from association map.
338 *
339 * Remove llink (local link) entry from association map.
340 *
341 * @param map Association map
342 * @param llink Llink entry
343 */
344static void amap_llink_remove(amap_t *map, amap_llink_t *llink)
345{
346 list_remove(&llink->lamap);
347 portrng_destroy(llink->portrng);
348 free(llink);
349}
350
351/** Insert endpoint pair into map with repla as key.
352 *
353 * If local port number is not specified, it is allocated.
354 *
355 * @param map Association map
356 * @param epp Endpoint pair, possibly with local port inet_port_any
357 * @param arg arg User value
358 * @param flags Flags
359 * @param aepp Place to store actual endpoint pair, possibly with allocated port
360 *
361 * @return EOK on success, EEXIST if conflicting epp exists,
362 * ENOMEM if out of memory
363 */
364static int amap_insert_repla(amap_t *map, inet_ep2_t *epp, void *arg,
365 amap_flags_t flags, inet_ep2_t *aepp)
366{
367 amap_repla_t *repla;
368 inet_ep2_t mepp;
369 int rc;
370
371 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert_repla()");
372
373 rc = amap_repla_find(map, &epp->remote, &epp->local.addr, &repla);
374 if (rc != EOK) {
375 /* New repla */
376 rc = amap_repla_insert(map, &epp->remote, &epp->local.addr,
377 &repla);
378 if (rc != EOK) {
379 assert(rc == ENOMEM);
380 return rc;
381 }
382 }
383
384 mepp = *epp;
385
386 rc = portrng_alloc(repla->portrng, epp->local.port, arg, aflags_to_pflags(flags),
387 &mepp.local.port);
388 if (rc != EOK) {
389 return rc;
390 }
391
392 *aepp = mepp;
393 return EOK;
394}
395
396/** Insert endpoint pair into map with laddr as key.
397 *
398 * If local port number is not specified, it is allocated.
399 *
400 * @param map Association map
401 * @param epp Endpoint pair, possibly with local port inet_port_any
402 * @param arg arg User value
403 * @param flags Flags
404 * @param aepp Place to store actual endpoint pair, possibly with allocated port
405 *
406 * @return EOK on success, EEXIST if conflicting epp exists,
407 * ENOMEM if out of memory
408 */
409static int amap_insert_laddr(amap_t *map, inet_ep2_t *epp, void *arg,
410 amap_flags_t flags, inet_ep2_t *aepp)
411{
412 amap_laddr_t *laddr;
413 inet_ep2_t mepp;
414 int rc;
415
416 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert_laddr()");
417
418 rc = amap_laddr_find(map, &epp->local.addr, &laddr);
419 if (rc != EOK) {
420 /* New laddr */
421 rc = amap_laddr_insert(map, &epp->local.addr, &laddr);
422 if (rc != EOK) {
423 assert(rc == ENOMEM);
424 return rc;
425 }
426 }
427
428 mepp = *epp;
429
430 rc = portrng_alloc(laddr->portrng, epp->local.port, arg, aflags_to_pflags(flags),
431 &mepp.local.port);
432 if (rc != EOK) {
433 return rc;
434 }
435
436 *aepp = mepp;
437 return EOK;
438}
439
440/** Insert endpoint pair into map with llink as key.
441 *
442 * If local port number is not specified, it is allocated.
443 *
444 * @param map Association map
445 * @param epp Endpoint pair, possibly with local port inet_port_any
446 * @param arg arg User value
447 * @param flags Flags
448 * @param aepp Place to store actual endpoint pair, possibly with allocated port
449 *
450 * @return EOK on success, EEXIST if conflicting epp exists,
451 * ENOMEM if out of memory
452 */
453static int amap_insert_llink(amap_t *map, inet_ep2_t *epp, void *arg,
454 amap_flags_t flags, inet_ep2_t *aepp)
455{
456 amap_llink_t *llink;
457 inet_ep2_t mepp;
458 int rc;
459
460 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert_llink()");
461
462 rc = amap_llink_find(map, epp->local_link, &llink);
463 if (rc != EOK) {
464 /* New llink */
465 rc = amap_llink_insert(map, epp->local_link, &llink);
466 if (rc != EOK) {
467 assert(rc == ENOMEM);
468 return rc;
469 }
470 }
471
472 mepp = *epp;
473
474 rc = portrng_alloc(llink->portrng, epp->local.port, arg, aflags_to_pflags(flags),
475 &mepp.local.port);
476 if (rc != EOK) {
477 return rc;
478 }
479
480 *aepp = mepp;
481 return EOK;
482}
483
484/** Insert endpoint pair into map with unspec as key.
485 *
486 * If local port number is not specified, it is allocated.
487 *
488 * @param map Association map
489 * @param epp Endpoint pair, possibly with local port inet_port_any
490 * @param arg arg User value
491 * @param flags Flags
492 * @param aepp Place to store actual endpoint pair, possibly with allocated port
493 *
494 * @return EOK on success, EEXIST if conflicting epp exists,
495 * ENOMEM if out of memory
496 */
497static int amap_insert_unspec(amap_t *map, inet_ep2_t *epp, void *arg,
498 amap_flags_t flags, inet_ep2_t *aepp)
499{
500 inet_ep2_t mepp;
501 int rc;
502
503 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert_unspec()");
504 mepp = *epp;
505
506 rc = portrng_alloc(map->unspec, epp->local.port, arg, aflags_to_pflags(flags),
507 &mepp.local.port);
508 if (rc != EOK) {
509 return rc;
510 }
511
512 *aepp = mepp;
513 return EOK;
514}
515
516/** Insert endpoint pair into map.
517 *
518 * If local endpoint is not fully specified, it is filled in (determine
519 * source address, allocate port number). Checks for conflicting endpoint pair.
520 *
521 * @param map Association map
522 * @param epp Endpoint pair, possibly with local port inet_port_any
523 * @param arg arg User value
524 * @param flags Flags
525 * @param aepp Place to store actual endpoint pair, possibly with allocated port
526 *
527 * @return EOK on success, EEXIST if conflicting epp exists,
528 * ENOMEM if out of memory
529 */
530int amap_insert(amap_t *map, inet_ep2_t *epp, void *arg, amap_flags_t flags,
531 inet_ep2_t *aepp)
532{
533 bool raddr, rport, laddr, llink;
534 inet_ep2_t mepp;
535 int rc;
536
537 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert()");
538
539 mepp = *epp;
540
541 /* Fill in local address? */
542 if (!inet_addr_is_any(&epp->remote.addr) &&
543 inet_addr_is_any(&epp->local.addr)) {
544 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert: "
545 "determine local address");
546 rc = inet_get_srcaddr(&epp->remote.addr, 0, &mepp.local.addr);
547 if (rc != EOK) {
548 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert: "
549 "cannot determine local address");
550 return rc;
551 }
552 } else {
553 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert: "
554 "local address specified or remote address not specified");
555 }
556
557 raddr = !inet_addr_is_any(&mepp.remote.addr);
558 rport = mepp.remote.port != inet_port_any;
559 laddr = !inet_addr_is_any(&mepp.local.addr);
560 llink = mepp.local_link != 0;
561
562 if (raddr && rport && laddr && !llink) {
563 return amap_insert_repla(map, &mepp, arg, flags, aepp);
564 } else if (!raddr && !rport && laddr && !llink) {
565 return amap_insert_laddr(map, &mepp, arg, flags, aepp);
566 } else if (!raddr && !rport && !laddr && llink) {
567 return amap_insert_llink(map, &mepp, arg, flags, aepp);
568 } else if (!raddr && !rport && !laddr && !llink) {
569 return amap_insert_unspec(map, &mepp, arg, flags, aepp);
570 } else {
571 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_insert: invalid "
572 "combination of raddr=%d rport=%d laddr=%d llink=%d",
573 raddr, rport, laddr, llink);
574 return EINVAL;
575 }
576
577 return EOK;
578}
579
580/** Remove endpoint pair using repla as key from map.
581 *
582 * The endpoint pair must be present in the map, otherwise behavior
583 * is unspecified.
584 *
585 * @param map Association map
586 * @param epp Endpoint pair
587 */
588static void amap_remove_repla(amap_t *map, inet_ep2_t *epp)
589{
590 amap_repla_t *repla;
591 int rc;
592
593 rc = amap_repla_find(map, &epp->remote, &epp->local.addr, &repla);
594 if (rc != EOK) {
595 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_remove_repla: not found");
596 return;
597 }
598
599 portrng_free_port(repla->portrng, epp->local.port);
600
601 if (portrng_empty(repla->portrng))
602 amap_repla_remove(map, repla);
603}
604
605/** Remove endpoint pair using laddr as key from map.
606 *
607 * The endpoint pair must be present in the map, otherwise behavior
608 * is unspecified.
609 *
610 * @param map Association map
611 * @param epp Endpoint pair
612 */
613static void amap_remove_laddr(amap_t *map, inet_ep2_t *epp)
614{
615 amap_laddr_t *laddr;
616 int rc;
617
618 rc = amap_laddr_find(map, &epp->local.addr, &laddr);
619 if (rc != EOK) {
620 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_remove_laddr: not found");
621 return;
622 }
623
624 portrng_free_port(laddr->portrng, epp->local.port);
625
626 if (portrng_empty(laddr->portrng))
627 amap_laddr_remove(map, laddr);
628}
629
630/** Remove endpoint pair using llink as key from map.
631 *
632 * The endpoint pair must be present in the map, otherwise behavior
633 * is unspecified.
634 *
635 * @param map Association map
636 * @param epp Endpoint pair
637 */
638static void amap_remove_llink(amap_t *map, inet_ep2_t *epp)
639{
640 amap_llink_t *llink;
641 int rc;
642
643 rc = amap_llink_find(map, epp->local_link, &llink);
644 if (rc != EOK) {
645 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_remove_llink: not found");
646 return;
647 }
648
649 portrng_free_port(llink->portrng, epp->local.port);
650
651 if (portrng_empty(llink->portrng))
652 amap_llink_remove(map, llink);
653}
654
655/** Remove endpoint pair using unspec as key from map.
656 *
657 * The endpoint pair must be present in the map, otherwise behavior
658 * is unspecified.
659 *
660 * @param map Association map
661 * @param epp Endpoint pair
662 */
663static void amap_remove_unspec(amap_t *map, inet_ep2_t *epp)
664{
665 portrng_free_port(map->unspec, epp->local.port);
666}
667
668/** Remove endpoint pair from map.
669 *
670 * The endpoint pair must be present in the map, otherwise behavior
671 * is unspecified.
672 *
673 * @param map Association map
674 * @param epp Endpoint pair
675 */
676void amap_remove(amap_t *map, inet_ep2_t *epp)
677{
678 bool raddr, rport, laddr, llink;
679
680 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_remove()");
681
682 raddr = !inet_addr_is_any(&epp->remote.addr);
683 rport = epp->remote.port != inet_port_any;
684 laddr = !inet_addr_is_any(&epp->local.addr);
685 llink = epp->local_link != 0;
686
687 if (raddr && rport && laddr && !llink) {
688 amap_remove_repla(map, epp);
689 } else if (!raddr && !rport && laddr && !llink) {
690 amap_remove_laddr(map, epp);
691 } else if (!raddr && !rport && !laddr && llink) {
692 amap_remove_llink(map, epp);
693 } else if (!raddr && !rport && !laddr && !llink) {
694 amap_remove_unspec(map, epp);
695 } else {
696 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_remove: invalid "
697 "combination of raddr=%d rport=%d laddr=%d llink=%d",
698 raddr, rport, laddr, llink);
699 return;
700 }
701}
702
703/** Find association matching an endpoint pair.
704 *
705 * Used to find which association to deliver a datagram to.
706 *
707 * @param map Association map
708 * @param epp Endpoint pair
709 * @param rarg Place to store user argument for the matching association.
710 *
711 * @return EOK on success, ENOENT if not found.
712 */
713int amap_find_match(amap_t *map, inet_ep2_t *epp, void **rarg)
714{
715 int rc;
716 amap_repla_t *repla;
717 amap_laddr_t *laddr;
718 amap_llink_t *llink;
719
720 log_msg(LOG_DEFAULT, LVL_DEBUG2, "amap_find_match(llink=%zu)",
721 epp->local_link);
722
723 /* Remode endpoint, local address */
724 rc = amap_repla_find(map, &epp->remote, &epp->local.addr, &repla);
725 if (rc == EOK) {
726 rc = portrng_find_port(repla->portrng, epp->local.port,
727 rarg);
728 if (rc == EOK) {
729 log_msg(LOG_DEFAULT, LVL_DEBUG2, "Matched repla / "
730 "port %" PRIu16, epp->local.port);
731 return EOK;
732 }
733 }
734
735 /* Local address */
736 rc = amap_laddr_find(map, &epp->local.addr, &laddr);
737 if (rc == EOK) {
738 rc = portrng_find_port(laddr->portrng, epp->local.port,
739 rarg);
740 if (rc == EOK) {
741 log_msg(LOG_DEFAULT, LVL_DEBUG2, "Matched laddr / "
742 "port %" PRIu16, epp->local.port);
743 return EOK;
744 }
745 }
746
747 /* Local link */
748 rc = amap_llink_find(map, epp->local_link, &llink);
749 if (epp->local_link != 0 && rc == EOK) {
750 rc = portrng_find_port(llink->portrng, epp->local.port,
751 rarg);
752 if (rc == EOK) {
753 log_msg(LOG_DEFAULT, LVL_DEBUG2, "Matched llink / "
754 "port %" PRIu16, epp->local.port);
755 return EOK;
756 }
757 }
758
759 /* Unspecified */
760 rc = portrng_find_port(map->unspec, epp->local.port, rarg);
761 if (rc == EOK) {
762 log_msg(LOG_DEFAULT, LVL_DEBUG2, "Matched unspec / port %" PRIu16,
763 epp->local.port);
764 return EOK;
765 }
766
767 log_msg(LOG_DEFAULT, LVL_DEBUG2, "No match.");
768 return ENOENT;
769}
770
771/**
772 * @}
773 */
Note: See TracBrowser for help on using the repository browser.