I was just wondering if anybody knew how to parse this IP-ranged string:

192.168.1.1-192.168.255.255

as in the case of

X1.X2.X3.X4-Y1.Y2.Y3.Y4

All i know is that i would have to loop until i find a '.' (period), and individually store the different sections (i.e, 192, 168 and stuff) until i reach the '-' sign, and i would repeat the process but store it in different buffers, and then finally compare each of the different subnets to find out their differences (out of 255).

Can somebody give a general example of this?

Thanks!
Posted on 2003-04-16 17:48:28 by Drocon
Yes.
Posted on 2003-04-16 17:53:32 by comrade

Yes.


I'm not wanting somebody to code something for me, if that is what you meant, i was simply seeking a example, so i could learn how to do it :-/

Sorry if i put it in a weird way...
Posted on 2003-04-16 19:02:51 by Drocon
; divide and conquer approach


Parse_Byte_Size_Number PROC pNumber:DWORD
; return value of number at memory pNumber
; stop at non-number
ret
Parse_Byte_Size_Number ENDP


Parse_IP_Address PROC pIP:DWORD
; return IP address in EAX
mov ebx, pIP
; skip whitespace prior to IP number,
; no whitespace allowed around "."
invoke Parse_Byte_Size_Number, ebx
ror eax, 8
; skip over "." period
invoke Parse_Byte_Size_Number, ebx
ror eax, 8
; skip over "." period
invoke Parse_Byte_Size_Number, ebx
ror eax, 8
; skip over "." period
invoke Parse_Byte_Size_Number, ebx
bswap eax
ret
Parse_IP_Address ENDP


Parse_IP_Range PROC uses ESI EDI EBX, pRange:DWORD
; return IP range in EDX:EAX
invoke Parse_IP_Address, pIP
push eax
; skip white space and ensure next character is a "-" dash
inc ebx
invoke Parse_IP_Address, ebx
pop eax
ret
Parse_IP_Range ENDP
This code isn't complete - you fill in the blanks (read comments).
Posted on 2003-04-16 22:08:34 by bitRAKE
Thanks!!!
Posted on 2003-04-16 22:57:08 by Drocon