File: NewObjects.html

package info (click to toggle)
python-libtrace 1.6%2Bgit20161027-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,124 kB
  • ctags: 1,357
  • sloc: ansic: 6,890; python: 3,228; makefile: 70; sh: 49
file content (87 lines) | stat: -rw-r--r-- 2,991 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Making new objects</title><meta name="generator" content="KompoZer" /><link rel="stylesheet" type="text/css" href="plt-doc.css" /></head><body>
<h2>Making New Objects</h2>

<p>Many of python-libtrace's classes have a <span style="font-style: italic;">new-instance</span> function, so you can
create a new object; this is most useful for handling encapsulated
packets.  These methods take a single argument, which may be an
existing object or a byte array.  In most cases the argument
will be something you have unpacked from an incoming package.  This
allows you to work on encapsulated packets, e.g.&nbsp;
</p>
<p style="font-family: Courier New,Courier,monospace;">
     &nbsp; for pkt in trace:<br /> &nbsp; &nbsp;&nbsp;&nbsp; trans = pkt.transport
<br /> &nbsp; &nbsp;&nbsp;&nbsp; if trans.proto != 41:  # IPv6 over IPv4<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue
<br /> &nbsp; &nbsp;&nbsp;&nbsp; ip6 = ip6.new(trans)<br />&nbsp; &nbsp; &nbsp;  ...  # Process the encapsulated IPv6 packet</p>
<p style="font-family: Courier New,Courier,monospace;"><br />

</p>


<table class="indent1">
<tbody>
<tr><td class="heading" colspan="2">Class Methods</td></tr>
<tr>
<td class="name methodwidth"><strong>ip()</strong><br />
</td>
<td class="name descriptionwidth"><em>ip(object or byte array) -&gt; anIP</em></td>
</tr><tr>
<td><br />
</td>
<td class="description vspace1">Makes a new IP (IPv4) object</td>
</tr>
<tr>
<td class="name methodwidth"><strong>ip6()</strong><br />
</td>
<td class="name descriptionwidth"><em>ip6bject or byte array) -&gt; anIP6</em></td></tr>
<tr>
<td><br />
</td>
<td class="description vspace1">Makes a new IP6 (IPv6)  object</td>
</tr>
<tr>
<td class="name methodwidth"><strong>tcp()</strong><br />
</td>
<td class="name descriptionwidth"><em>tcp(object or byte array) -&gt; aTCP</em></td>
</tr><tr>
<td><br />
</td>
<td class="description vspace1">Makes a new TCP object</td>
</tr>
<tr>
<td class="name methodwidth"><strong>udp()</strong><br />
</td>
<td class="name descriptionwidth"><em>udp(object or byte array) -&gt; aUDPP</em></td>
</tr><tr>
<td><br />
</td>
<td class="description vspace1">Makes a new UDP object</td>
</tr>
<tr>
<td class="name methodwidth"><strong>icmp()</strong><br />
</td>
<td class="name descriptionwidth"><em>icmp(object or byte array) -&gt; anICMP</em></td>
</tr><tr>
<td><br />
</td>
<td class="description vspace1">Makes a new ICMP object</td>
</tr>
<tr>
<td class="name methodwidth"><strong>icmp6()</strong><br />
</td>
<td class="name descriptionwidth"><em>icmp6(object or byte array) -&gt; anICMP</em></td>
</tr><tr>
<td><br />
</td>
<td class="description vspace1">Makes a new ICMPv6 object</td>
</tr>
</tbody></table>

<br />
<table>
</table><br />
Nevil Brownlee<br />Mon, 27 Jan 14 (NZDT)
</body></html>