Changes in uspace/srv/net/inetsrv/addrobj.c [feeac0d:a1a101d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/inetsrv/addrobj.c
rfeeac0d ra1a101d 42 42 #include <stdlib.h> 43 43 #include <str.h> 44 #include <net/socket_codes.h> 44 45 45 #include "addrobj.h" 46 46 #include "inetsrv.h" 47 47 #include "inet_link.h" 48 #include " ndp.h"48 #include "inet_util.h" 49 49 50 50 static inet_addrobj_t *inet_addrobj_find_by_name_locked(const char *, inet_link_t *); … … 106 106 /** Find address object matching address @a addr. 107 107 * 108 * @param addr Address 109 * @oaram find iaf_net to find network (using mask), 110 * iaf_addr to find local address (exact match) 111 * 108 * @param addr Address 109 * @oaram find iaf_net to find network (using mask), 110 * iaf_addr to find local address (exact match) 112 111 */ 113 112 inet_addrobj_t *inet_addrobj_find(inet_addr_t *addr, inet_addrobj_find_t find) 114 113 { 115 fibril_mutex_lock(&addr_list_lock); 116 117 list_foreach(addr_list, addr_list, inet_addrobj_t, naddr) { 118 switch (find) { 119 case iaf_net: 120 if (inet_naddr_compare_mask(&naddr->naddr, addr)) { 121 fibril_mutex_unlock(&addr_list_lock); 122 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find: found %p", 123 naddr); 124 return naddr; 125 } 126 break; 127 case iaf_addr: 128 if (inet_naddr_compare(&naddr->naddr, addr)) { 129 fibril_mutex_unlock(&addr_list_lock); 130 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find: found %p", 131 naddr); 132 return naddr; 133 } 134 break; 114 uint32_t mask; 115 116 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find(%x)", (unsigned)addr->ipv4); 117 118 fibril_mutex_lock(&addr_list_lock); 119 120 list_foreach(addr_list, link) { 121 inet_addrobj_t *naddr = list_get_instance(link, 122 inet_addrobj_t, addr_list); 123 124 mask = inet_netmask(naddr->naddr.bits); 125 if ((naddr->naddr.ipv4 & mask) == (addr->ipv4 & mask)) { 126 fibril_mutex_unlock(&addr_list_lock); 127 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find: found %p", 128 naddr); 129 return naddr; 135 130 } 136 131 } 137 132 138 133 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find: Not found"); 139 134 fibril_mutex_unlock(&addr_list_lock); 140 135 141 136 return NULL; 142 137 } … … 155 150 name, ilink->svc_name); 156 151 157 list_foreach(addr_list, addr_list, inet_addrobj_t, naddr) { 152 list_foreach(addr_list, link) { 153 inet_addrobj_t *naddr = list_get_instance(link, 154 inet_addrobj_t, addr_list); 155 158 156 if (naddr->ilink == ilink && str_cmp(naddr->name, name) == 0) { 159 157 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find_by_name_locked: found %p", … … 200 198 fibril_mutex_lock(&addr_list_lock); 201 199 202 list_foreach(addr_list, addr_list, inet_addrobj_t, naddr) { 200 list_foreach(addr_list, link) { 201 inet_addrobj_t *naddr = list_get_instance(link, 202 inet_addrobj_t, addr_list); 203 203 204 if (naddr->id == id) { 204 205 fibril_mutex_unlock(&addr_list_lock); … … 217 218 { 218 219 inet_addr_t lsrc_addr; 219 inet_naddr_addr(&addr->naddr, &lsrc_addr); 220 221 addr32_t lsrc_v4; 222 addr128_t lsrc_v6; 223 uint16_t lsrc_af = inet_addr_get(&lsrc_addr, &lsrc_v4, &lsrc_v6); 224 225 addr32_t ldest_v4; 226 addr128_t ldest_v6; 227 uint16_t ldest_af = inet_addr_get(ldest, &ldest_v4, &ldest_v6); 228 229 if (lsrc_af != ldest_af) 230 return EINVAL; 231 232 int rc; 233 addr48_t ldest_mac; 234 235 switch (ldest_af) { 236 case AF_INET: 237 return inet_link_send_dgram(addr->ilink, lsrc_v4, ldest_v4, 238 dgram, proto, ttl, df); 239 case AF_INET6: 240 /* 241 * Translate local destination IPv6 address. 242 */ 243 rc = ndp_translate(lsrc_v6, ldest_v6, ldest_mac, addr->ilink); 244 if (rc != EOK) 245 return rc; 246 247 return inet_link_send_dgram6(addr->ilink, ldest_mac, dgram, 248 proto, ttl, df); 249 } 250 251 return ENOTSUP; 220 inet_addr_t *ldest_addr; 221 222 lsrc_addr.ipv4 = addr->naddr.ipv4; 223 ldest_addr = &dgram->dest; 224 225 return inet_link_send_dgram(addr->ilink, &lsrc_addr, ldest_addr, dgram, 226 proto, ttl, df); 252 227 } 253 228 … … 268 243 269 244 i = 0; 270 list_foreach(addr_list, addr_list, inet_addrobj_t, addr) { 245 list_foreach(addr_list, link) { 246 inet_addrobj_t *addr = list_get_instance(link, 247 inet_addrobj_t, addr_list); 248 271 249 id_list[i++] = addr->id; 272 250 }
Note:
See TracChangeset
for help on using the changeset viewer.