Howto

20
How to setup a wireless thin rq-echo client. Before you begin. You should know how to setup and run rq-client in your PC, be familiar with what it requires: configuration files, URL, user name, password and des key needed to access a newcamd server. Running rq-client in an openwrt router is a lot like doing it in a PC, think of the router as a small computer (it actually is) with no hard drive, no monitor, no keyboard. What's different is the way you place the necessary files in the router's flash. This flash is like a harddrive to a PC, it contains the Operating System, folders, configuration files, programs, etc. In this guide I'm using a PC running XP profesional and will configure an Asus wl-520gu router to act as a thin wireless client. Other Operating Systems (Vista, 7, OSX) should be similar, as other routers capable of running openwrt. 1. Prepare your computer What's needed: a) a ftp or HTTP server (I'm using apache2 here) b) a text editor ( I recommend notepad++ or similar, that can create Linux text files in Windows) c) openwrt image and library packages. d) a terminal program (putty here). e) the rq-echo-client files and a working .bn10* image. The server. To transfer files into your router's flash, a server is needed, I'm using the apache2 HTTP server here, You can use a simple ftp server if you like, there is one reason I used a web server instead of ftp: opkg. Opkg is a program in the Openwrt system that allows to load packages into the router easily, via the HTTP protocol. So, download apache2 from http://httpd.apache.org/download.cgi and run the installation program. I selected the Win32 binary with no crypto (MSI installer).

Transcript of Howto

Page 1: Howto

How to setup a wireless thin rq-echo client.Before you begin.You should know how to setup and run rq-client in your PC, be familiar with what it requires:configuration files, URL, user name, password and des key needed to access a newcamd server.

Running rq-client in an openwrt router is a lot like doing it in a PC, think of the router as a small computer (it actually is) with no hard drive, no monitor, no keyboard. What's different is the way you place the necessary files in the router's flash. This flash is like a harddrive to a PC, it contains the Operating System, folders, configuration files, programs, etc.

In this guide I'm using a PC running XP profesional and will configure an Asus wl-520gu router to act as a thin wireless client.

Other Operating Systems (Vista, 7, OSX) should be similar, as other routers capable of running openwrt.

1. Prepare your computerWhat's needed:a) a ftp or HTTP server (I'm using apache2 here)b) a text editor ( I recommend notepad++ or similar, that can create Linux text files in Windows)c) openwrt image and library packages.d) a terminal program (putty here).e) the rq-echo-client files and a working .bn10* image.

The server.To transfer files into your router's flash, a server is needed, I'm using the apache2 HTTP server here,You can use a simple ftp server if you like, there is one reason I used a web server instead of ftp: opkg.Opkg is a program in the Openwrt system that allows to load packages into the router easily, via the HTTP protocol.So, download apache2 from http://httpd.apache.org/download.cgi and run the installation program. I selected the Win32 binary with no crypto (MSI installer).

Page 2: Howto

click next

Select accept and click next, and then click next againFill out your domain and server names (not too important) and click next, and then next again 2 times, and finally the Install button. This will install Apache on your X:\Program Files\Apache Software Foundation folder. and the server will be listening on port 80 of your local PC.

Page 3: Howto

Navigate to that folder, then into the Apache2.2\htdocs folder.Lets create 2 folders here, I'll name the first one 'rqclient' and the second 'openwrt'.

We need to place the binaries and configuration files for the rq-cient, all of them, in the rqclient folder of your Apache server.

Page 4: Howto

We'll use the openwrt folder to host the library files needed to run the client later.

Its a good idea at this point to download a 'Linux friendly' text editor. I'm using notepad++, download from http://notepad-plus-plus.org/ run the installation file with all the default options.

Once it is installed configure notepad++ to use Linux files by going to Settings -> Preferences and then select the New Document tab and select Unix in the format option.

Page 5: Howto

Run notepad++, select File -> New to create a new file, copy and paste this skeleton into this new file,edit with your info and save as rq-echo-client.conf and place it in the rqclient folder of your server.

--- code ---########################### general configuration #############################[General]# Serial port where the emu board is connected.# Asus wl520gu : /dev/tts/0# Linksys WRT54GL: /dev/tts/0 or /dev/tts/1serial_port=/dev/tts/0

# Sets the byte write delay. The default value of this parameter is zero.byte_write_delay=0

# Enable or disable background executionbackground_execution=1

# This sets the level of console output for debugging:debug_level=2

# This option enables or disables the writing of debug information to the# console.

log_to_console=1

# This option enables or disables the writing of console output to a log file

log_to_file=0

# When log_to_file is set to 1, this is the path and filename to write console

logfile_name=/root/rq-echo-client.log

# Selects the generation of nagra encryption system that will be used# The emu board's ATR must match this (i.e: N2 -> ROM10X, N3 -> ROM24X)# 0 - Nagravision 2# 1 - Nagravision 3

nagra_generation=1

# Nagra CAM eeprom image to use for configuration (must be an *.bn102 file).

nagra_cam_image=./bin.bn102

# Tier source# 0 - CAM image# 1 - This configuration file# 2 – Server-side

Page 6: Howto

nagra_tier_source=0

# List of custom tiers to use replacing the ones in the cam file. These tiers# are specified as outputted to the ird by a real card. Up to 64 tiers can be# specified by incrementing a consecutive number at the end.

nagra_tier_0=nagra_tier_1=nagra_tier_2=

# Autoupdate expired data items. A value of zero disables this feature. If # set to a value greater than zero, expired data items will be updated to# the current date plus this number of days.

nagra_autoupdate_expired_dataitems=30

# Timeout in seconds for receiving control words from server.# Default value is 10 seconds

control_words_timeout=10

# Number of retries before triggering a server fail-over.# Note: A value of 0 means it will fail-over on first failure (no retries).# Default value is 2 retries

retries_before_failover=2

# URL of card-server to use, formats are as follows:## newcamd://<username>:<password>@<hostname>:<port>/<des_key>/[EMM]## Example:# newcamd://foo:[email protected]:12345/0CE3476FF2E1C9D9A0A109B371E3/EMM## NOTE: The "EMM" suffix is optional and tells rq-echo-client whether# to send EMM's to the card-server or not. Enabling or disabling this only# has effect if the card-server is configured to accept emms from this client.## Multiple card-server url's can be specified for server fail-over.# If the emu fails to connect or fails to get valid CW's, it will try to# connect to other servers in a round-robin fashion.## Up to 65 servers can be added from index 0 to 63, plus a non-indexed parameter# named "card_server_url"

card_server_url=newcamd://dummy_1:[email protected]:10000/0102030405060708091011121314--- code ---

Page 7: Howto

Create another new file, copy and past the following and save as inittab, make sure you select 'All types (*.*)' in the Save as type picker, place in the rqclient folder.--- code ---::sysinit:/etc/init.d/rcS S boot::shutdown:/etc/init.d/rcS K stop--- code ---

Create a third new file, copy and paste the following code and save as rqboot.sh.--- code ---#!/bin/sh /etc/rc.common#-------START=98#-------RQ_PATH=/rootRQ_CLIENT=$RQ_PATH/rq-echo-client.openwrt-bcm947xxDESC="RQ Client"#-------boot() { start}

Page 8: Howto

#-------start() { sleep 5 cd $RQ_PATH echo "Starting : $DESC " $RQ_CLIENT &}--- code ----

Finally, create a fourth file, copy and paste this code to it, save as opkg.conf--- code ---src/gz snapshots http://192.168.1.11/openwrtdest root /dest ram /tmplists_dir ext /var/opkg-listsoption overlay_root /jffs--- code ---

I'll explain a little. The 2nd file is a configuration file that disables Openwrt from using the serial port to login or send debug messages, since we need this port for our client. The 3rd file is a script that starts the client automagically every time we turn on our router. The fourth is a configuration file that tells the opkg program to look for packages in our local PC.

If you haven't done so, place the bn102 or bn103 file needed for the client, also in the same folder.Here's how my rqclient folder looks like:

Page 9: Howto

Now... Openwrt. The asus router comes with a firmware that won't allow us to run the client, there are several 3rd party firmwares that we can use for this. Here, we use Openwrt.

The image for the asus is: http://downloads.openwrt.org/kamikaze/8.09.2/brcm-2.4/openwrt-brcm-2.4-squashfs.trx Download that and place it anywhere on your Desktop or My Documents.

Rq-echo-client needs the c++ standard library to work. Luckily, Openwrt has opkg that allows us to install any needed packages into our box. Download http://downloads.openwrt.org/kamikaze/8.09.2/brcm-2.4/packages/Packages Download http://downloads.openwrt.org/kamikaze/8.09.2/brcm-2.4/packages/Packages.gz Download http://downloads.openwrt.org/kamikaze/8.09.2/brcm-2.4/packages/libstdcpp_3.4.6-14.3_mipsel.ipk And place all 3 files in the 'openwrt' folder of the Apache server.

Page 10: Howto

Install the asus wireless router utilities from the cd that came with the router.

Uncheck the Launch the EZ setup wizard option and click Finish.

We need a terminal program to communicate with our router. I'm using putty here. Download fromhttp://the.earth.li/~sgtatham/putty/latest/x86/putty.exe

Finally setup your network to have the static ip address of 192.168.1.11, netmask 255.255.255.0 and

Page 11: Howto

gateway 192.168.1.1. First, open ' Network Connections', right click on 'Local Area Network' and select properties.

Highlight Internet Protocol, and click Properties.

Page 12: Howto

And setup your network to have the static ip address of 192.168.1.11, netmask 255.255.255.0 and gateway 192.168.1.1

Now your PC is ready for you to install Openwrt and the rq-client in to your router.

2. Install Openwrt and rq-echo-client files.So far, your PC was connected to the internet probably this way:

Now you need to connect your PC to the asus router like this:

Page 13: Howto

connect it to the first LAN port, closest to the WAN port, just after the power supply and USB port.

On the PC, start the firmware restoration utility. Browse to select the Openwrt image downloaded before.

Disconnect the power supply from the back of the router.Press and hold the Restore button (black) and connect the power supply while pressing the Restore button.As soon as the power led flashes once, release the Restore button.Now, on the restoration program, click Upload.

Close the program when the flashing finishes.

Page 14: Howto

Start the putty program, enter the address 192.168.1.1 , select telnet and click Open

On the terminal window enter the 'passwd' command, to set a password for root, the superuser.

Page 15: Howto

You will be prompted to enter a password twice. Type the 'exit' command or close the terminal window.

Now run putty again, same ip address but this time select ssh. If prompted with a security warning, click Yes.

When prompted login as: , type 'root' then Enter . When prompted for a password, type the password entered in the previous step, then hit Enter. You should see this welcome screen:

Page 16: Howto

Once inside your openwrt terminal, enter the following commands:--- code ---wget http://192.168.1.11/rqclient/rq-echo-client.openwrt-bcm947xxwget http://192.168.1.11/rqclient/rq-echo-client.confwget http://192.168.1.11/rqclient/bin.bn102 ( edit with the proper image name )--- code ---

If your apache server is running, You shoud see something like this..

make the client executable with this command:--- code ---chmod + x /root/rq-echo-client.openwrt-bcm947xx--- code ---Replace the original inittab file with the edited one in our server:--- code ---rm /etc/inittabcd /etcwget http://192.168.1.11/rqclient/inittab--- code ---

Replace the original opkg.conf file with the one in our server:--- code ---rm /etc/opkg.confcd /etcwget http://192.168.1.11/rqclient/opkg.conf--- code ---

Now we can install the libstdcpp library using the opkg command:

Page 17: Howto

--- code ---opkg updateopkg install libstdcpp--- code ---

Download the autostart script.--- code ---cd /etc/init.dwget http://192.168.1.11/rqclient/rqboot.sh

--- code ---

Make it executable, and enable it:--- code ---chmod +x /etc/init.d/rqboot.sh/etc/init.d/rqboot.sh enable--- code ---

Finally, lets configure the firewall so we can access this router when we're not connected to it with anethernet cable on the local network (LAN). This will allow You to manage the router remotely, if necesary. Enter the following commands. Line by line.-- code --uci add firewall ruleuci set firewall.@rule[-1]._name=sshuci set firewall.@rule[-1].src=wanuci set firewall.@rule[-1].target=ACCEPTuci set firewall.@rule[-1].proto=tcpuci set firewall.@rule[-1].dest_port=22uci commit firewall/etc/init.d/firewall restart-- code --

3. Network configuration.At this point, lets restore our PC to obtain dynamic IP address.Here, you need to decide how your router will connect to the server, posible scenarions are:local network, internet directly (as a main router), internet via a second router or as a wireless client.As default, Openwrt is a dhcp client on the WAN port, and dhcp server on the LAN ports, with no wireless enabled.Openwrt uses the 192.168.1.1 LAN ip address. If you connect the router directly to a cable or dsl modem with dhcp, there is no need to configure anything. If you connect the asus router to an existing router, and both have the same network IP, your asus router wont get a dhcp lease, to fix this, you must change the asus IP address.Access your Openwrt webif interface by opening a web browser (firefox here) and entering the router IP address: http://192.168.1.1 , username is root, and the password, the one you entered in putty.On Network -> General, edit your network IP-v4 address (I'm using 10.0.0.1 here, but make sure it doesn't conflict with anything else on your network).

Page 18: Howto

Click Save and then Apply changes. You should unplug your ethernet cable and after a couple of minutes, plug it back so your PC can renew the IP. If You're planning on running this as a wired client, that's it, all your router needs now is a wire from its WAN port to one of the LAN ports of your router/modem/switch.

Page 19: Howto

If you have a wireless access point (wifi-AP) available, you can run this router as a wireless client, here's how:

open a web browser and go to the Openwrt webif ( mine is http://10.0.0.1 now ).After loggin in, go to Network -> wifi. Check the enable option, and enter the values corresponding to your AP, on mode, select Join (client), click Save, then apply settings.

Let the router reload all new values, when finished, go to Network->General, and make sure you have a WAN IP address.

If You don't, double check your ESSID name, key, channel #.

Page 20: Howto

4. EMU Interface.

Remove the 2 screws from the bottom of the router, 2 more are hidden under the stick-on rubber stands.Remove the cover and localize the 4 pin serial header. Here's a close up of it

An atmega 128 can be used as an emu board for this router without the need of a serial adaptor.3 wires would be needed for this.

1. Pin #2 of the atmega (Rx) connects to Tx in the asus.2. Pin #3 (Tx) connects to Rx in the asus.3. Gnd (Several pines, or gnd from the caps) connects to Gnd.

Happy testing ..this is version #1 .. any feedback will be posted on future versions.