Sportica   Sportica

Set_Ntp and Get_Ntp 主要是IP


int  __ns8__GetNTP(struct soap* soap, struct _ns8__GetNTP *ns8__GetNTP, struct _ns8__GetNTPResponse *ns8__GetNTPResponse)
{

printf("%s\n",__FUNCTION__);

readIPaddr(); //read NTP configuration
struct ns3__NTPInformation *pNTPInformation;
pNTPInformation=(struct ns3__NTPInformation*)soap_malloc(soap, sizeof(struct ns3__NTPInformation));
memset(pNTPInformation, 0, sizeof(struct ns3__NTPInformation));

// No support DHCP
pNTPInformation->FromDHCP = xsd__boolean__false_;
pNTPInformation->__sizeNTPFromDHCP = 0;
pNTPInformation->__sizeNTPManual = 1;

// Set NTP Manual parameter
struct ns3__NetworkHost *pNTPManual;
pNTPManual=(struct ns3__NetworkHost*)soap_malloc(soap, sizeof(struct ns3__NetworkHost));
memset(pNTPManual, 0, sizeof(struct ns3__NetworkHost));
pNTPManual->Type = ns3__NetworkHostType__IPv4;

static char *pAddr[16] = {NULL};
static char szTmp[16] = {0};

strcpy(szTmp, readIPaddr_r[0].IP4);

*pAddr = szTmp;

pNTPManual->IPv4Address = pAddr;

pNTPInformation->NTPManual = pNTPManual;

ns8__GetNTPResponse->NTPInformation = pNTPInformation;

return SOAP_OK;
}


int  __ns8__SetNTP(struct soap* soap, struct _ns8__SetNTP *ns8__SetNTP, struct _ns8__SetNTPResponse *ns8__SetNTPResponse)
{
printf("%s\n",__FUNCTION__);

if (xsd__boolean__true_ == ns8__SetNTP->FromDHCP)
{
return soap_receiver_fault_subcode(soap, "ActionNotSupported", "DHCPNotSupported", NULL);
}

if (ns3__NetworkHostType__IPv4 == ns8__SetNTP->NTPManual->Type)
{

char *pszIP = NULL;
int judge_IPv4;
pszIP = *(ns8__SetNTP->NTPManual->IPv4Address);

judge_IPv4 = is_valid_ip(pszIP); //判断IP是不是合法  
                                                                                   //IP 地址的判断点这里可以到在这里。
        if(0 == judge_IPv4)
{
writeNTPaddr(pszIP); //保存NTP信息
//printf("success\n");
}
else
{
return soap_receiver_fault_subcode(soap, "ActionNotSupported", "invalidIPv4Address", "invalidIPv4Address IPv4");
}
printf("ip4:%s\n",*(ns8__SetNTP->NTPManual->IPv4Address ));
}
else if (ns3__NetworkHostType__IPv6 == ns8__SetNTP->NTPManual->Type)
{
return soap_receiver_fault_subcode(soap, "ActionNotSupported", "NoSupportedIPv6Address", "No Support IPv6");
}
else if (ns3__NetworkHostType__DNS == ns8__SetNTP->NTPManual->Type)
{
return soap_receiver_fault_subcode(soap, "ActionNotSupported", "NoSupportedDnsName ", "No Support DNS");
}

return SOAP_OK;
}
  


posted @ 2012-03-23 15:49  qingjoin  阅读(543)  评论(0编辑  收藏  举报
  Sportica