lkml.org 
[lkml]   [2008]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/4 2.6.28] cxgb3 - manage a private ip address for iSCSI
Andrew Morton wrote:
>> + unsigned long octet;
>> + const char *parse = buf;
>> + char *endp;
>> + int i;
>> +
>> + for (i = 1; i <= 4; i++) {
>> + octet = simple_strtoul(parse, &endp, 10);
>> + if (endp == buf || octet > 255 ||
>> + (i < 4 && *endp != '.') ||
>> + (i == 4 && *endp != '\0' && *endp != '\n'))
>> + return -EINVAL;
>> + a = (a << 8) | octet;
>> + parse = endp+1;
>> + }
>> + pi->iscsi_ipaddr = htonl(a);
>> + return endp-buf;
>> +}
>>
>
> This appears to be taking a dotted quad ipv4 address in ascii form,
> turning it into a u32 while performing checking?
>
> Surely we have a library function somewhere in networking which does
> this? If not, I'd suggest writing one.
>
>

try in_aton() from include/linux/inet.h.






\
 
 \ /
  Last update: 2008-08-22 21:17    [W:0.044 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site