close
Warning:
Can't synchronize with repository "(default)" (/common/SVN/wimax does not appear to be a Subversion repository.). Look in the Trac log for more information.
- Timestamp:
-
Mar 15, 2013, 3:31:00 AM (10 years ago)
- Author:
-
ffund01
- Comment:
-
—
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v6
|
v7
|
|
14 | 14 | == Installing the driver == |
15 | 15 | |
16 | | === Patches to omf-resctl === |
| 16 | === Patches to omf-resctl (on the node) === |
17 | 17 | |
18 | 18 | In /usr/share/omf-resctl-5.3/omf-resctl/omf_agent/nodeAgent.rb: |
… |
… |
|
50 | 50 | # |
51 | 51 | # This file defines the class TeltonikaDevice which is a sub-class of |
| 52 | # WimaxcuDevice. |
52 | 53 | # |
53 | 54 | require 'omf-resctl/omf_driver/wimax' |
… |
… |
|
70 | 71 | |
71 | 72 | clearIP = deconfig |
72 | | @mode = @chnnl = @frequency = @bandwidth = @ip = @subnet = @nm = @fnm = @gw = @routip = @oldroutip = @oldnetmask = nil; |
73 | | @deldef = false |
| 73 | @mode = @chnnl = @frequency = @bandwidth = @ip = @dip = @subnet = @nm = @fnm = @gw = @routip = @oldroutip = @oldnetmask = nil; |
| 74 | @deldef = false |
| 75 | $chflag = 0 |
74 | 76 | end |
75 | 77 | |
… |
… |
|
82 | 84 | host.cmd("export interface=icc0"){ |c| print c } |
83 | 85 | host.cmd("/etc/udhcpc.script deconfig"){ |c| print c } |
| 86 | host.cmd("/bin/iptables -t nat -F") { |c| print c } |
84 | 87 | host.close |
| 88 | end |
| 89 | |
| 90 | def telnet_dynamicIP |
| 91 | debug "Configuring iptables for dynamic IP" |
| 92 | host = Net::Telnet::new("Host" => "192.168.0.1", |
| 93 | "Timeout" => 10, |
| 94 | "Port" => 700, |
| 95 | "Prompt" => /[$%#>] \z/n) |
| 96 | host.login("admin", "admin01") { |c| print c } |
| 97 | |
| 98 | begin |
| 99 | str = host.cmd("ifconfig icc0") { |c| print c } |
| 100 | #get the dynamic IP address: |
| 101 | lines = str.split("\n") |
| 102 | lines=lines.drop(2) |
| 103 | lines=lines.reverse.drop(6).reverse |
| 104 | vals=lines.collect { |row| |
| 105 | column = row.split(" ") |
| 106 | column[1] |
| 107 | } |
| 108 | |
| 109 | addr=vals[0] |
| 110 | addrAr=addr.split("\:") |
| 111 | dynIP=addrAr[1] |
| 112 | end while "#{dynIP}" <= "" |
| 113 | host.close |
| 114 | |
| 115 | debug "Dynamic IP is: #{dynIP} \n" |
| 116 | #add the rules to the iptables: |
| 117 | rule1 = "/bin/iptables -t nat -A PREROUTING -p udp -d #{dynIP} -j DNAT --to 192.168.0.8" |
| 118 | rule2 = "/bin/iptables -t nat -A PREROUTING -p tcp -d #{dynIP} -j DNAT --to 192.168.0.8" |
| 119 | debug "Running #{rule1} \n" |
| 120 | debug "Running #{rule2} \n" |
| 121 | #second telnet session to add the rules: |
| 122 | host = Net::Telnet::new("Host" => "192.168.0.1", |
| 123 | "Timeout" => 10, |
| 124 | "Port" => 700, |
| 125 | "Prompt" => /[$%#>] \z/n) |
| 126 | host.login("admin", "admin01") { |c| print c } |
| 127 | begin |
| 128 | host.cmd("#{rule1}") { |c| print c } |
| 129 | host.cmd("#{rule2}") { |c| print c } |
| 130 | rtrn = host.cmd("/bin/iptables -t nat -L") { |c| print c } |
| 131 | end while !(rtrn.include? "192.168.0.8") |
| 132 | host.close |
| 133 | return dynIP |
85 | 134 | end |
86 | 135 | |
… |
… |
|
116 | 165 | host.cmd("export router=#{router}"){ |c| print c } |
117 | 166 | host.cmd("/etc/udhcpc.script bound"){ |c| print c } |
| 167 | host.cmd("/bin/iptables -t nat -A PREROUTING -p udp -d #{ip} -j DNAT --to 192.168.0.8"){ |c| print c } |
| 168 | host.cmd("/bin/iptables -t nat -A PREROUTING -p tcp -d #{ip} -j DNAT --to 192.168.0.8"){ |c| print c } |
118 | 169 | host.close |
119 | 170 | |
120 | 171 | @fnm = netmask #final netmask. This will be used in 'unload' |
121 | | return tlres |
| 172 | return tlres |
| 173 | |
122 | 174 | end |
123 | 175 | |
124 | 176 | def initialize(logicalName, deviceName) |
125 | 177 | super(logicalName, deviceName) |
126 | | @mode = @ip = @subnet = @nm = @gw = nil |
| 178 | @mode = @ip = @dip = @subnet = @nm = @gw = nil |
127 | 179 | @ifconfig = '/sbin/ifconfig' |
128 | 180 | @wget = '/usr/bin/wget' |
129 | 181 | @route = '/sbin/route' |
130 | 182 | @deldef = false |
| 183 | $chflag = 0 |
131 | 184 | IO.popen("#{@ifconfig} #{deviceName} 192.168.0.8 netmask 255.255.255.0") |
132 | 185 | end |
… |
… |
|
138 | 191 | when :channel |
139 | 192 | return nil if @chnnl.nil? |
140 | | cmd = "#{@wget} --http-user admin --http-password admin -qO - 'http://192.168.0.1/cgi/cli?stopSs'; #{@wget} --http-user admin --http-password admin -qO - 'http://192.168.0.1/cgi/cli?addChannel frequency=#{@frequency} bandwidth=#{@bandwidth}'; #{@wget} --http-user admin --http-password admin -qO - 'http://192.168.0.1/cgi/cli?startSs'; #{@route} add default gw 192.168.0.1" |
| 193 | cmd = "#{@wget} --http-user admin --http-password admin -qO - 'http://192.168.0.1/cgi/cli?stopSs'; #{@wget} --http-user admin --http-password admin -qO - 'http://192.168.0.1/cgi/cli?addChannel frequency=#{@frequency} bandwidth=#{@bandwidth}'; #{@wget} --http-user admin --http-password admin -qO - 'http://192.168.0.1/cgi/cli?startSs'; #{@route} add default gw 192.168.0.1" |
| 194 | $chflag = 1 |
141 | 195 | when :ip |
142 | 196 | return nil if @ip.nil? |
… |
… |
|
151 | 205 | comRes = telnetIfConf |
152 | 206 | cmd = comRes unless comRes.nil? |
| 207 | when :dynip |
| 208 | return nil if @dip.nil? |
| 209 | if $chflag == 1 |
| 210 | comRes = telnet_dynamicIP |
| 211 | else |
| 212 | raise "CONNECT THE DEVICE (setup the channel first!) BEFORE ASSIGNING AN IP..." |
| 213 | end |
| 214 | cmd = nil |
153 | 215 | else |
154 | | raise "Unknown mode '#{@mode}'. Should be 'initiate', 'channel', 'mtu' or 'ip'" |
155 | | end |
| 216 | raise "Unknown mode '#{@mode}'. Should be 'channel', 'mtu', gway, dynip, netmask, or 'ip'" |
| 217 | end |
156 | 218 | return cmd |
157 | 219 | end |
158 | | # |
| 220 | # |
159 | 221 | # Return the specific command required to configure a given property of this |
160 | 222 | # device. When a property does not exist for this device, check if it does |
… |
… |
|
176 | 238 | @nm = value |
177 | 239 | @subnet = IPAddr.new("#{@nm}").to_i.to_s(2).count("1") |
| 240 | return buildCmd |
| 241 | when "dynip" |
| 242 | @mode = :dynip |
| 243 | @dip = value |
178 | 244 | return buildCmd |
179 | 245 | when "gway" |