Module: AdditionalImperituroard

Defined in:
lib/imperituroard/add_functions/add/additional.rb

Class Method Summary collapse

Class Method Details

.stat_parse_ip_num(ipnum) ⇒ Object



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
# File 'lib/imperituroard/add_functions/add/additional.rb', line 5

def self.stat_parse_ip_num(ipnum)
  #translated prefix from ip address number
  prefixmask=0

  #translation from ip addresses number to prefix
  if ipnum == 1
    prefixmask=32
  elsif ipnum == 2
    prefixmask = 31
  elsif ipnum>2 && ipnum<=8
    prefixmask=29
  elsif ipnum>8 && ipnum<=16
    prefixmask=28
  elsif ipnum>16 && ipnum <=32
    prefixmask=27
  elsif ipnum>32 && ipnum <=64
    prefixmask=26
  elsif ipnum >64 && ipnum <=128
    prefixmask=25
  elsif ipnum >128 && ipnum <=256
    prefixmask=24
  elsif ipnum >256 && ipnum <=512
    prefixmask=23
  elsif ipnum >512 && ipnum <=1024
    prefixmask=22
  elsif ipnum >1024 && ipnum <=2048
    prefixmask=21
  elsif ipnum >2046 && ipnum <=4094
    prefixmask=20
  elsif ipnum >4094 && ipnum <=8190
    prefixmask=19
  elsif ipnum >8190 && ipnum <=16382
    prefixmask=18
  elsif ipnum >16382 && ipnum <=32766
    prefixmask=17
  elsif ipnum >32766 && ipnum <=65534
    prefixmask=16
  elsif ipnum >65534 && ipnum <=131070
    prefixmask=15
  elsif ipnum >131070 && ipnum <=262142
    prefixmask=14
  elsif ipnum >262142 && ipnum <=524286
    prefixmask=13
  elsif ipnum >524286 && ipnum <=1048574
    prefixmask=12
  elsif ipnum >1048574 && ipnum <=2097150
    prefixmask=11
  elsif ipnum >2097150 && ipnum <=4194302
    prefixmask=10
  elsif ipnum >4194302 && ipnum <=8388606
    prefixmask=9
  elsif ipnum >8388606 && ipnum <=16777214
    prefixmask=8
  end
  ##

  prefixmask

end