Tk Library Source Code

View Ticket
Login
Ticket UUID: 1260174
Title: ip: various procs for ip package
Type: Patch Version: None
Submitter: aakhter Created on: 2005-08-15 19:21:26
Subsystem: A Category Is Missing Assigned To: andreas_kupries
Priority: 5 Medium Severity:
Status: Deleted Last Modified: 2005-08-16 02:31:13
Resolution: None Closed By: andreas_kupries
    Closed on: 2005-08-15 19:31:13
Description:
below is the current man page for the extension to the
ip package.

A review and changes to accomodate integration into the
tcllib ip package is requested.



ipExtension.tcl(l)                                    
     ipExtension.tcl(l)



NAMEE
       ::ipExtension:: - an extension to tcllib ip library

SSYYNNOOPPSSIISS
       package require ipExtension



AAUUTTHHOORRSS
       Aamer Akhter / [email protected]


SSUUPPPPOORRTT
       [email protected]


DDEESSCCRRIIPPTTIIOONN
       A detailed description of the functionality
provided by the library.


RREEQQUUIIRREEMMEENNTTSS
       package require logger
       package require ip



NNOOTTEESS
       1.



PPRROOCCEEDDUURREESS
       ::ip::prefixToNative




              convert from dotted from to native (hex) form




                     prefixToNative <prefix>



              Options:



                     <prefix>
                         string in the <ipaddr>/<mask>
format



              Return values:



                     <prefix> in native format {<hexip>
<hexmask>}



              Examples:



                     % ip::prefixToNative 1.1.1.0/24
                     0x01010100 0xffffff00




       ::ip::nativeToPrefix




              convert from native (hex) form to dotted form




                     nativeToPrefix <native>



              Options:



                     <native>
                         tcllist in format {<hexip>
<hexmask>}



              Return values:



                     <prefix> form of <native>, where
prefix is string in the <ipaddr>/<mask> format



              Examples:



                     % ip::nativeToPrefix {0x01010100
0xffffff00}
                     1.1.1.0/24




       ::ip::intToString




              convert from an integer/hex to dotted form




                     intToString <integer/hex>



              Options:



                     <integer>
                         ip address in integer form



              Return values:



                     ip address in dotted form



              Examples:



                     ip::intToString 4294967295
                     255.255.255.255




       ::ip::ToInteger




              convert dotted form ip to integer




                     ToInteger <ipaddr>



              Options:



                     <ipaddr>
                         decimal dotted from ip address



              Return values:



                     integer form of <ipaddr>



              Examples:



                     % ::ip::ToInteger 1.1.1.0
                     16843008




       ::ip::ToHex




              convert dotted form ip to hex




                     ToHex <ipaddr>



              Options:



                     <ipaddr>
                         decimal dotted from ip address



              Return values:



                     hex form of <ipaddr>



              Examples:



                     % ::ip::ToHex 1.1.1.0
                     0x01010100




       ::ip::MaskToInt




              convert mask to integer




                     MaskToInt <mask>



              Options:



                     <mask>
                         mask in either dotted form or
mask length form (255.255.255.0 or 24)



              Return values:



                     integer form of mask



              Examples:



                     ::ip::MaskToInt 24
                     4294967040




       ::ip::broadcastAddress




              return broadcast address given prefix




                     broadcastAddress <prefix>



              Options:



                     <prefix>
                         route in the form of
<ipaddr>/<mask> or native form {<hexip> <hexmask>}



              Return values:



                     ipaddress of broadcast



              Examples:



                     ::ip::broadcastAddress 1.1.1.0/24
                     1.1.1.255

                     ::ip::broadcastAddress {0x01010100
0xffffff00}
                     0x010101ff




       ::ip::MaskToLength




              converts dotted or integer form of mask
to length




                     MaskToLength
<dottedMask>|<integerMask>|<hexMask>



              Options:



                     <dottedMask>
                     <integerMask>
                     <hexMask>
                         mask to convert to prefix
length format (eg /24)



              Return values:



                     prefix length



              Examples:



                     ::ip::MaskToLength 0xffffff00
                     24

                     % ::ip::MaskToLength 255.255.255.0
                     24




       ::ip::LengthToMask




              converts mask length to dotted mask form




                     LengthToMask <maskLength>



              Options:



                     <maskLength>
                         mask length



              Return values:



                     mask in dotted form



              Examples:



                     ::ip::LengthToMask 24
                     255.255.255.0




       ::ip::nextNet




              returns next an ipaddress in same
position in next network




                     nextNet <ipaddr> <mask> [<count>]



              Options:



                     <ipaddress>
                         in hex/integer/dotted format
                     <mask>
                         mask in
hex/integer/dotted/maskLen format
                     <count>
                         number of nets to skip over
(default is 1)



              Return values:



                     ipaddress in same position in next
network in hex




       ::ip::isOverlap




              checks to see if prefixes overlap




                     isOverlap <prefix> <prefix1>
<prefix2>...



              Options:



                     <prefix>
                         in form <ipaddr>/<mask> prefix
to compare <prefixN> against
                     <prefixN>
                         in form <ipaddr>/<mask>
prefixes to compare against



              Return values:



                     1 if there is an overlap



              Examples:



                     % ::ip::isOverlap 1.1.1.0/24
2.1.0.1/32
                     0

                     ::ip::isOverlap 1.1.1.0/24
2.1.0.1/32 1.1.1.1/32
                     1




       ::ip::isOverlapNative




              checks to see if prefixes overlap
(optimized native form)




                     isOverlap <hexipaddr> <hexmask>
{{<hexipaddr1> <hexmask1>} {<hexipaddr2> <hexmask2>...}



              Options:



                     -all
                         return all overlaps rather
than the first one
                     -inline
                         rather than returning index
values, return the actual overlap prefixes
                     <hexipaddr>
                         ipaddress in hex/integer form
                     <hexMask>
                         mask in hex/integer form



              isOverlapNative is avaliabel both as a C
extension and in a native tcl form
              if the extension is loaded (tried
automatically), isOverlapNative will be
              linked to isOverlapNativeC. If an
extension is not loaded, then isOverlapNative
              will be linked to the native tcl proc:
ipOverlapNativeTcl.

              Return values:



                     non-zero if there is an overlap,
value is element # in list with overlap



              Examples:



                     % ::ip::isOverlapNative 0x01010100
0xffffff00 {{0x02010001 0xffffffff}}
                     0

                     %::ip::isOverlapNative 0x01010100
0xffffff00 {{0x02010001 0xffffffff} {0x01010101
0xffffffff}}
                     2




       ::ip::IpToLayer2Multicast




              converts ipv4 address to a layer 2
multicast address




                     IpToLayer2Multicast <ipaddr>



              Options:



                     <ipaddr>
                         ipaddress in dotted form



              Return values:



                     mac address in xx.xx.xx.xx.xx.xx form



              Examples:



                     % ::ip::IpToLayer2Multicast 224.0.0.2
                     01.00.5e.00.00.02




       ::ip::IpHostFromPrefix




              gives back a host address from a prefix




                     ::ip::IpHostFromPrefix <ipprefix>
[-exclude <list of prefixes>]



              Options:



                     <ipprefix>
                         prefix is <ipaddr>/<masklen>
                     -exclude <list of ipprefixes>
                         list if ipprefixes that host
should not be in



              Return values:



                     ip address



              Examples:



                     %::ip::IpHostFromPrefix  1.1.1.5/24
                     1.1.1.1

                     %::ip::IpHostFromPrefix  1.1.1.1/32
                     1.1.1.1




       ::ip::reduceToAggregates




              finds nets that overlap and filters out
the more specifc nets




                     ::ip::reduceToAggregates <list of
ipprefixes>



              Options:



                     <ipprefix>
                         prefix is <ipaddr>/<masklen>
or native format



              Return values:



                     non-overlapping ip prefixes



              Examples:




                       % ::ip::reduceToAggregates
{1.1.1.0/24 1.1.0.0/8  2.1.1.0/24 1.1.1.1/32 }
                       1.0.0.0/8 2.1.1.0/24




       ::ip::longestPrefixMatch




              given host IP finds longest prefix match
from set of prefixes




                     ::ip::longestPrefixMatch <ipaddr>
<list of ipprefixes>



              Options:



                     <ipprefix>
                         prefix is <ipaddr>/<masklen>
or native format
                     <ipaddr>
                         ip address in <ipprefix>
format, dotted form, or integer form



              Return values:



                     <ipprefix> that is the most
specific match to <ipaddr>



              Examples:



                     % ::ip::longestPrefixMatch 1.1.1.1
{1.1.1.0/24 1.0.0.0/8  2.1.1.0/24 1.1.1.0/28 }
                     1.1.1.0/28




       ::ip::cmpDotIP




              helper function for dotted ip address for
use in lsort




                     ::ip::cmpDotIP <ipaddr1> <ipaddr2>



              Options:



                     <ipaddr1> <ipaddr2>
                         prefix is in dotted ip address
format



              Return values:



                     -1 if ipaddr1 is less that ipaddr2
                      1 if ipaddr1 is more that ipaddr2
                      0 if ipaddr1 and ipaddr2 are equal



              Examples:



                     % lsort -command ip::cmpDotIP
{1.0.0.0 2.2.0.0 128.0.0.0 3.3.3.3}
                     1.0.0.0 2.2.0.0 3.3.3.3 128.0.0.0








ATS                                  Cisco            
     ipExtension.tcl(l)
User Comments: andreas_kupries added on 2005-08-16 02:30:31:
Logged In: YES 
user_id=75003

Aamer,

I have to delete this entry. The inlined manpage is
unreadable (*) in both the HTML and in the notification
mails generated by SF. And the latter has the additional
problem of causing SF to mail _very large_ mails around, as
it duplicates the whole comment thread, including your large
initial manpage.

Please refile this report, and attach not only
ipExtension.tar.gz, but also the manpage.

(*) I am not sure what format the manpage is in, but it is
not a plain text format. Possibly *roff output ? If so,
attaching the file is again the right thing to do.

aakhter added on 2005-08-16 02:21:28:

File Added - 145749: ipExtension.tar.gz

Attachments: