Strega
01-11-2006, 10:21 AM
This is a small lil subnet calculator for IRC. Basically you just put in the type of network it is, and it outputs the subnet.
So, if you want to know what the subnet on a /24 network is, you type:
!subnet /24 or !subnet 24
It will return the appropriate subnet, which is: 255.255.255.0
on 1:text:!sub*:#: {
set %type $2
if ($chr(47) isin %type) { set %type $right(%type,-1) }
if (($len(%type) > 2) || (!%type)) { msg $chan 14Not a valid network | HALT }
if ((%type !isnum) || (%type > 32)) { msg $chan 14Not a valid network | HALT }
set %i 1
while (%i < 5) {
if (%type >= 8) { set %oct. [ $+ [ %i ] ] 255 }
elseif (%type <= 0) { set %oct. [ $+ [ %i ] ] 0 }
else { set %oct. [ $+ [ %i ] ] $calc(256 - 2 ^ (8 - %type)) }
inc %i 1
dec %type 8
}
msg $chan 14Subnet:4 $+(%oct.1,.,%oct.2,.,%oct .3,.,%oct.4)
}
So, if you want to know what the subnet on a /24 network is, you type:
!subnet /24 or !subnet 24
It will return the appropriate subnet, which is: 255.255.255.0
on 1:text:!sub*:#: {
set %type $2
if ($chr(47) isin %type) { set %type $right(%type,-1) }
if (($len(%type) > 2) || (!%type)) { msg $chan 14Not a valid network | HALT }
if ((%type !isnum) || (%type > 32)) { msg $chan 14Not a valid network | HALT }
set %i 1
while (%i < 5) {
if (%type >= 8) { set %oct. [ $+ [ %i ] ] 255 }
elseif (%type <= 0) { set %oct. [ $+ [ %i ] ] 0 }
else { set %oct. [ $+ [ %i ] ] $calc(256 - 2 ^ (8 - %type)) }
inc %i 1
dec %type 8
}
msg $chan 14Subnet:4 $+(%oct.1,.,%oct.2,.,%oct .3,.,%oct.4)
}