~ubuntu-branches/ubuntu/oneiric/ginkgocadx/oneiric

« back to all changes in this revision

Viewing changes to src/cadxcore/endpoint/tricks.html

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-05-02 08:09:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110502080926-bql5wep49c7hg91t
Tags: upstream-2.4.1.1
ImportĀ upstreamĀ versionĀ 2.4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
<title>Cool Things You Can do With Endpoint</title>
 
4
</head>
 
5
<body>
 
6
<h1>Endpoint: Tips and Tricks</h1>
 
7
 
 
8
<h2>Send/Receive Normal TCP/UDP Traffic</h2>
 
9
<p>This is easy:
 
10
<pre>
 
11
// Choose one of these. It'll return once a connection is established.
 
12
Endpoint ep(TCP | CLIENT, "example.com:80");       // Active open
 
13
Endpoint ep(TCP | SERVER, ":80");                  // Passive open
 
14
Endpoint ep(UDP | CLIENT, "example.com:41170");    // Send
 
15
Endpoint ep(UDP | SERVER, ":41170");               // Receive
 
16
 
 
17
if (!ep)   // If couldn't open socket
 
18
   std::cout << "failed: " << std::endl; 
 
19
 
 
20
// Print out the local and remote address
 
21
std::cout << "New socket: " << ep << std::endl;
 
22
 
 
23
// Find out who we're connected to (note that this is shown above also)
 
24
std::cout << "Connected to: " << string(ep.m_remote) << std::endl;
 
25
 
 
26
// Write some data
 
27
ep.Write("hi");
 
28
</pre>
 
29
 
 
30
<h2>Use IPv6</h2>
 
31
<p>If your host supports it, IPv6 will be automatically enabled. DNS names
 
32
will resolve to 128-bit IPv6 addresses. To <i>specifically</i> use IPv6:
 
33
<pre>
 
34
EndpointAddrlist::g_default_family = AF_INET6;
 
35
</pre>
 
36
<p>Now all DNS names will resolve to IPv6 addresses. (See also: RES_USE_INET6)
 
37
 
 
38
<p>To connect to an IPv6 host without DNS, simply write the address. Use 
 
39
square brackets around the IPv6 address if you're also specifying a port.
 
40
For example, to connect to a local web server you're running on IPv6:
 
41
<pre>
 
42
Endpoint ep(TCP | CLIENT, "[::1]:80");
 
43
 
 
44
</pre>
 
45
 
 
46
<p>If you have IPv6 support but don't want it to get in the way, use:
 
47
<pre>
 
48
EndpointAddrlist::g_default_family = AF_INET;
 
49
</pre>
 
50
 
 
51
<h2>Use Raw Sockets</h2>
 
52
<p>Endpoint now supports raw sockets with IPv4 (IPv6 doesn't have raw sockets;
 
53
you have to use datalink access for that, which Endpoint doesn't currently
 
54
support). If you want to write your own IP header, use RAW.
 
55
 
 
56
<p>A number of transport-layer protocols that sit on top of IPv4 are available
 
57
to Endpoint. To write IGMP packets, for example, use RAW_ICMP. This will make
 
58
the IP header for you, but you have to write the IGMP header.
 
59
 
 
60
<p>RAW_UDP and RAW_ICMP automatically create the UDP or ICMP header for you.
 
61
See the next topic for using ICMP.
 
62
 
 
63
 
 
64
<h2>Send ICMP Messages</h2>
 
65
<p>Simply create a RAW_ICMP | CLIENT socket with your destined address,
 
66
specifying a port number of <i>type</i>,<i>code</i>. For example, to send a
 
67
"host unreachable" ICMP message to 10.3.2.1:
 
68
 
 
69
<pre>
 
70
Endpoint ep(RAW_ICMP | CLIENT, "10.3.2.1:3,1");
 
71
 
 
72
ep.Write("...");
 
73
</pre>
 
74
 
 
75
<p>To send a "ping" (ICMP echo request), replace "3,1" with "8,0". See the
 
76
official <a href="http://www.iana.org/assignments/icmp-parameters">IANA ICMP 
 
77
parameters</a> for more information.
 
78
 
 
79
<p>ICMP can be used as a covert channel. See 
 
80
<a href="http://www.phrack.org/phrack/49/P49-06">Project Loki: ICMP
 
81
Tunnelling</a> in Phrack 49, by Alhambra and daemon9 for an article about this
 
82
steganographic process.