/*-------------------------------------------------------------*/
/***************************************************************
* Refer to RFC 792 to obtain more information about ICMP. *
***************************************************************/
/*-------------------------------------------------------------*/
typedef enum {
NETWIB_ICMP4CODE_DESTUNREACH_NET = 0,
NETWIB_ICMP4CODE_DESTUNREACH_HOST = 1,
NETWIB_ICMP4CODE_DESTUNREACH_PROTO = 2,
NETWIB_ICMP4CODE_DESTUNREACH_PORT = 3,
NETWIB_ICMP4CODE_DESTUNREACH_FRAG = 4,
NETWIB_ICMP4CODE_DESTUNREACH_SR = 5,
NETWIB_ICMP4CODE_DESTUNREACH_NETUNKNOWN = 6,
NETWIB_ICMP4CODE_DESTUNREACH_HOSTUNKNOWN = 7,
NETWIB_ICMP4CODE_DESTUNREACH_HOSTISOL = 8,
NETWIB_ICMP4CODE_DESTUNREACH_NETPROHI = 9,
NETWIB_ICMP4CODE_DESTUNREACH_HOSTPROHI = 10,
NETWIB_ICMP4CODE_DESTUNREACH_NETTOS = 11,
NETWIB_ICMP4CODE_DESTUNREACH_HOSTTOS = 12,
NETWIB_ICMP4CODE_DESTUNREACH_PROHI = 13,
NETWIB_ICMP4CODE_DESTUNREACH_PRECVIOL = 14,
NETWIB_ICMP4CODE_DESTUNREACH_PRECCUTOFF = 15
} netwib_icmp4code_destunreach;
/* Name : netwib_icmp4_init_destunreach
Description :
Create a netwib_icmp4hdr and its data.
Input parameter(s) :
code : NETWIB_ICMP4_DESTUNREACH_xyz
*pbadippacket : bad ip packet to store inside the icmp4data
Input/output parameter(s) :
*picmp4hdr : netwib_icmp4hdr created
*picmp4icmp4data : buffer set with icmp4 data
Output parameter(s) :
Normal return values :
NETWIB_ERR_OK : ok
*/
netwib_err netwib_icmp4_init_destunreach(netwib_icmp4code_destunreach code,
netwib_constbuf *pbadippacket,
netwib_icmp4hdr *picmp4hdr,
netwib_buf *picmp4data);
/* Name : netwib_icmp4_decode_destunreach
Description :
Decode a netwib_icmp4hdr and its data.
Input parameter(s) :
icmp4hdr : netwib_icmp4hdr to analyze
icmp4data : icmp4 data to analyze
Input/output parameter(s) :
*pbadippacket : bad ip packet
Output parameter(s) :
*pcode : NETWIB_ICMP4_DESTUNREACH_xyz
Normal return values :
NETWIB_ERR_OK : ok
*/
netwib_err netwib_icmp4_decode_destunreach(netwib_consticmp4hdr *picmp4hdr,
netwib_constbuf *picmp4data,
netwib_icmp4code_destunreach *pcode,
netwib_bufext *pbadippacket);
/*-------------------------------------------------------------*/
typedef enum {
NETWIB_ICMP4CODE_TIMEEXCEED_TTL = 0,
NETWIB_ICMP4CODE_TIMEEXCEED_FRAG = 1
} netwib_icmp4code_timeexceed;
netwib_err netwib_icmp4_init_timeexceed(netwib_icmp4code_timeexceed code,
netwib_constbuf *pbadippacket,
netwib_icmp4hdr *picmp4hdr,
netwib_buf *picmp4data);
netwib_err netwib_icmp4_decode_timeexceed(netwib_consticmp4hdr *picmp4hdr,
netwib_constbuf *picmp4data,
netwib_icmp4code_timeexceed *pcode,
netwib_bufext *pbadippacket);
/*-------------------------------------------------------------*/
typedef enum {
NETWIB_ICMP4CODE_PARAPROB_POINTER = 0,
NETWIB_ICMP4CODE_PARAPROB_MISSOPT = 1,
NETWIB_ICMP4CODE_PARAPROB_BADLEN = 2
} netwib_icmp4code_paraprob;
netwib_err netwib_icmp4_init_paraprob(netwib_icmp4code_paraprob code,
netwib_uint8 pointer,
netwib_constbuf *pbadippacket,
netwib_icmp4hdr *picmp4hdr,
netwib_buf *picmp4data);
netwib_err netwib_icmp4_decode_paraprob(netwib_consticmp4hdr *picmp4hdr,
netwib_constbuf *picmp4data,
netwib_icmp4code_paraprob *pcode,
netwib_uint8 *ppointer,
netwib_bufext *pbadippacket);
/*-------------------------------------------------------------*/
netwib_err netwib_icmp4_init_srcquench(netwib_constbuf *pbadippacket,
netwib_icmp4hdr *picmp4hdr,
netwib_buf *picmp4data);
netwib_err netwib_icmp4_decode_srcquench(netwib_consticmp4hdr *picmp4hdr,
netwib_constbuf *picmp4data,
netwib_bufext *pbadippacket);
/*-------------------------------------------------------------*/
typedef enum {
NETWIB_ICMP4CODE_REDIRECT_NET = 0,
NETWIB_ICMP4CODE_REDIRECT_HOST = 1,
NETWIB_ICMP4CODE_REDIRECT_NETTOS = 2,
NETWIB_ICMP4CODE_REDIRECT_HOSTTOS = 3
} netwib_icmp4code_redirect;
netwib_err netwib_icmp4_init_redirect(netwib_icmp4code_redirect code,
netwib_ip *pgw,
netwib_constbuf *pbadippacket,
netwib_icmp4hdr *picmp4hdr,
netwib_buf *picmp4data);
netwib_err netwib_icmp4_decode_redirect(netwib_consticmp4hdr *picmp4hdr,
netwib_constbuf *picmp4data,
netwib_icmp4code_redirect *pcode,
netwib_ip *pgw,
netwib_bufext *pbadippacket);
/*-------------------------------------------------------------*/
netwib_err netwib_icmp4_init_echo(netwib_icmp4type type,
netwib_uint16 id,
netwib_uint16 seqnum,
netwib_constbuf *pechodata,
netwib_icmp4hdr *picmp4hdr,
netwib_buf *picmp4data);
netwib_err netwib_icmp4_decode_echo(netwib_consticmp4hdr *picmp4hdr,
netwib_constbuf *picmp4data,
netwib_icmp4type *ptype,
netwib_uint16 *pid,
netwib_uint16 *pseqnum,
netwib_bufext *pechodata);
/*-------------------------------------------------------------*/
netwib_err netwib_icmp4_init_timestamp(netwib_icmp4type type,
netwib_uint16 id,
netwib_uint16 seqnum,
netwib_uint32 originatetimestamp,
netwib_uint32 receivetimestamp,
netwib_uint32 transmittimestamp,
netwib_icmp4hdr *picmp4hdr,
netwib_buf *picmp4data);
netwib_err netwib_icmp4_decode_timestamp(netwib_consticmp4hdr *picmp4hdr,
netwib_constbuf *picmp4data,
netwib_icmp4type *ptype,
netwib_uint16 *pid,
netwib_uint16 *pseqnum,
netwib_uint32 *poriginatetimestamp,
netwib_uint32 *preceivetimestamp,
netwib_uint32 *ptransmittimestamp);
/*-------------------------------------------------------------*/
netwib_err netwib_icmp4_init_info(netwib_icmp4type type,
netwib_uint16 id,
netwib_uint16 seqnum,
netwib_icmp4hdr *picmp4hdr,
netwib_buf *picmp4data);
netwib_err netwib_icmp4_decode_info(netwib_consticmp4hdr *picmp4hdr,
netwib_constbuf *picmp4data,
netwib_icmp4type *ptype,
netwib_uint16 *pid,
netwib_uint16 *pseqnum);
/*-------------------------------------------------------------*/
/* Try to decode errors :
NETWIB_ICMP4TYPE_DESTUNREACH
NETWIB_ICMP4TYPE_TIMEEXCEED
NETWIB_ICMP4TYPE_PARAPROB
NETWIB_ICMP4TYPE_SRCQUENCH
NETWIB_ICMP4TYPE_REDIRECT
Output parameters represents needed parameters for each type.
*/
netwib_err netwib_icmp4_decode_error(netwib_consticmp4hdr *picmp4hdr,
netwib_constbuf *picmp4data,
netwib_icmp4type *ptype,
netwib_icmp4code *pcode,
netwib_uint8 *ppointer,
netwib_ip *pgw,
netwib_bufext *pbadippacket);
/*-------------------------------------------------------------*/
/* Name : netwib_ip64bits_init_ip4xyz
Description :
Initialize a buffer containing an IP header and
64 bits of data.
This kind of packets are needed for errors (cf. rfc 792).
Input parameter(s) :
*pip4hdr : IP header
*pipdata : IP data
*phdrudp : udp header
*phdrtcp : tcp header
Input/output parameter(s) :
Output parameter(s) :
*pip64bits : buffer containing an IP header and
64 bits of data.
Normal return values :
NETWIB_ERR_OK : ok
*/
netwib_err netwib_ip64bits_init_ip4pkt(netwib_constbuf *pip4pkt,
netwib_bufext *pip64bits);
/*-------------------------------------------------------------*/
/* Name : netwib_ip64bits_decode_ip4xyz
Description :
Try to decode ip packet contained in ip64bits.
Input parameter(s) :
*pip64bits : ip header and at least 64 bits of ip data
Input/output parameter(s) :
Output parameter(s) :
*pip4hdr : decoded IP header
*pip4data : buffer containing ip data
*pudpsrc : udp source port
*pudpdst : udp destination port
*pudplen : udp len
*pudpcheck : udp checksum
*ptcpsrc : tcp source port
*ptcpdst : tcp destination port
*pseqnum : tcp sequence number
Normal return values :
NETWIB_ERR_OK : ok
NETWIB_ERR_OKNOTDECODED : packet not decoded
*/
netwib_err netwib_ip64bits_decode_ip4optdata(netwib_constbuf *pip64bits,
netwib_ip4hdr *pip4hdr,
netwib_bufext *pip4opt,
netwib_bufext *pip4data);
#define netwib_ip64bits_decode_ip4data(pip64bits,pip4hdr,pip4data) netwib_ip64bits_decode_ip4optdata(pip64bits,pip4hdr,NULL,pip4data)
netwib_err netwib_ip64bits_decode_ip4optudp(netwib_constbuf *pip64bits,
netwib_ip4hdr *pip4hdr,
netwib_bufext *pip4opt,
netwib_port *pudpsrc,
netwib_port *pudpdst,
netwib_uint16 *pudplen,
netwib_uint16 *pudpcheck);
#define netwib_ip64bits_decode_ip4udp(pip64bits,pip4hdr,pudpsrc,pudpdst,pudplen,pudpcheck) netwib_ip64bits_decode_ip4optudp(pip64bits,pip4hdr,NULL,pudpsrc,pudpdst,pudplen,pudpcheck)
netwib_err netwib_ip64bits_decode_ip4opttcp(netwib_constbuf *pip64bits,
netwib_ip4hdr *pip4hdr,
netwib_bufext *pip4opt,
netwib_port *ptcpsrc,
netwib_port *ptcpdst,
netwib_uint32 *ptcpseqnum);
#define netwib_ip64bits_decode_ip4tcp(pip64bits,pip4hdr,ptcpsrc,ptcpdst,ptcpseqnum) netwib_ip64bits_decode_ip4opttcp(pip64bits,pip4hdr,NULL,ptcpsrc,ptcpdst,ptcpseqnum)