X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibnet.so_src%2Faddress.c;fp=Usermode%2FLibraries%2Flibnet.so_src%2Faddress.c;h=8887362d69a52a765023e5228e5162d019713642;hb=f01369e4fd327273b326a82b3e082210ceee631b;hp=66a28b1b45b22fe08b75d11dcc7c7ff1914a05a0;hpb=410beec382d925d02b248e66a0ec9d41e53931a1;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libnet.so_src/address.c b/Usermode/Libraries/libnet.so_src/address.c index 66a28b1b..8887362d 100644 --- a/Usermode/Libraries/libnet.so_src/address.c +++ b/Usermode/Libraries/libnet.so_src/address.c @@ -7,7 +7,8 @@ */ #include #include -#include +//#include +#include #define DEBUG 0 static inline uint32_t htonl(uint32_t v) @@ -37,43 +38,50 @@ static inline uint16_t htons(uint16_t v) */ static int Net_ParseIPv4Addr(const char *String, uint8_t *Addr) { - int i = 0; int j; - int val; + const char *pos = String; - for( j = 0; String[i] && j < 4; j ++ ) + for( j = 0; *pos && j < 4; j ++ ) { - val = 0; - for( ; String[i] && String[i] != '.'; i++ ) - { - if('0' > String[i] || String[i] > '9') { - #if DEBUG - printf("0 255) { #if DEBUG - printf("val > 255 (%i)\n", val); + _SysDebug("%s: val > 255 (%i)", __func__, val); #endif return 0; } + #if DEBUG + _SysDebug("%s: Comp '%.*s' = %lu", __func__, end - pos, pos, val); + #endif Addr[j] = val; - if(String[i] == '.') - i ++; + pos = end; + + if(*pos == '.') + pos ++; } if( j != 4 ) { #if DEBUG - printf("4 parts expected, %i found\n", j); + _SysDebug("%s: 4 parts expected, %i found", __func__, j); #endif return 0; } - if(String[i] != '\0') { + if(*pos != '\0') { #if DEBUG - printf("EOS != '\\0', '%c'\n", String[i]); + _SysDebug("%s: EOS != '\\0', '%c'", __func__, *pos); #endif return 0; }