Changes in uspace/srv/net/inetsrv/sroute.c [a1a101d:a2e3ee6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/sroute.c
ra1a101d ra2e3ee6 97 97 inet_sroute_t *inet_sroute_find(inet_addr_t *addr) 98 98 { 99 uint32_t mask; 100 inet_sroute_t *best; 101 102 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find(%x)", (unsigned)addr->ipv4); 103 104 fibril_mutex_lock(&sroute_list_lock); 105 106 best = NULL; 107 108 list_foreach(sroute_list, link) { 109 inet_sroute_t *sroute = list_get_instance(link, 110 inet_sroute_t, sroute_list); 111 99 uint32_t addr_addr; 100 int rc = inet_addr_pack(addr, &addr_addr); 101 if (rc != EOK) 102 return NULL; 103 104 inet_sroute_t *best = NULL; 105 uint8_t best_bits = 0; 106 107 fibril_mutex_lock(&sroute_list_lock); 108 109 list_foreach(sroute_list, link) { 110 inet_sroute_t *sroute = list_get_instance(link, 111 inet_sroute_t, sroute_list); 112 113 uint32_t dest_addr; 114 uint8_t dest_bits; 115 rc = inet_naddr_pack(&sroute->dest, &dest_addr, &dest_bits); 116 if (rc != EOK) 117 continue; 118 112 119 /* Look for the most specific route */ 113 if ( best != NULL && best->dest.bits >= sroute->dest.bits)120 if ((best != NULL) && (best_bits >= dest_bits)) 114 121 continue; 115 116 mask = inet_netmask(sroute->dest.bits); 117 if ((sroute->dest.ipv4 & mask) == (addr->ipv4 & mask)) { 118 fibril_mutex_unlock(&sroute_list_lock); 119 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find: found %p", 122 123 uint32_t mask = inet_netmask(dest_bits); 124 if ((dest_addr & mask) == (addr_addr & mask)) { 125 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find: found candidate %p", 120 126 sroute); 121 return sroute; 127 128 best = sroute; 129 best_bits = dest_bits; 122 130 } 123 131 } 124 125 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find: Not found"); 126 fibril_mutex_unlock(&sroute_list_lock); 127 128 return NULL; 132 133 if (best == NULL) 134 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find: Not found"); 135 136 fibril_mutex_unlock(&sroute_list_lock); 137 138 return best; 129 139 } 130 140
Note:
See TracChangeset
for help on using the changeset viewer.