Changes in uspace/lib/c/generic/net/inet.c [45bb1d2:1bfd3d3] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/net/inet.c
r45bb1d2 r1bfd3d3 64 64 switch (family) { 65 65 case AF_INET: 66 / * Check output buffer size */66 // check the output buffer size 67 67 if (length < INET_ADDRSTRLEN) 68 68 return ENOMEM; 69 69 70 / * Fill buffer with IPv4 address */70 // fill the buffer with the 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 output buffer size */77 // check the output buffer size 78 78 if (length < INET6_ADDRSTRLEN) 79 79 return ENOMEM; 80 80 81 / * Fill buffer with IPv6 address */81 // fill the buffer with the 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 processing parameters */126 // set the processing parameters 127 127 switch (family) { 128 128 case AF_INET: … … 142 142 } 143 143 144 / * Erase if no address */144 // erase if no address 145 145 if (!address) { 146 146 bzero(data, count); … … 148 148 } 149 149 150 / * Process string from the beginning */150 // process the string from the beginning 151 151 next = address; 152 152 index = 0; 153 153 do { 154 / * If the actual character is set */154 // if the actual character is set 155 155 if (next && *next) { 156 156 157 / * If not on the first character */157 // if not on the first character 158 158 if (index) { 159 / * Move to the next character */159 // move to the next character 160 160 ++next; 161 161 } 162 162 163 / * Parse the actual integral value */163 // parse the actual integral value 164 164 value = strtoul(next, &last, base); 165 /* 166 * Remember the last problematic character 167 * should be either '.' or ':' but is ignored to be 168 * more generic 169 */ 165 // remember the last problematic character 166 // should be either '.' or ':' but is ignored to be more 167 // generic 170 168 next = last; 171 169 172 / * Fill the address data byte by byte */170 // fill the address data byte by byte 173 171 shift = bytes - 1; 174 172 do { 175 / * like little endian */173 // like little endian 176 174 data[index + shift] = value; 177 175 value >>= 8; … … 180 178 index += bytes; 181 179 } else { 182 / * Erase the rest of the address */180 // erase the rest of the address 183 181 bzero(data + index, count - index); 184 182 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.