Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | ip - Ticket [510c9fce1b] - Added distance and nextIp commands provided by Martin Heinrich. Extended testsuite, docs. Version bumped to 1.3. |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
e2be9b2f8695397ba73efacb650f2b90 |
User & Date: | andreask 2015-04-15 20:59:43 |
Context
2015-04-15
| ||
21:10 | Refreshed the embedded docs. check-in: 4545293d4f user: aku tags: trunk | |
20:59 | ip - Ticket [510c9fce1b] - Added distance and nextIp commands provided by Martin Heinrich. Extended testsuite, docs. Version bumped to 1.3. check-in: e2be9b2f86 user: andreask tags: trunk | |
19:48 | uri - Ticket [c315712173] - Fixed handling of scheme-relative urls which have an authority (network-path). New test cases. Version bumped to 1.2.5. check-in: a29e0299a8 user: andreask tags: trunk | |
Changes
Changes to modules/dns/ip.tcl.
︙ | ︙ | |||
541 542 543 544 545 546 547 | # ------------------------------------------------------------------------- # Load extended command set. source [file join [file dirname [info script]] ipMore.tcl] # ------------------------------------------------------------------------- | | | 541 542 543 544 545 546 547 548 549 550 551 552 553 | # ------------------------------------------------------------------------- # Load extended command set. source [file join [file dirname [info script]] ipMore.tcl] # ------------------------------------------------------------------------- package provide ip 1.3 # ------------------------------------------------------------------------- # Local Variables: # indent-tabs-mode: nil # End: |
Changes to modules/dns/ipMore.tcl.
︙ | ︙ | |||
83 84 85 86 87 88 89 | set list [concat [lrange $list 0 [expr $index - 1]] \ [lrange $list [expr $index +1] end]]; return $top; } } # Some additional aliases for backward compatability. Not | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | set list [concat [lrange $list 0 [expr $index - 1]] \ [lrange $list [expr $index +1] end]]; return $top; } } # Some additional aliases for backward compatability. Not # documented. The old names are from previous versions while at Cisco. # # Old command name --> Documented command name interp alias {} ::ip::ToInteger {} ::ip::toInteger interp alias {} ::ip::ToHex {} ::ip::toHex interp alias {} ::ip::MaskToInt {} ::ip::maskToInt interp alias {} ::ip::MaskToLength {} ::ip::maskToLength interp alias {} ::ip::LengthToMask {} ::ip::lengthToMask |
︙ | ︙ | |||
285 286 287 288 289 290 291 | # convert dotted form ip to integer # # Synopsis: # toInteger <ipaddr> # # Arguments: # <ipaddr> | | | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | # convert dotted form ip to integer # # Synopsis: # toInteger <ipaddr> # # Arguments: # <ipaddr> # decimal dotted form ip address # # Return Values: # integer form of <ipaddr> # # Description: # # Examples: |
︙ | ︙ | |||
308 309 310 311 312 313 314 | # # See Also: # # End of Header proc ::ip::toInteger {ip} { binary scan [ip::Normalize4 $ip] I out | | | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | # # See Also: # # End of Header proc ::ip::toInteger {ip} { binary scan [ip::Normalize4 $ip] I out return [format %lu [expr {$out & 0xffffffff}]] } ##Procedure Header # Copyright (c) 2004 Cisco Systems, Inc. # # Name: # ::ip::toHex |
︙ | ︙ | |||
1210 1211 1212 1213 1214 1215 1216 | variable x for {set x 0} {$x <33} {incr x} { set maskLenToDotted($x) [intToString [maskToInt $x]] } unset x } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 | variable x for {set x 0} {$x <33} {incr x} { set maskLenToDotted($x) [intToString [maskToInt $x]] } unset x } ##Procedure Header # Copyright (c) 2015 Martin Heinrich <[email protected]> # # Name: # ::ip::distance # # Purpose: # Calculate integer distance between two IPv4 addresses (dotted form or int) # # Synopsis: # distance <ipaddr1> <ipaddr2> # # Arguments: # <ipaddr1> # <ipaddr2> # ip address # # Return Values: # integer distance (addr2 - addr1) # # Description: # # Examples: # % ::ip::distance 1.1.1.0 1.1.1.5 # 5 # # Sample Input: # # Sample Output: proc ::ip::distance {ip1 ip2} { # use package ip for normalization # XXX does not support ipv6 expr {[toInteger $ip2]-[toInteger $ip1]} } ##Procedure Header # Copyright (c) 2015 Martin Heinrich <[email protected]> # # Name: # ::ip::nextIp # # Purpose: # Increment the given IPv4 address by an offset. # Complement to 'distance'. # # Synopsis: # nextIp <ipaddr> ?<offset>? # # Arguments: # <ipaddr> # ip address # # <offset> # The integer to increment the address by. # Default is 1. # # Return Values: # The increment ip address. # # Description: # # Examples: # % ::ip::nextIp 1.1.1.0 5 # 1.1.1.5 # # Sample Input: # # Sample Output: proc ::ip::nextIp {ip {offset 1}} { set int [toInteger $ip] incr int $offset set prot {} # TODO if ipv4 then set prot -ipv4, but # XXX intToString has -ipv4, but never returns ipv6 intToString $int ;# 8.5-ism, avoid: {*}$prot } |
Changes to modules/dns/ipMore.test.
︙ | ︙ | |||
719 720 721 722 723 724 725 726 727 728 729 730 731 732 | } -constraints { } -cleanup { unset iplist } -body { set a [lsort -command ip::cmpDotIP $iplist] } -result {1.0.0.0 2.2.0.0 3.3.3.3 128.0.0.0} } namespace delete ::ip::test testsuiteCleanup # | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 | } -constraints { } -cleanup { unset iplist } -body { set a [lsort -command ip::cmpDotIP $iplist] } -result {1.0.0.0 2.2.0.0 3.3.3.3 128.0.0.0} ::tcltest::test ip::distance-1 {basic distance} -setup { } -constraints { } -cleanup { } -body { ::ip::distance 1.1.1.0 1.1.1.5 } -result 5 ::tcltest::test ip::distance-2 {distance, not enough args} -setup { } -constraints { } -cleanup { } -body { ::ip::distance } -returnCodes error -result {wrong # args: should be "::ip::distance ip1 ip2"} ::tcltest::test ip::distance-3 {distance, too many args} -setup { } -constraints { } -cleanup { } -body { ::ip::distance 1.1.1.1 1.1.1.5 1.1.1.19 } -returnCodes error -result {wrong # args: should be "::ip::distance ip1 ip2"} ::tcltest::test ip::nextIp-1 {basic nextIp} -setup { } -constraints { } -cleanup { } -body { ::ip::nextIp 1.1.1.0 5 } -result 1.1.1.5 ::tcltest::test ip::nextIp-2 {nextIp, not enough args} -setup { } -constraints { } -cleanup { } -body { ::ip::nextIp } -returnCodes error -result {wrong # args: should be "::ip::nextIp ip ?offset?"} ::tcltest::test ip::nextIp-3 {nextIp, too many args} -setup { } -constraints { } -cleanup { } -body { ::ip::nextIp 1.1.1.1 1.1.1.5 1.1.1.19 } -returnCodes error -result {wrong # args: should be "::ip::nextIp ip ?offset?"} foreach {n delta ip1 ip2} { 0 4294967295 0.0.0.0 255.255.255.255 1 -4294967295 255.255.255.255 0.0.0.0 2 7709 10.11.12.13 10.11.42.42 3 -7709 10.11.42.42 10.11.12.13 4 1994195353 54.229.115.42 173.194.116.195 5 -1994195353 173.194.116.195 54.229.115.42 } { ::tcltest::test ip::distance-4.$n {basic distance} -setup { } -constraints { } -cleanup { } -body { ::ip::distance $ip1 $ip2 } -result $delta ::tcltest::test ip::nextIp-4.$n {basic nextIp} -setup { } -constraints { } -cleanup { } -body { ::ip::nextIp $ip1 $delta } -result $ip2 } } namespace delete ::ip::test testsuiteCleanup # |
︙ | ︙ |
Changes to modules/dns/pkgIndex.tcl.
1 2 3 4 5 6 7 | # pkgIndex.tcl - # # $Id: pkgIndex.tcl,v 1.21 2010/08/16 17:35:18 andreas_kupries Exp $ if {![package vsatisfies [package provide Tcl] 8.2]} {return} package ifneeded dns 1.3.5 [list source [file join $dir dns.tcl]] package ifneeded resolv 1.0.3 [list source [file join $dir resolv.tcl]] | | | 1 2 3 4 5 6 7 8 9 | # pkgIndex.tcl - # # $Id: pkgIndex.tcl,v 1.21 2010/08/16 17:35:18 andreas_kupries Exp $ if {![package vsatisfies [package provide Tcl] 8.2]} {return} package ifneeded dns 1.3.5 [list source [file join $dir dns.tcl]] package ifneeded resolv 1.0.3 [list source [file join $dir resolv.tcl]] package ifneeded ip 1.3 [list source [file join $dir ip.tcl]] package ifneeded spf 1.1.1 [list source [file join $dir spf.tcl]] |
Changes to modules/dns/tcllib_ip.man.
|
| | | 1 2 3 4 5 6 7 8 | [vset IP_VERSION 1.3] [manpage_begin tcllib_ip n [vset IP_VERSION]] [see_also inet(3)] [see_also ip(7)] [see_also ipv6(7)] [keywords {internet address}] [keywords ip] [keywords ipv4] |
︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 | redundant parts or digts.. This procedure is the opposite of [cmd contract]. [call [cmd ::ip::contract] [arg address]] Convert a [cmd normalize]d internet address into a more compact form suitable for displaying to users. [call [cmd ::ip::prefix] [arg address]] Returns the address prefix generated by masking the address part with the mask if provided. If there is no mask then it is equivalent to calling [cmd normalize] | > > > > > > > > > > > > > > > > > > > > > > | 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 | redundant parts or digts.. This procedure is the opposite of [cmd contract]. [call [cmd ::ip::contract] [arg address]] Convert a [cmd normalize]d internet address into a more compact form suitable for displaying to users. [call [cmd ::ip::distance] [arg ipaddr1] [arg ipaddr2]] This command computes the (integer) distance from IPv4 address [arg ipaddr1] to IPv4 address [arg ipaddr2], i.e. "ipaddr2 - ipaddr1" [para] [example { % ::ip::distance 1.1.1.1 1.1.1.5 4 }] [call [cmd ::ip::nextIp] [arg ipaddr] [opt [arg offset]]] This command adds the integer [arg offset] to the IPv4 address [arg ipaddr] and returns the new IPv4 address. [para] [example { % ::ip::distance 1.1.1.1 4 1.1.1.5 }] [call [cmd ::ip::prefix] [arg address]] Returns the address prefix generated by masking the address part with the mask if provided. If there is no mask then it is equivalent to calling [cmd normalize] |
︙ | ︙ |