Will this do?
PHP Code:
int len; //length of ICMP
struct icmp ICMP;
int id=getpid();
ICMP.icmp_type=8;
ICMP.icmp_code=0;
ICMP.icmp_id=id;
ICMP.icmp_seq=seq++;
ICMP.icmp_cksum=0;
bcopy(&ICMP, buf, sizeof(ICMP));
len=8;
ICMP.icmp_cksum=do_cksum(len);
int n=sendto(sockR, sendbuf, len, 0, (struct sockaddr *) &serv, sizeof(serv));
ICMP always gets send(checked it with tcpdump)
If I use the following code server sends echo reply
PHP Code:
int id=getpid();
struct icmp *ICMP=(struct icmp *) buf;
ICMP->icmp_type=8;
ICMP->icmp_code=0;
ICMP->icmp_id=id;
ICMP->icmp_seq=16;
ICMP->icmp_cksum=0;
len=8;
ICMP->icmp_cksum=do_cksum(len);
int n=sendto(sockR, sendbuf, len, 0, (struct sockaddr *) &serv, sizeof(serv));