Changeset 8f8a0cd6 in mainline for uspace/lib/c/generic/net/inet.c
- Timestamp:
- 2011-01-07T09:13:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0f191a2, 692c0d3e
- Parents:
- 71ed4849 (diff), ae1f70e (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/net/inet.c
r71ed4849 r8f8a0cd6 64 64 switch (family) { 65 65 case AF_INET: 66 / / check the output buffer size66 /* Check output buffer size */ 67 67 if (length < INET_ADDRSTRLEN) 68 68 return ENOMEM; 69 69 70 / / fill the buffer with the IPv4 address70 /* Fill buffer with IPv4 address */ 71 71 snprintf(address, length, "%hhu.%hhu.%hhu.%hhu", 72 72 data[0], data[1], data[2], data[3]); … … 75 75 76 76 case AF_INET6: 77 / / check the output buffer size77 /* Check output buffer size */ 78 78 if (length < INET6_ADDRSTRLEN) 79 79 return ENOMEM; 80 80 81 / / fill the buffer with the IPv6 address81 /* Fill buffer with IPv6 address */ 82 82 snprintf(address, length, 83 83 "%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:%hhx%hhx:" … … 124 124 return EINVAL; 125 125 126 / / set the processing parameters126 /* Set processing parameters */ 127 127 switch (family) { 128 128 case AF_INET: … … 142 142 } 143 143 144 / / erase if no address144 /* Erase if no address */ 145 145 if (!address) { 146 146 bzero(data, count); … … 148 148 } 149 149 150 / / process the string from the beginning150 /* Process string from the beginning */ 151 151 next = address; 152 152 index = 0; 153 153 do { 154 / / if the actual character is set154 /* If the actual character is set */ 155 155 if (next && *next) { 156 156 157 / / if not on the first character157 /* If not on the first character */ 158 158 if (index) { 159 / / move to the next character159 /* Move to the next character */ 160 160 ++next; 161 161 } 162 162 163 / / parse the actual integral value163 /* Parse the actual integral value */ 164 164 value = strtoul(next, &last, base); 165 // remember the last problematic character 166 // should be either '.' or ':' but is ignored to be more 167 // generic 165 /* 166 * Remember the last problematic character 167 * should be either '.' or ':' but is ignored to be 168 * more generic 169 */ 168 170 next = last; 169 171 170 / / fill the address data byte by byte172 /* Fill the address data byte by byte */ 171 173 shift = bytes - 1; 172 174 do { 173 / / like little endian175 /* like little endian */ 174 176 data[index + shift] = value; 175 177 value >>= 8; … … 178 180 index += bytes; 179 181 } else { 180 / / erase the rest of the address182 /* Erase the rest of the address */ 181 183 bzero(data + index, count - index); 182 184 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.