Changeset 8b863a62 in mainline for uspace/srv/net/inetsrv/sroute.c
- Timestamp:
- 2014-04-16T17:14:06Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f857e8b
- Parents:
- dba3e2c (diff), 70b570c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/sroute.c
rdba3e2c r8b863a62 42 42 #include <stdlib.h> 43 43 #include <str.h> 44 45 44 #include "sroute.h" 46 45 #include "inetsrv.h" 47 46 #include "inet_link.h" 48 #include "inet_util.h"49 47 50 48 static FIBRIL_MUTEX_INITIALIZE(sroute_list_lock); … … 91 89 } 92 90 93 /** Find addressobject matching address @a addr.91 /** Find static route object matching address @a addr. 94 92 * 95 93 * @param addr Address … … 97 95 inet_sroute_t *inet_sroute_find(inet_addr_t *addr) 98 96 { 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 97 ip_ver_t addr_ver = inet_addr_get(addr, NULL, NULL); 98 99 inet_sroute_t *best = NULL; 100 uint8_t best_bits = 0; 101 102 fibril_mutex_lock(&sroute_list_lock); 103 104 list_foreach(sroute_list, sroute_list, inet_sroute_t, sroute) { 105 uint8_t dest_bits; 106 ip_ver_t dest_ver = inet_naddr_get(&sroute->dest, NULL, NULL, 107 &dest_bits); 108 109 /* Skip comparison with different address family */ 110 if (addr_ver != dest_ver) 111 continue; 112 112 113 /* Look for the most specific route */ 113 if ( best != NULL && best->dest.bits >= sroute->dest.bits)114 if ((best != NULL) && (best_bits >= dest_bits)) 114 115 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", 116 117 if (inet_naddr_compare_mask(&sroute->dest, addr)) { 118 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find: found candidate %p", 120 119 sroute); 121 return sroute; 120 121 best = sroute; 122 best_bits = dest_bits; 122 123 } 123 124 } 124 125 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find: Not found"); 126 fibril_mutex_unlock(&sroute_list_lock); 127 128 return NULL; 125 126 if (best == NULL) 127 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find: Not found"); 128 129 fibril_mutex_unlock(&sroute_list_lock); 130 131 return best; 129 132 } 130 133 … … 141 144 fibril_mutex_lock(&sroute_list_lock); 142 145 143 list_foreach(sroute_list, link) { 144 inet_sroute_t *sroute = list_get_instance(link, 145 inet_sroute_t, sroute_list); 146 146 list_foreach(sroute_list, sroute_list, inet_sroute_t, sroute) { 147 147 if (str_cmp(sroute->name, name) == 0) { 148 148 fibril_mutex_unlock(&sroute_list_lock); … … 170 170 fibril_mutex_lock(&sroute_list_lock); 171 171 172 list_foreach(sroute_list, link) { 173 inet_sroute_t *sroute = list_get_instance(link, 174 inet_sroute_t, sroute_list); 175 172 list_foreach(sroute_list, sroute_list, inet_sroute_t, sroute) { 176 173 if (sroute->id == id) { 177 174 fibril_mutex_unlock(&sroute_list_lock); … … 201 198 202 199 i = 0; 203 list_foreach(sroute_list, link) { 204 inet_sroute_t *sroute = list_get_instance(link, 205 inet_sroute_t, sroute_list); 206 200 list_foreach(sroute_list, sroute_list, inet_sroute_t, sroute) { 207 201 id_list[i++] = sroute->id; 208 202 }
Note:
See TracChangeset
for help on using the changeset viewer.