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.
hi,
now ur on the track ,
instead of hard coding location of array u use dat "=" as start parameter and end with "&" character.
it helps u a lot.
instead of using
<fn> int datastrtoint(char *string)
why dont u try
<fn> int in_reshost(char * host, /* IN - textual IP address or host name */
ip_addr * address, /* OUT - address if successful */
int flags) /* IN - RH_VERBOSE, RH_BLOCK */
sorry i dont undertand this function can you show me an example ...
1.- Does in_reshost function change the ip if I put a string char with the IP?
2.- Can I change submask and gateway with the same function?
thank you ...
best regards
Thanks for answered me
But I need to do multiple variables in one html form
form name="input" action="/lab2.htm">IP:<input type="text" name=user value=""/>Mask:<input type="text" name=user2 value="" /><input type="submit" value="Submit" /></form
When I press the submit bottom I will get two variables in this case the ip and submask that the user write and I need to handler to the forms
if I press submit bottom any.html/?user=192.168.1.0&user2=205.205.205.0and in the structure forms that you say
const FORM_STRUCTURE forms[] =
{
{"led", form_led_function},
{"serial", form_serial_function},
{"var", form_var_function},
{"user", form_user_function},
{"user2", form_user2_function}, //FSL This is not implemented....should remove. Think we can delete the function too!!
{"", form_led_function}
};
void form_user_function (char *data)
{
IP_v4=datastrtoint(data);
netstatic[0].n_ipaddr = (IP_v4);
//LCD_String_CFE(data,0,1);
}
void form_user2_function (char *data)
{
LCD_Init();
LCD_String_CFE(data,3,1);
}
The form_user2_funcion should writte in my lcd but i cant see these data... but if i change the variables in the http direccion. user2 first i can see the data into the lcd characters.
any.html/?user2=192.168.1.0 &user=205.205.205.0
do you knwo what am i doing wrong?
hi ,
see wen u press submit button,u'll get
any.html/?user=192.168.1.0&user2=205.205.205.0
This is the flow in software.
freescale_http_process
freescale_http_read_header
freescale_process_header
pre_process_filename
process_form
<fn>pre_process_filename :check for the "?" and data after "?" is process in <fn>process_form
In process_form check for the structure
const FORM_STRUCTURE forms[] =
{
{"led", form_led_function},
{"serial", form_serial_function},
{"var", form_var_function},
{"user", form_user_function},
{"user2", form_user2_function}, //FSL This is not implemented....should remove. Think we can delete the function too!!
{"", form_led_function}
};
if data after "?" inclued something like led=LED_TOGGLE1
then called appropriate funtion pointer
similarly in ur case u dont require 2 structure entries.u only chk for "user" or "user2" not both and in
their function pointer process all data afterwords.
hi ,
u hv to change ur form function little bit.
1st add ur form function in structure
say,
const FORM_STRUCTURE forms[] =
{
{"led", form_led_function},
{"ip", form_custom_function}
};
then in function form_custom_function
check for the start of ur value by seeing '=' and delimiter '&'
and just save it using flash drivers function.
and while displaying this values on web pages read the correspondig
location from the flash.
Hi
Look at AN3906SW LCF file as a clue to do this in CW. Source code was for a V1, but C and LCF stuff is the same. Now you have to look for a mcf5223x flash driver and how to use this as a reference in interniche stack.