ping.h

来自「PPPoE协议在Psos中的实现源代码」· C头文件 代码 · 共 83 行

H
83
字号
#ifndef _PING_H
#define _PING_H

#include "pna.h"
/*#include <pna_mib.h>*/

/*Because PSOS+ socket does not provide ICMP DIRECT access*/
/*so use raw socket and let proto type field in IP head =1*/
/*Will it work?*/

#define ICMP_PROTO 1    
#define	ICMP_ECHOREPLY		0		/* echo reply */
#define	ICMP_UNREACH		3		/* dest unreachable, codes: */
#define		ICMP_UNREACH_NET	0		/* bad net */
#define		ICMP_UNREACH_HOST	1		/* bad host */
#define		ICMP_UNREACH_PROTOCOL	2		/* bad protocol */
#define		ICMP_UNREACH_PORT	3		/* bad port */
#define		ICMP_UNREACH_NEEDFRAG	4		/* IP_DF caused drop */
#define		ICMP_UNREACH_SRCFAIL	5		/* src route failed */
#define	ICMP_SOURCEQUENCH	4		/* packet lost, slow down */
#define	ICMP_REDIRECT		5		/* shorter route, codes: */
#define		ICMP_REDIRECT_NET	0		/* for network */
#define		ICMP_REDIRECT_HOST	1		/* for host */
#define		ICMP_REDIRECT_TOSNET	2		/* for tos and net */
#define		ICMP_REDIRECT_TOSHOST	3		/* for tos and host */
#define	ICMP_ECHO		8		/* echo service */
#define	ICMP_TIMXCEED		11		/* time exceeded, code: */
#define		ICMP_TIMXCEED_INTRANS	0		/* ttl==0 in transit */
#define		ICMP_TIMXCEED_REASS	1		/* ttl==0 in reass */
#define	ICMP_PARAMPROB		12		/* ip header bad */
#define	ICMP_TSTAMP		13		/* timestamp request */
#define	ICMP_TSTAMPREPLY	14		/* timestamp reply */
#define	ICMP_IREQ		15		/* information request */
#define	ICMP_IREQREPLY		16		/* information reply */
#define	ICMP_MASKREQ		17		/* address mask request */
#define	ICMP_MASKREPLY		18		/* address mask reply */

#define BUFSIZE  1500

char recvbuf[BUFSIZE];
char sendbuf[BUFSIZE];
int datalen;   /*bytes of data,following ICMP header */
char *host;
int nsent;  /* add 1 each sendto()*/
int socksend;
int sockrecv;
int nrecv;

struct sockaddr_in sain; 
struct sockaddr_in sarecv; 

struct icmp 
{
  char icmp_type;
  char icmp_code;
  short icmp_cksum;
  short icmp_id;
  short icmp_seq;
  char icmp_data[56];
};

int niInitN;
int niGetN;
int niRetN;
int niSendN;
int niIoctlN;

struct myip
{
char ip_ver_length;
 char ip_service_type;
 short ip_data_length;
 short ip_id;
 short ip_offset;
 char ip_ttl;
 char ip_proto_type;
 char ip_chksum;
 int ip_srcadr;
 int ip_desadr;
};

#endif  /* _PING_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?