2003-07-18 12:16:24 +00:00
|
|
|
/*
|
|
|
|
ipv4.h -- missing IPv4 related definitions
|
2004-03-21 14:21:22 +00:00
|
|
|
Copyright (C) 2004 Ivo Timmermans <ivo@tinc-vpn.org>
|
|
|
|
2004 Guus Sliepen <guus@tinc-vpn.org>
|
2003-07-18 12:16:24 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
2004-03-21 14:21:22 +00:00
|
|
|
$Id$
|
2003-07-18 12:16:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TINC_IPV4_H__
|
|
|
|
#define __TINC_IPV4_H__
|
|
|
|
|
|
|
|
#ifndef AF_INET
|
|
|
|
#define AF_INET 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef IPPROTO_ICMP
|
|
|
|
#define IPPROTO_ICMP 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ICMP_DEST_UNREACH
|
|
|
|
#define ICMP_DEST_UNREACH 3
|
|
|
|
#endif
|
|
|
|
|
2003-12-22 11:05:23 +00:00
|
|
|
#ifndef ICMP_FRAG_NEEDED
|
|
|
|
#define ICMP_FRAG_NEEDED 4
|
|
|
|
#endif
|
|
|
|
|
2003-07-18 12:16:24 +00:00
|
|
|
#ifndef ICMP_NET_UNKNOWN
|
|
|
|
#define ICMP_NET_UNKNOWN 6
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ICMP_NET_UNREACH
|
|
|
|
#define ICMP_NET_UNREACH 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef IP_MSS
|
|
|
|
#define IP_MSS 576
|
|
|
|
#endif
|
|
|
|
|
2003-07-18 13:42:35 +00:00
|
|
|
#ifndef HAVE_STRUCT_IP
|
2003-07-18 12:16:24 +00:00
|
|
|
struct ip {
|
|
|
|
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
|
|
unsigned int ip_hl:4;
|
|
|
|
unsigned int ip_v:4;
|
|
|
|
#else
|
|
|
|
unsigned int ip_v:4;
|
|
|
|
unsigned int ip_hl:4;
|
|
|
|
#endif
|
|
|
|
uint8_t ip_tos;
|
2003-07-21 13:14:02 +00:00
|
|
|
uint16_t ip_len;
|
|
|
|
uint16_t ip_id;
|
|
|
|
uint16_t ip_off;
|
2003-07-18 12:16:24 +00:00
|
|
|
#define IP_RF 0x8000
|
|
|
|
#define IP_DF 0x4000
|
|
|
|
#define IP_MF 0x2000
|
|
|
|
#define IP_OFFMASK 0x1fff
|
|
|
|
uint8_t ip_ttl;
|
|
|
|
uint8_t ip_p;
|
2003-07-21 13:14:02 +00:00
|
|
|
uint16_t ip_sum;
|
2003-07-18 12:16:24 +00:00
|
|
|
struct in_addr ip_src, ip_dst;
|
2003-10-08 11:34:55 +00:00
|
|
|
} __attribute__ ((__packed__));
|
2003-07-18 12:16:24 +00:00
|
|
|
#endif
|
|
|
|
|
2003-07-18 13:42:35 +00:00
|
|
|
#ifndef HAVE_STRUCT_ICMP
|
2003-07-18 12:16:24 +00:00
|
|
|
struct icmp {
|
|
|
|
uint8_t icmp_type;
|
|
|
|
uint8_t icmp_code;
|
|
|
|
uint16_t icmp_cksum;
|
|
|
|
union {
|
2003-07-21 13:14:02 +00:00
|
|
|
uint8_t ih_pptr;
|
2003-07-18 12:16:24 +00:00
|
|
|
struct in_addr ih_gwaddr;
|
|
|
|
struct ih_idseq {
|
|
|
|
uint16_t icd_id;
|
|
|
|
uint16_t icd_seq;
|
|
|
|
} ih_idseq;
|
|
|
|
uint32_t ih_void;
|
|
|
|
|
|
|
|
|
|
|
|
struct ih_pmtu {
|
|
|
|
uint16_t ipm_void;
|
|
|
|
uint16_t ipm_nextmtu;
|
|
|
|
} ih_pmtu;
|
|
|
|
|
|
|
|
struct ih_rtradv {
|
|
|
|
uint8_t irt_num_addrs;
|
|
|
|
uint8_t irt_wpa;
|
|
|
|
uint16_t irt_lifetime;
|
|
|
|
} ih_rtradv;
|
|
|
|
} icmp_hun;
|
|
|
|
#define icmp_pptr icmp_hun.ih_pptr
|
|
|
|
#define icmp_gwaddr icmp_hun.ih_gwaddr
|
|
|
|
#define icmp_id icmp_hun.ih_idseq.icd_id
|
|
|
|
#define icmp_seq icmp_hun.ih_idseq.icd_seq
|
|
|
|
#define icmp_void icmp_hun.ih_void
|
|
|
|
#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
|
|
|
|
#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
|
|
|
|
#define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs
|
|
|
|
#define icmp_wpa icmp_hun.ih_rtradv.irt_wpa
|
|
|
|
#define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint32_t its_otime;
|
|
|
|
uint32_t its_rtime;
|
|
|
|
uint32_t its_ttime;
|
|
|
|
} id_ts;
|
|
|
|
struct {
|
|
|
|
struct ip idi_ip;
|
|
|
|
} id_ip;
|
|
|
|
uint32_t id_mask;
|
|
|
|
uint8_t id_data[1];
|
|
|
|
} icmp_dun;
|
|
|
|
#define icmp_otime icmp_dun.id_ts.its_otime
|
|
|
|
#define icmp_rtime icmp_dun.id_ts.its_rtime
|
|
|
|
#define icmp_ttime icmp_dun.id_ts.its_ttime
|
|
|
|
#define icmp_ip icmp_dun.id_ip.idi_ip
|
|
|
|
#define icmp_radv icmp_dun.id_radv
|
|
|
|
#define icmp_mask icmp_dun.id_mask
|
|
|
|
#define icmp_data icmp_dun.id_data
|
2003-10-08 11:34:55 +00:00
|
|
|
} __attribute__ ((__packed__));
|
2003-07-18 12:16:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __TINC_IPV4_H__ */
|