📄 test.c
字号:
#include <stdio.h>
#include <vxWorks.h>
#include "stdioLib.h"
#include "ioLib.h"
#include <string.h>
#include "ctype.h"
#include "inetLib.h"
typedef struct
{
UINT32 IpAddress;
UINT32 SubnetMask;
UINT32 Gateway;
} IP_ALL_CONFIGURE;
typedef struct
{
IP_ALL_CONFIGURE localip;
UINT32 remoteip;
UINT16 remoteport;
UINT16 localport;
}IP_INFO_T;
int fd()
{
usrTffsConfig(0,0,"/flash0/");
unlink("/flash0/ipinfo.cfg");
return 0;
}
int t1()
{
int fd,size,rs;
struct in_addr IpAddr;
IP_INFO_T ip,tmp;
char ip1[20],ip2[20];
char s[]= "192.168.0.245";
tmp.localip.IpAddress = inet_addr("192.168.0.244");
tmp.localip.SubnetMask = inet_addr("255.255.255.0");
tmp.localip.Gateway =0;
tmp.remoteip = inet_addr("192.168.0.160");
tmp.localport = 1235;
tmp.remoteport = 1236;
usrTffsConfig(0,0,"/flash0/");
/*
fd=open("/flash0/tmp.cfg",0x0201);
write(fd,&tmp,sizeof(tmp));
close(fd);
unlink("/flash0/ipinfo.cfg");
return 0;
*/
fd=open("/flash0/ipinfo.cfg",2,7777);
rs = write(fd,&tmp,sizeof(tmp));
if(rs!= sizeof(tmp))
printf("\n write err\n");
close(fd);
fd=open("/flash0/ipinfo.cfg",0,0644);
size=read(fd,&ip,sizeof(tmp));
close(fd);
IpAddr.s_addr = ip.localip.IpAddress;
inet_ntoa_b(IpAddr,ip1);
IpAddr.s_addr = ip.remoteip;
inet_ntoa_b(IpAddr,ip2);
printf("%d,%d,%d,%s,%s,%d,%d\n",fd,rs,size,ip1,ip2, ip.localport,ip.remoteport);
return 0;
}
#if 0
int t2()
{
int ipcfg;
IP_INFO tmp,g_ip;
usrTffsConfig(0,0,"/flash0/");
strcpy(tmp.localipaddr,"192.168.0.249");
strcpy(tmp.remoteipaddr,"192.168.0.161");
tmp.localport = 127;
tmp.remoteport = 126;
if(remove("/flash0/addr.cfg")!=OK)
printf("remove err\n");
if( (ipcfg = open("/flash0/addr.cfg",0,0)) == ERROR )
{
printf("sory open cfg fail and write nmm.cfg again\n");
ipcfg = open("/flash0/addr.cfg",0x0201,0);
write(ipcfg,&tmp,sizeof(tmp));
}
close(ipcfg);
ipcfg = open("/flash0/addr.cfg",0,0);
read(ipcfg, &g_ip,sizeof(g_ip));
close(ipcfg);
printf("trytytyt %s,ryy %s,try %d,try %d\n",
g_ip.localipaddr,g_ip.remoteipaddr,g_ip.remoteport,g_ip.localport);
}
#endif
int csys()
{
int syscfg;
usrTffsConfig(0,0,"/flash0/");
syscfg = open("/flash0/syscfg.cfg",0x0201,0);
if(syscfg == ERROR)
printf("create file error\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -