hi tanks
I have some problems with it...
I have a form that have 2 textfield. when I fill the textfields and I press sumbit bottom I have in the url this
any.html/?ip=192.168.001.098&ip=255.255.255.000
Suppose that I put these values...
and int form structure I have
const FORM_STRUCTURE forms[] =
{
// {"led", form_led_function},
{"serial", form_serial_function},
{"var", form_var_function},
{"ip", form_ip_function},
};
and in my form ip function
void form_ip_function( char *data )
{
char n=0;
for (n=0; n<=14; n++)
{
if(n<=14)
{
IP[n]=data[n];
}
if(n>=19 & n<=33)
{
Mask[n-19]=data[n];
}
}
IP_v4=datastrtoint(IP); // convierte a entero y lo coloca en ipv4
Mask_v4=datastrtoint(Mask);
netstatic[0].n_ipaddr = (IP_v4);
netstatic[0].snmask = (Mask_v4);
//LCD_Init();
//LCD_String_CFE(data,3,2);
}
the function datastrtoint converts the data char to int and return the value for the struct that has the ip and submask in iniche code, these is the code...
int datastrtoint(char *string)
{
int x=0,n=0;
char num0[3],num1[3],num2[3],num3[3];
int octeto0,octeto1,octeto2,octeto3;
int data;
// length=strlen(data);
for(n=0; string[n]; n++)
{
if(n<=2)
{
num0[n]=string[n]-48;
}
if(n>3 && n<=6)
{
num1[n-4]=string[n]-48;
}
if(n>7 && n<=10)
{
num2[n-8]=string[n]-48;
}
if(n>11 && n<=14)
{
num3[n-12]=string[n]-48;
}
}
octeto0=num0[0]*100+num0[1]*10+num0[2];
octeto1=num1[0]*100+num1[1]*10+num1[2];
octeto2=num2[0]*100+num2[1]*10+num2[2];
octeto3=num3[0]*100+num3[1]*10+num3[2];
data=(octeto0*16777216)+(octeto1*65536)+(octeto2*256)+(octeto3);
return data;
}
Suppose that I put these values I don’t know if this is the best way to do it but I am newbie …. But the problem is when I try to fill the html text field with the ip and mask with the values that I want. I don’t know what happens but the server gets other sbmask or something bad… I tried comment the line that change the submask :netstatic[0].snmask = (Mask_v4);And I can change the ip address without problems.