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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
|
<!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>IPprefix</title>
<meta name="generator" content="amaya 8.5, see http://www.w3.org/Amaya/">
<link rel="stylesheet" type="text/css" href="plt-doc.css"></head>
<body>
<h2>IPprefix Module</h2>
<p>This Module (<big><span style="font-family: Courier New,Courier,monospace;">ipp</span></big>) provides methods to store and use IPv4 and IPv6
addresses.</p>
<p>When you use <span style="font-style: italic;">python-libtrace</span> (<span style="font-family: Courier New,Courier,monospace;">import plt</span>), IPprefix is
automatically <br>loaded - you don't need to import <big><span style="font-family: Courier New,Courier,monospace;">ipp</span> </big>as well.</p>
<h3>Class IPprefix</h3>
<p>Represents an IP adress or prefix.</p>
<table class="indent1">
<tbody>
<tr>
<td class="heading" colspan="2">Instance
Variables</td>
</tr>
<tr>
<td class="name methodwidth" valign="top">
<strong>version</strong>
</td>
<td class="name descriptionwidth">4 for IPv4, 6 for IPv6
</td>
</tr>
<tr>
<td class="name" valign="top">
<strong>addr</strong>
</td>
<td class="name">
4- or 16-byte array containing actual address; the array bytes contain the actual bytes of the
address
</td>
</tr>
<tr>
<td class="name" valign="top">
<span style="font-weight: bold;">length</span></td>
<td class="name">
Number of bits in prefix. If length is None the <span style="font-style: italic;">IPprefix</span> represents just
an IP address
</td>
</tr>
</tbody></table>
<br>
<table class="indent1"><tbody>
<tr>
<td class="heading" colspan="2">Class Methods</td>
</tr>
<tr>
<td class="name methodwidth"><strong>from_s()</strong></td>
<td class="name descriptionwidth"><em>ipp.from_s(aString)->
aNewIPprefix</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">
Parses str to find version and address, e.g.<br>
p = ipp.from_s('192.168.1.1') <br>
p = ipp.from_s('fe80::20d:60ff:fe38:18b/64')
</td>
</tr><tr>
<td class="name"><strong> </strong></td>
<td class="name descriptionwidth"><em><em>IPprefix -> aString</em></em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">
Returns a string containing a printable version of the
<span style="font-style: italic;">IPprefix'</span>s address (and /width, if width is not None)<br><span style="font-style: italic;">ipp will convert an IPprefix to a python string by calling its (built-in) str() function</span>
</td></tr>
</tbody></table>
<br>
<table class="indent1">
<tbody>
<tr>
<td class="heading" colspan="2">Instance Methods</td>
</tr>
<tr>
<td class="name methodwidth"><strong><, <=, ==, >=, >, !=<br>
</strong></td>
<td class="name descriptionwidth"><em>IPprefix op OtherIPprefix
-> True or False<br>
</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">'Rich compare' operators: comparisions use the versions, addresses and
lengths of two IPprefixes. These can be used to sort IPprefixes into
ascending or descending order, IPprefixes with the same addr compare
based on their lengths.</td>
</tr>
<tr>
<td class="name methodwidth"><strong>IPprefix(v, a)</strong><br>
</td>
<td class="name descriptionwidth"><em>IPprefix(version,address)
->
aNewIPprefix</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">
Returns an IPprefix conatining an IP address, e.g. 192.168.0.3<br>
version = 4 for
IPv4, 6 for IPv6<br>
address = 4- or 16-byte array containing<br>
actual address</td>
</tr>
<tr>
<td class="name"><strong>IPprefix(v, a, len)</strong></td>
<td class="name"><em>IPprefix(version,
address, length)
->
aNewIPprefix</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">Returns an IPprefix containing a network prefix, e.g.
192.168.0.0/16. <br>
version, address - as above<br>
length = number of bits in prefix</td>
</tr>
<tr>
<td class="name"><strong>version</strong></td>
<td class="name"><em>IPprefix.version ->
anIinteger</em></td>
</tr>
<tr>
<td class="name"><strong>addr</strong></td>
<td class="name"><em>IPprefix.addr ->
aString</em></td>
</tr>
<tr>
<td class="name" valign="top"><strong>length</strong></td>
<td class="name"><em>IPprefix.length->
anIinteger</em><br>
</td>
</tr>
<tr><td><br>
</td><td class="description">Read values of the instance variables.</td></tr>
<tr>
<td class="name"><strong>length=</strong></td>
<td class="name"><em>IPprefix.length = anInteger -> anIinteger</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">
Se<span>t</span>s value for an IPprefix width.<br>
</td>
</tr>
</tbody></table>
<br>
<table class="indent1"><tbody>
<tr><td class="heading" colspan="2">Instance Methods for prefix testing</td>
</tr>
<tr>
<td class="name methodwidth"><strong>is_prefix</strong></td>
<td class="name descriptionwidth"><em>IPprefix .is_prefix(OtherIPprefix)
-> True or False</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">Returns true if this <span style="font-style: italic;">IPprefix</span> is a prefix of <span style="font-style: italic;">OtherIPprefix</span>, i.e. their first <span style="font-style: italic;">IPprefix.length </span>bits are the same.<br></td>
</tr>
<tr>
<td class="name"><strong>equal</strong></td>
<td class="name"><em><em>IPprefix.equal(OtherIPprefix)
-> True or False </em></em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">Two IPprefixes are equal if they have the same <span style="font-weight: bold;">version and </span><span style="font-weight: bold;">addr. </span><span style="font-weight: bold;"><br>
</span></td>
</tr>
<tr>
<td class="name methodwidth"><strong>width</strong></td>
<td class="name descriptionwidth"><em>IPprefix.width
->
anInteger</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">Returns<span style="font-style: italic;"> IPprefix.length - 1</span><br></td>
</tr>
<tr>
<td class="name"><strong>has_bit_set</strong></td>
<td class="name"><em>IPprefix.has_bit_set(Integer) -> True or False</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">Returns true if the bit specified by <span style="font-style: italic;">Integer</span> is 1.<br>For example, if <span style="font-style: italic;">Integer</span> is 0, has_bit_set is true if the leftmost bit of <span style="font-style: italic;">IPprefix</span> is 1.</td>
</tr>
<tr>
<td class="name"><strong>first_bit_different</strong></td>
<td class="name"><em>IPprefix.first_bit_different(OtherIPprefix) -> anInteger</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">Returns an <span style="font-style: italic;">Integer</span>, the (0-origin) bit position where the two IPprefixes are different.<br></td>
</tr>
<tr>
<td class="name"><strong>complement</strong></td>
<td class="name"><em>IPprefix.complement -> OtherIPprefix</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">
Returns the complement of an <span style="font-style: italic;">IPprefix,</span> i.e. one having the same length, but all bits the ones-complement of those in <span style="font-style: italic;">IPprefix</span>.</td>
</tr>
<tr><td class="name"><strong>is_rfc1918</strong></td>
<td class="name"><em>IPprefix.is_rfc1918 -> True or False<br>
</em></td>
</tr>
<tr>
<td><br>
</td>
<td class="description">
Returns True if the IPprefix's address is in the IPv4 range specified in RFC 1918, i.e. in one of the Private prefixes below.<br>
</td>
</tr>
</tbody>
</table>
<br>
<table class="indent1">
<tbody>
<tr>
<td class="heading" colspan="3">Global
Constants</td>
</tr>
<tr>
<td class="name methodwidth"><em>'Private' prefixes<br>
</em></td>
<td class="name" colspan="2">See RFC 1918 for more details</td>
</tr>
<tr>
<td><br>
</td>
<td class="c2width">ipp.rfc1918s16</td>
<td class="c3width">192.168.0.0/16<br>
</td>
</tr>
<tr>
<td><br>
</td>
<td>ipp.rfc1918s12</td>
<td>172.16.0.0/12</td>
</tr>
<tr>
<td><br>
</td>
<td>ipp.rfc1918s8</td>
<td>10.0.0.0/8</td>
</tr>
</tbody>
</table>
<p>Nevil Brownlee<br>Tue, 4 Nov 14 (NZDT)</p></body></html>
|