Changes in uspace/lib/c/generic/inet/addr.c [83781a22:02a09ed] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet/addr.c
r83781a22 r02a09ed 52 52 }; 53 53 54 static const addr48_t inet_addr48_solicited_node = {55 0x33, 0x33, 0xff, 0, 0, 056 };57 58 54 static const inet_addr_t inet_addr_any_addr = { 59 55 .family = AF_INET, … … 74 70 { 75 71 memcpy(dst, src, 16); 76 }77 78 int addr48_compare(const addr48_t a, const addr48_t b)79 {80 return memcmp(a, b, 6);81 }82 83 int addr128_compare(const addr128_t a, const addr128_t b)84 {85 return memcmp(a, b, 16);86 }87 88 /** Compute solicited node MAC multicast address from target IPv6 address89 *90 * @param ip Target IPv6 address91 * @param mac Solicited MAC address to be assigned92 *93 */94 void addr48_solicited_node(const addr128_t ip, addr48_t mac)95 {96 memcpy(mac, inet_addr48_solicited_node, 3);97 memcpy(mac + 3, ip + 13, 3);98 72 } 99 73 … … 238 212 } 239 213 240 void inet_addr_naddr(const inet_addr_t *addr, uint8_t prefix,241 inet_naddr_t *naddr)242 {243 naddr->family = addr->family;244 memcpy(naddr->addr6, addr->addr6, 16);245 naddr->prefix = prefix;246 }247 248 214 void inet_addr_any(inet_addr_t *addr) 249 215 { … … 268 234 return (a->addr == b->addr); 269 235 case AF_INET6: 270 return addr128_compare(a->addr6, b->addr6);236 return memcmp(&a->addr6, &b->addr6, 16); 271 237 default: 272 238 return 0; … … 279 245 (inet_addr_compare(addr, &inet_addr_any_addr)) || 280 246 (inet_addr_compare(addr, &inet_addr_any_addr6))); 281 }282 283 int inet_naddr_compare(const inet_naddr_t *naddr, const inet_addr_t *addr)284 {285 if (naddr->family != addr->family)286 return 0;287 288 switch (naddr->family) {289 case AF_INET:290 return (naddr->addr == addr->addr);291 case AF_INET6:292 return addr128_compare(naddr->addr6, addr->addr6);293 default:294 return 0;295 }296 247 } 297 248
Note:
See TracChangeset
for help on using the changeset viewer.