This file is indexed.

/usr/share/doc/libghc-iproute-doc/html/iproute.txt is in libghc-iproute-doc 1.7.1-2build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | IP Routing Table
--   
--   IP Routing Table is a tree of IP ranges to search one of them on the
--   longest match base. It is a kind of TRIE with one way branching
--   removed. Both IPv4 and IPv6 are supported.
@package iproute
@version 1.7.1

module Data.IP.Internal

-- | The abstract data type to express an IPv4 address. To create this, use
--   <a>toIPv4</a>. Or use <a>read</a> <tt>"192.0.2.1"</tt> :: <a>IPv4</a>,
--   for example. Also, <tt>"192.0.2.1"</tt> can be used as literal with
--   OverloadedStrings.
--   
--   <pre>
--   &gt;&gt;&gt; read "192.0.2.1" :: IPv4
--   192.0.2.1
--   </pre>
newtype IPv4
IP4 :: IPv4Addr -> IPv4

-- | The abstract data type to express an IPv6 address. To create this, use
--   <a>toIPv6</a>. Or use <a>read</a> <tt>"2001:DB8::1"</tt> ::
--   <a>IPv6</a>, for example. Also, <tt>"2001:DB8::1"</tt> can be used as
--   literal with OverloadedStrings.
--   
--   <pre>
--   &gt;&gt;&gt; read "2001:db8:00:00:00:00:00:01" :: IPv6
--   2001:db8::1
--   
--   &gt;&gt;&gt; read "2001:db8:11e:c00::101" :: IPv6
--   2001:db8:11e:c00::101
--   
--   &gt;&gt;&gt; read "2001:db8:11e:c00:aa:bb:192.0.2.1" :: IPv6
--   2001:db8:11e:c00:aa:bb:c000:201
--   
--   &gt;&gt;&gt; read "2001:db8::192.0.2.1" :: IPv6
--   2001:db8::c000:201
--   
--   &gt;&gt;&gt; read "0::ffff:192.0.2.1" :: IPv6
--   ::ffff:192.0.2.1
--   
--   &gt;&gt;&gt; read "0::0:c000:201" :: IPv6
--   ::192.0.2.1
--   
--   &gt;&gt;&gt; read "::0.0.0.1" :: IPv6
--   ::1
--   </pre>
newtype IPv6
IP6 :: IPv6Addr -> IPv6

-- | The Addr range consists of an address, a contiguous mask, and mask
--   length. The contiguous mask and the mask length are essentially same
--   information but contained for pre calculation.
--   
--   To create this, use <tt>makeAddrRange</tt> or <a>read</a>
--   <tt>"192.0.2.0/24"</tt> :: <a>AddrRange</a> <a>IPv4</a>. Also,
--   <tt>"192.0.2.0/24"</tt> can be used as literal with OverloadedStrings.
--   
--   <pre>
--   &gt;&gt;&gt; read "192.0.2.1/24" :: AddrRange IPv4
--   192.0.2.0/24
--   
--   &gt;&gt;&gt; read "2001:db8:00:00:00:00:00:01/48" :: AddrRange IPv6
--   2001:db8::/48
--   </pre>
data AddrRange a
AddrRange :: !a -> !a -> {-# UNPACK #-} !Int -> AddrRange a

-- | The <a>addr</a> function returns an address from <a>AddrRange</a>.
[addr] :: AddrRange a -> !a

-- | The <a>mask</a> function returns a contiguous <a>IP</a> mask from
--   <a>AddrRange</a>.
[mask] :: AddrRange a -> !a

-- | The <a>mlen</a> function returns a mask length from <a>AddrRange</a>.
[mlen] :: AddrRange a -> {-# UNPACK #-} !Int


-- | IP routing table is a tree of <tt>IPRange</tt> to search one of them
--   on the longest match base. It is a kind of TRIE with one way branching
--   removed. Both IPv4 and IPv6 are supported.
--   
--   For more information, see:
--   <a>http://www.mew.org/~kazu/proj/iproute/</a>
module Data.IP.RouteTable

-- | A class to contain IPv4 and IPv6.
class Addr a => Routable a

-- | The <a>intToTBit</a> function takes <a>Int</a> and returns an
--   <a>Routable</a> address whose only n-th bit is set.
intToTBit :: Routable a => Int -> a

-- | The <a>isZero</a> function takes an <a>Routable</a> address and an
--   test bit <a>Routable</a> address and returns <a>True</a> is the bit is
--   unset, otherwise returns <a>False</a>.
isZero :: Routable a => a -> a -> Bool

-- | The Tree structure for IP routing table based on TRIE with one way
--   branching removed. This is an abstract data type, so you cannot touch
--   its inside. Please use <a>insert</a> or <a>lookup</a>, instead.
data IPRTable k a

-- | The <a>empty</a> function returns an empty IP routing table.
--   
--   <pre>
--   &gt;&gt;&gt; (empty :: IPRTable IPv4 ()) == fromList []
--   True
--   </pre>
empty :: Routable k => IPRTable k a

-- | The <a>insert</a> function inserts a value with a key of
--   <a>AddrRange</a> to <a>IPRTable</a> and returns a new <a>IPRTable</a>.
--   
--   <pre>
--   &gt;&gt;&gt; (insert ("127.0.0.1" :: AddrRange IPv4) () empty) == fromList [("127.0.0.1",())]
--   True
--   </pre>
insert :: (Routable k) => AddrRange k -> a -> IPRTable k a -> IPRTable k a

-- | The <a>delete</a> function deletes a value by a key of
--   <a>AddrRange</a> from <a>IPRTable</a> and returns a new
--   <a>IPRTable</a>.
--   
--   <pre>
--   &gt;&gt;&gt; delete "127.0.0.1" (insert "127.0.0.1" () empty) == (empty :: IPRTable IPv4 ())
--   True
--   </pre>
delete :: (Routable k) => AddrRange k -> IPRTable k a -> IPRTable k a

-- | The <a>lookup</a> function looks up <a>IPRTable</a> with a key of
--   <a>AddrRange</a>. If a routing information in <a>IPRTable</a> matches
--   the key, its value is returned.
--   
--   <pre>
--   &gt;&gt;&gt; let v4 = ["133.4.0.0/16","133.5.0.0/16","133.5.16.0/24","133.5.23.0/24"] :: [AddrRange IPv4]
--   
--   &gt;&gt;&gt; let rt = fromList $ zip v4 v4
--   
--   &gt;&gt;&gt; lookup "127.0.0.1" rt
--   Nothing
--   
--   &gt;&gt;&gt; lookup "133.3.0.1" rt
--   Nothing
--   
--   &gt;&gt;&gt; lookup "133.4.0.0" rt
--   Just 133.4.0.0/16
--   
--   &gt;&gt;&gt; lookup "133.4.0.1" rt
--   Just 133.4.0.0/16
--   
--   &gt;&gt;&gt; lookup "133.5.16.0" rt
--   Just 133.5.16.0/24
--   
--   &gt;&gt;&gt; lookup "133.5.16.1" rt
--   Just 133.5.16.0/24
--   </pre>
lookup :: Routable k => AddrRange k -> IPRTable k a -> Maybe a

-- | The <a>findMatch</a> function looks up <a>IPRTable</a> with a key of
--   <a>AddrRange</a>. If the key matches routing informations in
--   <a>IPRTable</a>, they are returned.
--   
--   <pre>
--   &gt;&gt;&gt; let v4 = ["133.4.0.0/16","133.5.0.0/16","133.5.16.0/24","133.5.23.0/24"] :: [AddrRange IPv4]
--   
--   &gt;&gt;&gt; let rt = fromList $ zip v4 $ repeat ()
--   
--   &gt;&gt;&gt; findMatch "133.4.0.0/15" rt :: [(AddrRange IPv4,())]
--   [(133.4.0.0/16,()),(133.5.0.0/16,()),(133.5.16.0/24,()),(133.5.23.0/24,())]
--   </pre>
findMatch :: MonadPlus m => Routable k => AddrRange k -> IPRTable k a -> m (AddrRange k, a)

-- | The <a>fromList</a> function creates a new IP routing table from a
--   list of a pair of <tt>IPrange</tt> and value.
fromList :: Routable k => [(AddrRange k, a)] -> IPRTable k a

-- | The <a>toList</a> function creates a list of a pair of
--   <a>AddrRange</a> and value from an IP routing table.
toList :: Routable k => IPRTable k a -> [(AddrRange k, a)]


-- | Data structures to express IPv4, IPv6 and IP range.
module Data.IP

-- | A unified IP data for <a>IPv4</a> and <a>IPv6</a>. To create this, use
--   the data constructors. Or use <a>read</a> <tt>"192.0.2.1"</tt> ::
--   <a>IP</a>, for example. Also, <tt>"192.0.2.1"</tt> can be used as
--   literal with OverloadedStrings.
--   
--   <pre>
--   &gt;&gt;&gt; (read "192.0.2.1" :: IP) == IPv4 (read "192.0.2.1" :: IPv4)
--   True
--   
--   &gt;&gt;&gt; (read "2001:db8:00:00:00:00:00:01" :: IP) == IPv6 (read "2001:db8:00:00:00:00:00:01" :: IPv6)
--   True
--   </pre>
data IP
IPv4 :: IPv4 -> IP
[ipv4] :: IP -> IPv4
IPv6 :: IPv6 -> IP
[ipv6] :: IP -> IPv6

-- | The abstract data type to express an IPv4 address. To create this, use
--   <a>toIPv4</a>. Or use <a>read</a> <tt>"192.0.2.1"</tt> :: <a>IPv4</a>,
--   for example. Also, <tt>"192.0.2.1"</tt> can be used as literal with
--   OverloadedStrings.
--   
--   <pre>
--   &gt;&gt;&gt; read "192.0.2.1" :: IPv4
--   192.0.2.1
--   </pre>
data IPv4

-- | The <a>toIPv4</a> function takes a list of <a>Int</a> and returns
--   <a>IPv4</a>.
--   
--   <pre>
--   &gt;&gt;&gt; toIPv4 [192,0,2,1]
--   192.0.2.1
--   </pre>
toIPv4 :: [Int] -> IPv4

-- | The <a>fromIPv4</a> function converts <a>IPv4</a> to a list of
--   <a>Int</a>.
--   
--   <pre>
--   &gt;&gt;&gt; fromIPv4 (toIPv4 [192,0,2,1])
--   [192,0,2,1]
--   </pre>
fromIPv4 :: IPv4 -> [Int]

-- | The <a>fromHostAddress</a> function converts <a>HostAddress</a> to
--   <a>IPv4</a>.
fromHostAddress :: HostAddress -> IPv4

-- | The <a>toHostAddress</a> function converts <a>IPv4</a> to
--   <a>HostAddress</a>.
toHostAddress :: IPv4 -> HostAddress

-- | The abstract data type to express an IPv6 address. To create this, use
--   <a>toIPv6</a>. Or use <a>read</a> <tt>"2001:DB8::1"</tt> ::
--   <a>IPv6</a>, for example. Also, <tt>"2001:DB8::1"</tt> can be used as
--   literal with OverloadedStrings.
--   
--   <pre>
--   &gt;&gt;&gt; read "2001:db8:00:00:00:00:00:01" :: IPv6
--   2001:db8::1
--   
--   &gt;&gt;&gt; read "2001:db8:11e:c00::101" :: IPv6
--   2001:db8:11e:c00::101
--   
--   &gt;&gt;&gt; read "2001:db8:11e:c00:aa:bb:192.0.2.1" :: IPv6
--   2001:db8:11e:c00:aa:bb:c000:201
--   
--   &gt;&gt;&gt; read "2001:db8::192.0.2.1" :: IPv6
--   2001:db8::c000:201
--   
--   &gt;&gt;&gt; read "0::ffff:192.0.2.1" :: IPv6
--   ::ffff:192.0.2.1
--   
--   &gt;&gt;&gt; read "0::0:c000:201" :: IPv6
--   ::192.0.2.1
--   
--   &gt;&gt;&gt; read "::0.0.0.1" :: IPv6
--   ::1
--   </pre>
data IPv6

-- | The <a>toIPv6</a> function takes a list of <a>Int</a> and returns
--   <a>IPv6</a>.
--   
--   <pre>
--   &gt;&gt;&gt; toIPv6 [0x2001,0xDB8,0,0,0,0,0,1]
--   2001:db8::1
--   </pre>
toIPv6 :: [Int] -> IPv6

-- | The <a>toIPv6b</a> function takes a list of <a>Int</a> where each
--   member repserents a single byte and returns <a>IPv6</a>.
--   
--   <pre>
--   &gt;&gt;&gt; toIPv6b [0x20,0x01,0xD,0xB8,0,0,0,0,0,0,0,0,0,0,0,1]
--   2001:db8::1
--   </pre>
toIPv6b :: [Int] -> IPv6

-- | The <a>toIPv6</a> function converts <a>IPv6</a> to a list of
--   <a>Int</a>.
--   
--   <pre>
--   &gt;&gt;&gt; fromIPv6 (toIPv6 [0x2001,0xDB8,0,0,0,0,0,1])
--   [8193,3512,0,0,0,0,0,1]
--   </pre>
fromIPv6 :: IPv6 -> [Int]

-- | The <a>fromIPv6b</a> function converts <a>IPv6</a> to a list of
--   <a>Int</a> where each member represents a single byte.
--   
--   <pre>
--   &gt;&gt;&gt; fromIPv6b (toIPv6b [0x20,0x01,0xD,0xB8,0,0,0,0,0,0,0,0,0,0,0,1])
--   [32,1,13,184,0,0,0,0,0,0,0,0,0,0,0,1]
--   </pre>
fromIPv6b :: IPv6 -> [Int]

-- | The <a>fromHostAddress6</a> function converts <a>HostAddress6</a> to
--   <a>IPv6</a>.
fromHostAddress6 :: HostAddress6 -> IPv6

-- | The <a>toHostAddress6</a> function converts <a>IPv6</a> to
--   <a>HostAddress6</a>.
toHostAddress6 :: IPv6 -> HostAddress6

-- | A unified data for <a>AddrRange</a> <a>IPv4</a> and <a>AddrRange</a>
--   <a>IPv6</a>. To create this, use <a>read</a> <tt>"192.0.2.0/24"</tt>
--   :: <a>IPRange</a>. Also, <tt>"192.0.2.0/24"</tt> can be used as
--   literal with OverloadedStrings.
--   
--   <pre>
--   &gt;&gt;&gt; (read "192.0.2.1/24" :: IPRange) == IPv4Range (read "192.0.2.0/24" :: AddrRange IPv4)
--   True
--   
--   &gt;&gt;&gt; (read "2001:db8:00:00:00:00:00:01/48" :: IPRange) == IPv6Range (read "2001:db8:00:00:00:00:00:01/48" :: AddrRange IPv6)
--   True
--   </pre>
data IPRange
IPv4Range :: AddrRange IPv4 -> IPRange
[ipv4range] :: IPRange -> AddrRange IPv4
IPv6Range :: AddrRange IPv6 -> IPRange
[ipv6range] :: IPRange -> AddrRange IPv6

-- | The Addr range consists of an address, a contiguous mask, and mask
--   length. The contiguous mask and the mask length are essentially same
--   information but contained for pre calculation.
--   
--   To create this, use <tt>makeAddrRange</tt> or <a>read</a>
--   <tt>"192.0.2.0/24"</tt> :: <a>AddrRange</a> <a>IPv4</a>. Also,
--   <tt>"192.0.2.0/24"</tt> can be used as literal with OverloadedStrings.
--   
--   <pre>
--   &gt;&gt;&gt; read "192.0.2.1/24" :: AddrRange IPv4
--   192.0.2.0/24
--   
--   &gt;&gt;&gt; read "2001:db8:00:00:00:00:00:01/48" :: AddrRange IPv6
--   2001:db8::/48
--   </pre>
data AddrRange a

-- | <pre>
--   &gt;&gt;&gt; toIPv4 [127,0,2,1] `masked` intToMask 7
--   126.0.0.0
--   </pre>
class Eq a => Addr a

-- | The <a>masked</a> function takes an <a>Addr</a> and a contiguous mask
--   and returned a masked <a>Addr</a>.
masked :: Addr a => a -> a -> a

-- | The <a>intToMask</a> function takes an <a>Int</a> representing the
--   number of bits to be set in the returned contiguous mask. When this
--   integer is positive the bits will be starting from the MSB and from
--   the LSB otherwise.
--   
--   <pre>
--   &gt;&gt;&gt; intToMask 16 :: IPv4
--   255.255.0.0
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; intToMask (-16) :: IPv4
--   0.0.255.255
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; intToMask 16 :: IPv6
--   ffff::
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; intToMask (-16) :: IPv6
--   ::ffff
--   </pre>
intToMask :: Addr a => Int -> a

-- | The <a>makeAddrRange</a> functions takes an <a>Addr</a> address and a
--   mask length. It creates a bit mask from the mask length and masks the
--   <a>Addr</a> address, then returns <a>AddrRange</a> made of them.
--   
--   <pre>
--   &gt;&gt;&gt; makeAddrRange (toIPv4 [127,0,2,1]) 8
--   127.0.0.0/8
--   
--   &gt;&gt;&gt; makeAddrRange (toIPv6 [0x2001,0xDB8,0,0,0,0,0,1]) 8
--   2000::/8
--   </pre>
makeAddrRange :: Addr a => a -> Int -> AddrRange a

-- | The &gt;:&gt; operator takes two <a>AddrRange</a>. It returns
--   <a>True</a> if the first <a>AddrRange</a> contains the second
--   <a>AddrRange</a>. Otherwise, it returns <a>False</a>.
--   
--   <pre>
--   &gt;&gt;&gt; makeAddrRange ("127.0.2.1" :: IPv4) 8 &gt;:&gt; makeAddrRange "127.0.2.1" 24
--   True
--   
--   &gt;&gt;&gt; makeAddrRange ("127.0.2.1" :: IPv4) 24 &gt;:&gt; makeAddrRange "127.0.2.1" 8
--   False
--   
--   &gt;&gt;&gt; makeAddrRange ("2001:DB8::1" :: IPv6) 16 &gt;:&gt; makeAddrRange "2001:DB8::1" 32
--   True
--   
--   &gt;&gt;&gt; makeAddrRange ("2001:DB8::1" :: IPv6) 32 &gt;:&gt; makeAddrRange "2001:DB8::1" 16
--   False
--   </pre>
(>:>) :: Addr a => AddrRange a -> AddrRange a -> Bool

-- | The <tt>toMatchedTo</tt> function take an <a>Addr</a> address and an
--   <a>AddrRange</a>, and returns <a>True</a> if the range contains the
--   address.
--   
--   <pre>
--   &gt;&gt;&gt; ("127.0.2.0" :: IPv4) `isMatchedTo` makeAddrRange "127.0.2.1" 24
--   True
--   
--   &gt;&gt;&gt; ("127.0.2.0" :: IPv4) `isMatchedTo` makeAddrRange "127.0.2.1" 32
--   False
--   
--   &gt;&gt;&gt; ("2001:DB8::1" :: IPv6) `isMatchedTo` makeAddrRange "2001:DB8::1" 32
--   True
--   
--   &gt;&gt;&gt; ("2001:DB8::" :: IPv6) `isMatchedTo` makeAddrRange "2001:DB8::1" 128
--   False
--   </pre>
isMatchedTo :: Addr a => a -> AddrRange a -> Bool

-- | The <tt>unmakeAddrRange</tt> functions take a <a>AddrRange</a> and
--   returns the network address and a mask length.
--   
--   <pre>
--   &gt;&gt;&gt; addrRangePair ("127.0.0.0/8" :: AddrRange IPv4)
--   (127.0.0.0,8)
--   
--   &gt;&gt;&gt; addrRangePair ("2000::/8" :: AddrRange IPv6)
--   (2000::,8)
--   </pre>
addrRangePair :: Addr a => AddrRange a -> (a, Int)

-- | Convert IPv4 range to IPV4-embedded-in-IPV6 range
ipv4RangeToIPv6 :: AddrRange IPv4 -> AddrRange IPv6

-- | Convert IPv4 address to IPv4-embedded-in-IPv6
ipv4ToIPv6 :: IPv4 -> IPv6