Changeset bdae198 in mainline for uspace/lib/c/generic/inet/addr.c
- Timestamp:
- 2013-08-04T12:01:10Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ea50906
- Parents:
- b08879c2 (diff), d856110 (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/lib/c/generic/inet/addr.c
rb08879c2 rbdae198 52 52 }; 53 53 54 static const addr48_t inet_addr48_solicited_node = { 55 0x33, 0x33, 0xff, 0, 0, 0 56 }; 57 54 58 static const inet_addr_t inet_addr_any_addr = { 55 59 .family = AF_INET, … … 70 74 { 71 75 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 address 89 * 90 * @param ip Target IPv6 address 91 * @param mac Solicited MAC address to be assigned 92 * 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); 72 98 } 73 99 … … 212 238 } 213 239 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 214 248 void inet_addr_any(inet_addr_t *addr) 215 249 { … … 234 268 return (a->addr == b->addr); 235 269 case AF_INET6: 236 return memcmp(&a->addr6, &b->addr6, 16);270 return addr128_compare(a->addr6, b->addr6); 237 271 default: 238 272 return 0; … … 245 279 (inet_addr_compare(addr, &inet_addr_any_addr)) || 246 280 (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 } 247 296 } 248 297
Note:
See TracChangeset
for help on using the changeset viewer.