Changeset 4c53333 in mainline for uspace/srv/net/inetsrv/sroute.c
- Timestamp:
- 2013-07-11T08:21:10Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 64e63ce1
- Parents:
- 80445cf (diff), c8bb1633 (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/sroute.c
r80445cf r4c53333 42 42 #include <stdlib.h> 43 43 #include <str.h> 44 45 44 #include "sroute.h" 46 #include "inet .h"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); … … 57 55 58 56 if (sroute == NULL) { 59 log_msg(L VL_ERROR, "Failed allocating static route object. "57 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed allocating static route object. " 60 58 "Out of memory."); 61 59 return NULL; … … 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(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 uint16_t addr_af = 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, link) { 105 inet_sroute_t *sroute = list_get_instance(link, 106 inet_sroute_t, sroute_list); 107 108 uint8_t dest_bits; 109 uint16_t dest_af = inet_naddr_get(&sroute->dest, NULL, NULL, 110 &dest_bits); 111 112 /* Skip comparison with different address family */ 113 if (addr_af != dest_af) 114 continue; 115 112 116 /* Look for the most specific route */ 113 if ( best != NULL && best->dest.bits >= sroute->dest.bits)117 if ((best != NULL) && (best_bits >= dest_bits)) 114 118 continue; 115 116 mask = inet_netmask(sroute->dest.bits); 117 if ((sroute->dest.ipv4 & mask) == (addr->ipv4 & mask)) { 119 120 if (inet_naddr_compare_mask(&sroute->dest, addr)) { 121 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find: found candidate %p", 122 sroute); 123 124 best = sroute; 125 best_bits = dest_bits; 126 } 127 } 128 129 if (best == NULL) 130 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find: Not found"); 131 132 fibril_mutex_unlock(&sroute_list_lock); 133 134 return best; 135 } 136 137 /** Find static route with a specific name. 138 * 139 * @param name Address object name 140 * @return Address object 141 */ 142 inet_sroute_t *inet_sroute_find_by_name(const char *name) 143 { 144 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find_by_name('%s')", 145 name); 146 147 fibril_mutex_lock(&sroute_list_lock); 148 149 list_foreach(sroute_list, link) { 150 inet_sroute_t *sroute = list_get_instance(link, 151 inet_sroute_t, sroute_list); 152 153 if (str_cmp(sroute->name, name) == 0) { 118 154 fibril_mutex_unlock(&sroute_list_lock); 119 log_msg(L VL_DEBUG, "inet_sroute_find: found %p",155 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find_by_name: found %p", 120 156 sroute); 121 157 return sroute; … … 123 159 } 124 160 125 log_msg(LVL_DEBUG, "inet_sroute_find: Not found"); 126 fibril_mutex_unlock(&sroute_list_lock); 127 128 return NULL; 129 } 130 131 /** Find static route with a specific name. 132 * 133 * @param name Address object name 134 * @return Address object 135 */ 136 inet_sroute_t *inet_sroute_find_by_name(const char *name) 137 { 138 log_msg(LVL_DEBUG, "inet_sroute_find_by_name('%s')", 139 name); 140 141 fibril_mutex_lock(&sroute_list_lock); 142 143 list_foreach(sroute_list, link) { 144 inet_sroute_t *sroute = list_get_instance(link, 145 inet_sroute_t, sroute_list); 146 147 if (str_cmp(sroute->name, name) == 0) { 148 fibril_mutex_unlock(&sroute_list_lock); 149 log_msg(LVL_DEBUG, "inet_sroute_find_by_name: found %p", 150 sroute); 151 return sroute; 152 } 153 } 154 155 log_msg(LVL_DEBUG, "inet_sroute_find_by_name: Not found"); 161 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_find_by_name: Not found"); 156 162 fibril_mutex_unlock(&sroute_list_lock); 157 163 … … 166 172 inet_sroute_t *inet_sroute_get_by_id(sysarg_t id) 167 173 { 168 log_msg(L VL_DEBUG, "inet_sroute_get_by_id(%zu)", (size_t)id);174 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_sroute_get_by_id(%zu)", (size_t)id); 169 175 170 176 fibril_mutex_lock(&sroute_list_lock);
Note:
See TracChangeset
for help on using the changeset viewer.