~ubuntu-branches/ubuntu/oneiric/openvpn/oneiric

« back to all changes in this revision

Viewing changes to .pc/jjo-ipv6-support.patch/ping.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-06-16 18:33:37 UTC
  • mfrom: (1.1.17 upstream) (10.2.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110616183337-fv50u3kmiabewjq0
Tags: 2.2.0-2ubuntu1
* Merge from debian unstable.  Remaining changes:
 + debian/openvpn.init.d:
    - Do not use start-stop-daemon and </dev/null to avoid blocking boot.
    - Show per-VPN result messages.
    - Add "--script-security 2" by default for backwards compatabliity.
  + debian/control: Add lsb-base >= 3.2-14 to allow status_of_proc()
  + debian/update-resolv-conf: Support multiple domains.
  + fix bug where '--script-security 2' would be passed for all
    daemons after the first. (LP: #794916

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  OpenVPN -- An application to securely tunnel IP networks
3
 
 *             over a single TCP/UDP port, with support for SSL/TLS-based
4
 
 *             session authentication and key exchange,
5
 
 *             packet encryption, packet authentication, and
6
 
 *             packet compression.
7
 
 *
8
 
 *  Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
9
 
 *
10
 
 *  This program is free software; you can redistribute it and/or modify
11
 
 *  it under the terms of the GNU General Public License version 2
12
 
 *  as published by the Free Software Foundation.
13
 
 *
14
 
 *  This program is distributed in the hope that it will be useful,
15
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
 *  GNU General Public License for more details.
18
 
 *
19
 
 *  You should have received a copy of the GNU General Public License
20
 
 *  along with this program (see the file COPYING included with this
21
 
 *  distribution); if not, write to the Free Software Foundation, Inc.,
22
 
 *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
 
 */
24
 
 
25
 
#include "syshead.h"
26
 
 
27
 
#include "ping.h"
28
 
 
29
 
#include "memdbg.h"
30
 
 
31
 
#include "ping-inline.h"
32
 
 
33
 
/*
34
 
 * This random string identifies an OpenVPN ping packet.
35
 
 * It should be of sufficient length and randomness
36
 
 * so as not to collide with other tunnel data.
37
 
 *
38
 
 * PING_STRING_SIZE must be sizeof (ping_string)
39
 
 */
40
 
const uint8_t ping_string[] = {
41
 
  0x2a, 0x18, 0x7b, 0xf3, 0x64, 0x1e, 0xb4, 0xcb,
42
 
  0x07, 0xed, 0x2d, 0x0a, 0x98, 0x1f, 0xc7, 0x48
43
 
};
44
 
 
45
 
/*
46
 
 * Should we exit or restart due to ping (or other authenticated packet)
47
 
 * not received in n seconds?
48
 
 */
49
 
void
50
 
check_ping_restart_dowork (struct context *c)
51
 
{
52
 
  struct gc_arena gc = gc_new ();
53
 
  switch (c->options.ping_rec_timeout_action)
54
 
    {
55
 
    case PING_EXIT:
56
 
      msg (M_INFO, "%sInactivity timeout (--ping-exit), exiting",
57
 
           format_common_name (c, &gc));
58
 
      c->sig->signal_received = SIGTERM;
59
 
      c->sig->signal_text = "ping-exit";
60
 
      break;
61
 
    case PING_RESTART:
62
 
      msg (M_INFO, "%sInactivity timeout (--ping-restart), restarting",
63
 
           format_common_name (c, &gc));
64
 
      c->sig->signal_received = SIGUSR1; /* SOFT-SIGUSR1 -- Ping Restart */
65
 
      c->sig->signal_text = "ping-restart";
66
 
      break;
67
 
    default:
68
 
      ASSERT (0);
69
 
    }
70
 
  gc_free (&gc);
71
 
}
72
 
 
73
 
/*
74
 
 * Should we ping the remote?
75
 
 */
76
 
void
77
 
check_ping_send_dowork (struct context *c)
78
 
{
79
 
  c->c2.buf = c->c2.buffers->aux_buf;
80
 
  ASSERT (buf_init (&c->c2.buf, FRAME_HEADROOM (&c->c2.frame)));
81
 
  ASSERT (buf_safe (&c->c2.buf, MAX_RW_SIZE_TUN (&c->c2.frame)));
82
 
  ASSERT (buf_write (&c->c2.buf, ping_string, sizeof (ping_string)));
83
 
 
84
 
  /*
85
 
   * We will treat the ping like any other outgoing packet,
86
 
   * encrypt, sign, etc.
87
 
   */
88
 
  encrypt_sign (c, true);
89
 
  dmsg (D_PING, "SENT PING");
90