Help!the code of the function of ip_send_ping()!

when i read the sample of GRPS_PING,the problem comes.i cannt find the code of function u8* ip_send_ping(u32 host,u32 LocalAddr,u16* size);u8 ip_check_ping(u8 *packet);
so ,i am expecting an expert to give me some suggestions and show me the code of that functions.
:unamused:

Hi,
The code for ip_send_ping()and ip_check_ping() is not available. These functions are defined object files present in the โ€œ\Samples\adl\Common\srcโ€ folder.
These object files are linked with your Open-AT sample application when you compile your Open AT Application.
I hope that in future releases of Open AT, you might find the code for these functions.

Best Regards,
Open AT Fan.

thank you.
you know ,i am a beginer in wavecom.and the problem i face is how to send packets in 645 protocol format to GPRS by FCM.i beg some experts send me the similar examples .
regards ,thank you .

void scasyip_send_ping (u8 * buff, u32 host, u32 LocalAddr, u16 * size, u16 PayloadLength ){
//u8 buff [ 30 ];
IPDatagram ipPackage;
ICMPDatagram icmpPackage;
//u8 * ptr;

//ptr = &ipPackage;
//IcmpPing(&ipPackage, LocalAddr, host);
ipPackage.Version_HLen = 0x45;
ipPackage.Service = 0;
ipPackage.TotalLength = htons(PACKETSIZE);
ipPackage.ID = 0;
ipPackage.Frag = 0;
ipPackage.TTL = 64;
ipPackage.Protocol = ICMP;
ipPackage.Checksum = 0;
ipPackage.SourceAddress = htonl(LocalAddr);
ipPackage.DestAddress = htonl(host);
ipPackage.Checksum = checksum ((u16 *)(&ipPackage), sizeof(ipPackage) );
//DUMP(1, &ipPackage, sizeof(ipPackage) );

icmpPackage.Type = ECHO;
icmpPackage.Code = 0;
icmpPackage.Checksum = 0;
icmpPackage.Identifier = 0;
icmpPackage.SeqNumber = 0;
icmpPackage.payload[0] = 32;
icmpPackage.payload[1] = 33;
icmpPackage.Checksum = checksum ((u16 *)(&icmpPackage), sizeof(icmpPackage));

//DUMP(1, &icmpPackage, sizeof(icmpPackage) );
wm_memcpy(buff, &ipPackage, sizeof(ipPackage) );
wm_memcpy(buff + sizeof(ipPackage), &icmpPackage, sizeof(icmpPackage) );

//DUMP(1, buff, PACKETSIZE);
*size = sizeof(ipPackage)+sizeof(icmpPackage);
//return buff;

}

u8 scasyip_check_ping(u8 * buf, u16 DataLen){
IPDatagram *iphdr = NULL;
ICMPDatagram *icmphdr = NULL;
u16 iphdrlen;
u32 tick;
static u32 icmpcount = 0;
DUMP(1, buf, DataLen );
iphdr = (IPDatagram *)buf;
// Number of 32-bit words * 4 = bytes
iphdrlen = (iphdr->Version_HLen & 0x0F) * 4;//iphdr->Length h_len * 4;
//tick = GetTickCount();

icmphdr = (ICMPDatagram *)(buf + iphdrlen);

if (icmphdr->Type != ECHO_REPLY) 
{
    TRACE((1, "nonecho type %d recvd\n", icmphdr->Type));
}

//printf("%d bytes from %s:", bytes, inet_ntoa(from->sin_addr));
TRACE((1, " icmp_seq = %d. ", icmphdr->Type));

//icmpcount++;
return icmphdr->Type;

}

but my udp package failed to reach udp server and the following is my code. Is anyone knows whatโ€™s wrong with that.

#define htons(A) ((((A) & 0xFF00) >> 8) | (((A) & 0x00FF) << 8))
#define htonl(A) ((((A) & 0xFF000000) >> 24) | (((A) & 0x00FF0000) >> 8) | (((A) & 0x0000FF00) << 8) | (((A) & 0x000000FF) << 24))

#define TCP 0x06
#define UDP 0x11
#define ICMP 0x01

typedef struct {
u8 Version_HLen;
u8 Service;
u16 TotalLength;
u16 ID;
u16 Frag;
u8 TTL;
u8 Protocol;
u16 Checksum;
u32 SourceAddress;
u32 DestAddress;
//u8 Payload [10];
} IPDatagram;

//IPDatagram *ip_out;
u16 checksum(u16 *buffer, s32 size)
{
unsigned long cksum=0;

while (size > 1)
{
    cksum += *buffer++;
    size  -= sizeof(u16);   
}
if (size)
{
    cksum += *(u8*)buffer;   
}
cksum = (cksum >> 16) + (cksum & 0xffff);
cksum += (cksum >>16); 

return (u16)(~cksum); 

}

#define ECHO 8
#define ECHO_REPLY 0
#define TRACEROUTE 30

//u8 IPAddress [4];
typedef struct {
u8 Type;
u8 Code;
u16 Checksum;
u16 Identifier;
u16 SeqNumber;
u8 payload[2];
} ICMPDatagram;//8

typedef struct {
u16 src_portno; // Source port number
u16 dst_portno; // Destination port number
u16 udp_length; // UDP packet length
u16 udp_checksum; // UDP checksum (optional)
u8 payload[2];
} UDPDatagram;

u16 scasyip_send_udp(u8 *buff, u32 host, u16 hostport, u32 LocalAddr, u16 localport, u8 *msg){
u16 size, udpsize;
IPDatagram ipPackage;
UDPDatagram udpPackage;
//fill ip package
ipPackage.Version_HLen = 0x45;
ipPackage.Service = 0;
ipPackage.TotalLength = htons(PACKETSIZE);
ipPackage.ID = 0;
ipPackage.Frag = 0;
ipPackage.TTL = 64;
ipPackage.Protocol = UDP;
ipPackage.Checksum = 0;
ipPackage.SourceAddress = htonl(LocalAddr);
ipPackage.DestAddress = htonl(host);
ipPackage.Checksum = checksum ((u16 *)(&ipPackage), sizeof(ipPackage) );
//fill udp datagram
udpPackage.dst_portno = htons(hostport);
udpPackage.src_portno = htons(localport);
udpsize = sizeof(udpPackage);
udpPackage.udp_length = htons(udpsize);
udpPackage.udp_checksum = 0;
udpPackage.payload[0] = 1;
udpPackage.payload[1] = 2;
udpPackage.udp_checksum = checksum( (u16 *)(&udpPackage), sizeof(udpPackage) );
wm_memcpy(buff, &ipPackage, sizeof(ipPackage) );
wm_memcpy(buff + sizeof(ipPackage), &udpPackage, sizeof(udpPackage) );

size = sizeof(ipPackage) + sizeof(udpPackage);
return size;

}
void scasyip_send_ping (u8 * buff, u32 host, u32 LocalAddr, u16 * size, u16 PayloadLength ){
IPDatagram ipPackage;
ICMPDatagram icmpPackage;
//fill ip package
ipPackage.Version_HLen = 0x45;
ipPackage.Service = 0;
ipPackage.TotalLength = htons(PACKETSIZE);
ipPackage.ID = 0;
ipPackage.Frag = 0;
ipPackage.TTL = 64;
ipPackage.Protocol = ICMP;
ipPackage.Checksum = 0;
ipPackage.SourceAddress = htonl(LocalAddr);
ipPackage.DestAddress = htonl(host);
ipPackage.Checksum = checksum ((u16 *)(&ipPackage), sizeof(ipPackage) );
//DUMP(1, &ipPackage, sizeof(ipPackage) );
//fill ICMP package
icmpPackage.Type = ECHO;
icmpPackage.Code = 0;
icmpPackage.Checksum = 0;
icmpPackage.Identifier = 0;
icmpPackage.SeqNumber = 0;
icmpPackage.payload[0] = 32;
icmpPackage.payload[1] = 33;
icmpPackage.Checksum = checksum ((u16 *)(&icmpPackage), sizeof(icmpPackage));

//DUMP(1, &icmpPackage, sizeof(icmpPackage) );
wm_memcpy(buff, &ipPackage, sizeof(ipPackage) );
wm_memcpy(buff + sizeof(ipPackage), &icmpPackage, sizeof(icmpPackage) );

//DUMP(1, buff, PACKETSIZE);
*size = sizeof(ipPackage)+sizeof(icmpPackage);
//return buff;

}
u8 scasyip_check_ping(u8 * buf, u16 DataLen){
IPDatagram *iphdr = NULL;
ICMPDatagram *icmphdr = NULL;
u16 iphdrlen;
u32 tick;
static u32 icmpcount = 0;
DUMP(1, buf, DataLen );
iphdr = (IPDatagram *)buf;
// Number of 32-bit words * 4 = bytes
iphdrlen = (iphdr->Version_HLen & 0x0F) * 4;

icmphdr = (ICMPDatagram *)(buf + iphdrlen);

if (icmphdr->Type != ECHO_REPLY) 
{
    TRACE((1, "nonecho type %d recvd\n", icmphdr->Type));
}

//printf("%d bytes from %s:", bytes, inet_ntoa(from->sin_addr));
TRACE((1, " icmp_seq = %d. ", icmphdr->Type));

//icmpcount++;
return icmphdr->Type;

}
/* Send a Ping packet on GPRS FCM flow /
void SendPingPacket ( void )
{
u16 size, PayloadSize;// = ping_PacketSize - ip_get_header_size();
u8 * PacketToSend;
s32 sFcmReturn;
/
#ifndef SCASY_PING
PayloadSize = ping_PacketSize - ip_get_header_size();
// Update payload size, according to packet number
if ( Ping_Send == ( ping_NbPackets - 1 ) )
{
PayloadSize = ping_LastPacketSize - ip_get_header_size();
}

	// Build packet
	PacketToSend = ip_send_ping ( HostAddr, InfosCid.LocalIP, &size, PayloadSize );		
#else
	PacketToSend = (u8 *)adl_memGet(PACKETSIZE);
	scasyip_send_ping (PacketToSend, HostAddr, InfosCid.LocalIP, &size, PayloadSize );  
#endif
*/ 
if(scasyIP == 1){
	PacketToSend = (u8 *)adl_memGet(PACKETSIZE);
	wm_memset(PacketToSend, 0, PACKETSIZE);
	scasyip_send_ping (PacketToSend, HostAddr, InfosCid.LocalIP, &size, PayloadSize ); 
}else{
	PayloadSize = ping_PacketSize - ip_get_header_size();
	// Update payload size, according to packet number
	if ( Ping_Send == ( ping_NbPackets - 1 ) )
	{
		PayloadSize = ping_LastPacketSize - ip_get_header_size();
	}
	
	// Build packet
	PacketToSend = ip_send_ping ( HostAddr, InfosCid.LocalIP, &size, PayloadSize );
}
TRACE((1, "package size:%d", size));
DUMP ( 1, PacketToSend, size );
/* Send packet */
sFcmReturn = adl_fcmSendData ( FCM_Handler, PacketToSend, size );
Ping_Send++;
if ( sFcmReturn < OK )
{
    TRACE (( 1, "Problem to send the packet" ));    
    adl_atSendResponse ( ADL_AT_UNS, "\r\nCannot send the packet\r\n" );            
}
else
{
    /* OK */
    ascii Rsp [ 40 ];
    TRACE (( 1, "Ping Sent [%d/%d]", Ping_Send + 1, ping_NbPackets ));
    wm_sprintf ( Rsp, "\r\nPing Sent [%d/%d]\r\n", Ping_Send + 1, ping_NbPackets );
    adl_atSendResponse ( ADL_AT_UNS, Rsp );
    
    if ( sFcmReturn == ADL_FCM_RET_OK_WAIT_RESUME )
    {
        // Wait for resume before going on...
		TRACE( (1, "Wait for resume before going on...") );
    }
    else
    {
        /* Start Timer */
        Ping_Timer = adl_tmrSubscribe ( FALSE, ping_Time, ADL_TMR_TYPE_100MS, Ping_TimerHandler );
    }
}

// Release buffer
adl_memRelease ( PacketToSend );

}

void sendUdpPackage( void ){
u16 size, PayloadSize;// = ping_PacketSize - ip_get_header_size();
u8 * PacketToSend;
s32 sFcmReturn;
ascii message[10];

PacketToSend = (u8 *)adl_memGet(PACKETSIZE);
wm_memset( PacketToSend, 0, PACKETSIZE );
size = scasyip_send_udp (PacketToSend, HostAddr, 2008, InfosCid.LocalIP, 57258, message ); 

TRACE((1, "package size:%d", size));
DUMP ( 1, PacketToSend, size );
/* Send packet */
sFcmReturn = adl_fcmSendData ( FCM_Handler, PacketToSend, size );
Ping_Send++;
if ( sFcmReturn < OK )
{
    TRACE (( 1, "Problem to send udp packet" ));    
    adl_atSendResponse ( ADL_AT_UNS, "\r\nCannot send udp packet\r\n" );            
}
else
{
    /* OK */
    //ascii Rsp [ 40 ];
    TRACE (( 1, "udp Sent"));
    //wm_sprintf ( Rsp, "\r\nPing Sent [%d/%d]\r\n", Ping_Send + 1, ping_NbPackets );
    //adl_atSendResponse ( ADL_AT_UNS, Rsp );
    
    if ( sFcmReturn == ADL_FCM_RET_OK_WAIT_RESUME )
    {
        // Wait for resume before going on...
		TRACE( (1, "Wait for resume before going on...") );
    }
    
}

// Release buffer
adl_memRelease ( PacketToSend );

}