~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/icmp/Icmp4.h

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2009-09-24 14:51:06 UTC
  • mfrom: (1.1.12 upstream)
  • mto: (20.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090924145106-38jgrzmj0d73pha5
Tags: 3.1.0.13-1
* Upload to experimental

* New upstream release
  - Fixes Follow-X-Forwarded-For support (Closes: #523943)
  - Adds IPv6 support (Closes: #432351)

* debian/rules
  - Removed obsolete configuration options
  - Enable db and radius basic authentication modules

* debian/patches/01-cf.data.debian
  - Adapted to new upstream version

* debian/patches/02-makefile-defaults
  - Adapted to new upstream version

* debian/{squid.postinst,squid.rc,README.Debian,watch}
  - Updated references to squid 3.1

* debian/squid3.install
  - Install CSS file for error pages
  - Install manual pages for new authentication modules

* debian/squid3-common.install
  - Install documented version of configuration file in /usr/share/doc/squid3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id$
 
3
 *
 
4
 * DEBUG: section 37    ICMP Routines
 
5
 * AUTHOR: Duane Wessels, Amos Jeffries
 
6
 *
 
7
 * SQUID Web Proxy Cache          http://www.squid-cache.org/
 
8
 * ----------------------------------------------------------
 
9
 *
 
10
 *  Squid is the result of efforts by numerous individuals from
 
11
 *  the Internet community; see the CONTRIBUTORS file for full
 
12
 *  details.   Many organizations have provided support for Squid's
 
13
 *  development; see the SPONSORS file for full details.  Squid is
 
14
 *  Copyrighted (C) 2001 by the Regents of the University of
 
15
 *  California; see the COPYRIGHT file for full details.  Squid
 
16
 *  incorporates software developed and/or copyrighted by other
 
17
 *  sources; see the CREDITS file for full details.
 
18
 *
 
19
 *  This program is free software; you can redistribute it and/or modify
 
20
 *  it under the terms of the GNU General Public License as published by
 
21
 *  the Free Software Foundation; either version 2 of the License, or
 
22
 *  (at your option) any later version.
 
23
 *
 
24
 *  This program is distributed in the hope that it will be useful,
 
25
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
26
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
27
 *  GNU General Public License for more details.
 
28
 *
 
29
 *  You should have received a copy of the GNU General Public License
 
30
 *  along with this program; if not, write to the Free Software
 
31
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
 
32
 *
 
33
 */
 
34
#ifndef _INCLUDE_ICMPV4_H
 
35
#define _INCLUDE_ICMPV4_H
 
36
 
 
37
#include "config.h"
 
38
#include "Icmp.h"
 
39
 
 
40
#if HAVE_NETINET_IN_SYSTM_H
 
41
#include <netinet/in_systm.h>
 
42
#endif
 
43
#if HAVE_NETINET_IN_H
 
44
#include <netinet/in.h>
 
45
#endif
 
46
#if HAVE_NETINET_IP_H
 
47
#include <netinet/ip.h>
 
48
#endif
 
49
#if HAVE_NETINET_IP_ICMP_H
 
50
#include <netinet/ip_icmp.h>
 
51
#endif
 
52
 
 
53
#ifndef _SQUID_LINUX_
 
54
#ifndef _SQUID_CYGWIN_
 
55
#ifndef _SQUID_MSWIN_
 
56
#define icmphdr icmp
 
57
#define iphdr ip
 
58
#endif
 
59
#endif
 
60
#endif
 
61
 
 
62
/* Linux uses its own field names. */
 
63
#if defined (_SQUID_LINUX_)
 
64
#ifdef icmp_id
 
65
#undef icmp_id
 
66
#endif
 
67
#ifdef icmp_seq
 
68
#undef icmp_seq
 
69
#endif
 
70
#define icmp_type type
 
71
#define icmp_code code
 
72
#define icmp_cksum checksum
 
73
#define icmp_id un.echo.id
 
74
#define icmp_seq un.echo.sequence
 
75
#define ip_hl ihl
 
76
#define ip_v version
 
77
#define ip_tos tos
 
78
#define ip_len tot_len
 
79
#define ip_id id
 
80
#define ip_off frag_off
 
81
#define ip_ttl ttl
 
82
#define ip_p protocol
 
83
#define ip_sum check
 
84
#define ip_src saddr
 
85
#define ip_dst daddr
 
86
#endif
 
87
 
 
88
 
 
89
/* Native Windows port doesn't have netinet support, so we emulate it.
 
90
   At this time, Cygwin lacks icmp support in its include files, so we need
 
91
   to use the native Windows port definitions.
 
92
 */
 
93
 
 
94
#ifdef _SQUID_WIN32_
 
95
 
 
96
#include "fde.h"
 
97
 
 
98
#ifdef _SQUID_MSWIN_
 
99
 
 
100
#if HAVE_WINSOCK2_H
 
101
#include <winsock2.h>
 
102
#endif
 
103
#include <process.h>
 
104
 
 
105
#endif
 
106
 
 
107
/* IP Header */
 
108
typedef struct iphdr {
 
109
 
 
110
u_int8_t  ip_vhl:
 
111
    4;          /* Length of the header in dwords */
 
112
 
 
113
u_int8_t  version:
 
114
    4;  /* Version of IP                  */
 
115
    u_int8_t  tos;              /* Type of service                */
 
116
    u_int16_t total_len;        /* Length of the packet in dwords */
 
117
    u_int16_t ident;            /* unique identifier              */
 
118
    u_int16_t flags;            /* Flags                          */
 
119
    u_int8_t  ip_ttl;           /* Time to live                   */
 
120
    u_int8_t  proto;            /* Protocol number (TCP, UDP etc) */
 
121
    u_int16_t checksum;         /* IP checksum                    */
 
122
    u_int32_t source_ip;
 
123
    u_int32_t dest_ip;
 
124
} iphdr;
 
125
 
 
126
/* ICMP header */
 
127
typedef struct icmphdr {
 
128
    u_int8_t  icmp_type;        /* ICMP packet type                 */
 
129
    u_int8_t  icmp_code;        /* Type sub code                    */
 
130
    u_int16_t icmp_cksum;
 
131
    u_int16_t icmp_id;
 
132
    u_int16_t icmp_seq;
 
133
    u_int32_t timestamp;        /* not part of ICMP, but we need it */
 
134
} icmphdr;
 
135
 
 
136
#endif  /* _SQUID_MSWIN_ */
 
137
 
 
138
#ifndef ICMP_ECHO
 
139
#define ICMP_ECHO 8
 
140
#endif
 
141
 
 
142
#ifndef ICMP_ECHOREPLY
 
143
#define ICMP_ECHOREPLY 0
 
144
#endif
 
145
 
 
146
#ifndef IPPROTO_ICMP
 
147
#define IPPROTO_ICMP 1
 
148
#endif
 
149
 
 
150
/* some OS apparently define icmp instead of icmphdr */
 
151
#if !defined(icmphdr) && defined(icmp)
 
152
#define icmphdr icmp
 
153
#endif
 
154
 
 
155
/* some OS apparently define ip instead of iphdr */
 
156
#if !defined(iphdr) && defined(ip)
 
157
#define iphdr ip
 
158
#endif
 
159
 
 
160
/**
 
161
 * Class partially implementing RFC 792 - ICMP for IP version 4.
 
162
 * Provides ECHO-REQUEST, ECHO-REPLY (secion 4.1)
 
163
 */
 
164
class Icmp4 : public Icmp
 
165
{
 
166
public:
 
167
    Icmp4();
 
168
    virtual ~Icmp4();
 
169
 
 
170
    virtual int Open();
 
171
 
 
172
#if USE_ICMP
 
173
    virtual void SendEcho(IpAddress &, int, const char*, int);
 
174
    virtual void Recv(void);
 
175
#endif
 
176
};
 
177
 
 
178
#if USE_ICMP
 
179
 
 
180
/// pinger helper contains one of these as a global object.
 
181
SQUIDCEXTERN Icmp4 icmp4;
 
182
 
 
183
#endif /* USE_ICMP && SQUID_HELPER */
 
184
 
 
185
#endif