DHCP server configuration. Loading and updating STB software
Additional information may be taken from - Operator guide. IPTV MAG-200 High resolution device.
Examples are provided on base: OS - Ubuntu 16.04 server, DHCP - isc-dhcp-server, TFTP Server - Openbsd-inetd TFTP, STB MAG-322
TFTP server. Installation, setup
Example of installing and configuring TFTP server for downloading and updating software by TFTP for MAG322
- Install TFTP server (if it was not installed before) :
apt-get install openbsd-inetd tftp tftpd
- By default TFTP server is configured to use the directory
/srv/tftp
. if necessary, change its value in/etc/inetd.conf
- Create directory /srv/tftp/stb/322 and put the necessary files in it: Bootstrap, imageupdate, logo.bmp.gz, OP.KEY.
Where:
Bootstrap - OS Kernel (it is provided with STB software release);
imageupdate - STB software image (as a rule it is created by the operator);
logo.bmp.gz - Bootloader Logotype (as a rule it is created by the operator);
OP.KEY - Operator gpg key (public part).
- Assign the ownership of the created directory to the pseudo-user nobody:
chown -R nobody /srv/tftp/stb/322
- Restart
inetd service:
/etc/init.d/openbsd-inetd restart
TFTP server functionality check-up
If the TFTP client runs on a local server, specify the IP address 127.0.0.1. If the client runs on a remote server, specify the IP address of the server.
echo test > /srv/tftp/stb/322/myfile
cd /home tftp 127.0.0.1 tftp> get stb/322/myfile
DHCP server isc-dhcp-server. Installation, setup
sudo apt-get install isc-dhcp-server
- DHCP server global (default) Configuration File is /
etc/default/isc-dhcp-server
In this file, you must specify the interface on which the DHCP server should act. In this example, the name of the network interface is enp1s6
- DHCP Server Configuration File is
/etc/dhcp/dhcpd.conf
Option Space
To exchange "vendor-specific" information between the server and the client (STB), DHCP option # 43 is used. To describe the manufacturer's information, STB uses "option space Infomir". The list of possible options:
option space Infomir; option Infomir.autostart code 1 = text; option Infomir.bootargs code 2 = text; option Infomir.mcip code 3 = ip-address; option Infomir.mcport code 4 = integer 16; option Infomir.oppubfile code 9 = text; option Infomir.mcip_img code 10 = ip-address; option Infomir.mcport_img code 11 = integer 16; option Infomir.mcip_mng code 12 = ip-address; option Infomir.mcport_mng code 13 = integer 16; option Infomir.ip_log code 14 = ip-address; option Infomir.port_log code 15 = integer 16; option Infomir.logo_x code 16 = integer 16; option Infomir.logo_y code 17 = integer 16; option Infomir.bg_color code 18 = integer 32; option Infomir.fg_color code 19 = integer 32; option Infomir.VerNumber code 20 = text; option Infomir.DateTime code 21 = text; option Infomir.portal_dhcp code 22 = text; option Infomir.timezone code 23 = text; option Infomir.update_url code 24 = text; option Infomir.update_sboot code 25 = text; option Infomir.update_ver code 26 = text; option Infomir.update_mode code 27 = text; option Infomir.update_sboot_ver code 28 = text;
Description of vendor-specific options
Name | Code | Type | Description | Who uses |
---|---|---|---|---|
mcip | 3 | ip-address | IP address of multicast group for kernel/Bootstrap receiving | Boolloader |
mcport | 4 | integer 16 | Port of the multicast group for kernel/Bootstrap receiving | Boolloader |
oppubfile | 9 | text | Contains the file name, in which prepared operator's key for installation | Bootstrap |
mcip_img | 10 | ip-address | IP address of multicast group for imageupdate receiving | Bootstrap |
mcport_img | 11 | integer 16 | Port of the multicast group for imageupdate receiving | Bootstrap |
mcip_mng | 12 | ip-address | IP address of multicast group for commands receiving | Firmware |
mcport_mng | 13 | integer 16 | Port of the multicast group for commands receiving | Firmware |
ip_log | 14 | ip-address | IP address of the server, on which Bootstrap can send reports | Bootstrap |
port_log | 15 | integer 16 | Port of server, on which Bootstrap can send reports | Bootstrap |
logo_x | 16 | integer 16 | Coordinates by x, left-top corner of the logo | Boolloader |
logo_y | 17 | integer 16 | Coordinates by y, left-top corner of the logo | Boolloader |
bg_color | 18 | integer 32 | Background color in “XRGB” format for messages while loading | Boolloader |
fg_color | 19 | integer 32 | Fonts color “XRGB” format for messages while loading | Boolloader |
VerNumber | 20 | text | Bootstrap version 3 digits with leading zero. Example: substring( option vendor-encapsulated-options,2,3)=“002” | Dhcp-сервер |
DateTime | 21 | text | Date and time of Bootstrap creation | Dhcp-сервер |
portal_dhcp | 22 | text | Starting portal, if the values “portal1” and “portal2” are not defined & variable ”use_portal_dhcp” is not set or has value “true”. If the variable “use_portal_dhcp” is set to ”false”, then it will not be used | Dhcp-сервер |
timezone | 23 | text | Timezone value that is passed to STB to set the variable timezone_conf. | |
update_url | 24 | text | URL (location) of imageupdate file (to update STB software). Example: "tftp: //10.1.1.1/322/imageupdate" | |
update_sboot | 25 | text | URL of Bootloader image that used for updating. | |
update_ver | 26 | text | The version number of the STB software update file (imageupdate). If the number of the current image (used in STB) and transmitted for update coincides, then the update is not performed. | |
update_mode | 27 | text | URL of Bootstrap image. Example: "tftp: //10.1.1.1/254/Bootstrap". | |
update_sboot_ver | 28 | text | Bootloader version that used for updating. |
Loading OS kernel (Bootstrap / uImage) via TFTP on Emergency mode
Example of the contents of the section "MAG322_boot":
class "MAG322_boot" { match if (( option vendor-class-identifier="InfomirMAG322boot")); filename "stb/322/Bootstrap"; next-server 10.1.1.1; option ntp-servers 10.1.1.1; vendor-option-space Infomir; }
Note. Emergency Recovering with Service button MAG3xx
Updating software (imageupdate) from System Recovery Utility menu
Example of section "MAG322_upgrade" contents:
class "MAG322_upgrade" { match if (( option vendor-class-identifier="InfomirMAG322upgrade")); next-server 10.1.1.1; option ntp-servers 10.1.1.1; vendor-option-space Infomir; option Infomir.update_url "tftp://10.1.1.1/stb/322/imageupdate"; }
Note. Selecting software update mode on System Recovery Utility MAG-3xx
After update completing: 1) bootloader variables Image_Version, Image_Date, and Image_Desc are set, according to the updated version parameters; 2) NAND boot mode is set; 3) STB is restarted.
Automatic software update via TFTP when STB starting in DHCP
Example of section "MAG322_vendor" contents:
class "MAG322_vendor" { match if (( option vendor-class-identifier="InfomirMAG322")); next-server 10.1.1.1; option ntp-servers 10.1.1.1; vendor-option-space Infomir; option Infomir.portal_dhcp "http://10.1.1.1/stalker_portal/c/index.html"; option Infomir.update_ver "220"; option Infomir.update_url "tftp://10.1.1.1/stb/322/imageupdate"; }
In case of successful update: 1) bootloader variables Image_Version, Image_Date, and Image_Desc are set according to the new (just updated) version parameters; 2) NAND boot mode is set; 3) STB is being restarted.
An external portal will be loaded under the following conditions: 1) the value of
infomir.portal_dhcp is defined in the "MAG322_vendor" class; 2) the variables portal1 and portal2 are not set; 3) the variable use_portal_dhcp is not set or it has the value " true". If the variable use_portal_dhcp is set to "false", then the value of the option Infomir.portal_dhcp is not used.
The value of environment variables can be set/viewed in Portal Settings, as well as, with the fw_printenv utility.
Message Exchange via DHCP protocol
Consider an example of exchanging DHCP-protocol messages between STB and server in case of using the class "MAG322_upgrade" in dhcpd.conf according to example.
The following network parameters are used in the example:
- MAC address of the network interface (Ethernet) of the set-top box - 0: 1a: 79: 51: 8: 98
- MAC address of the network interface (Ethernet) of the server - 0: 30: 48: fd: 9e: 5f
- IP-address, which is assigned to the STB by the server - 10.1.1.26
- IP address of the server is 10.1.1.1
STB sends dhcp-request with the following parameters (only certain parameters are specified):
- IP: 0.0.0.0 (0:1a:79:51:8:98) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
- OP: 1 (BOOTPREQUEST)
- CHADDR: 00:1a:79:51:08:98:00:00:00:00:00:00:00:00:00:00
Option 53 DHCP message type: 1 (DHCPDISCOVER)
- Option 61 Client identifier 0:1a:79:51:8:98
Option 55 Parameter Request List: 1 (Subnet mask), 3 (Routers), 6 (DNS server), 12 (Host name), 15 (Domain name), 28 (Broadcast address), 42 (NTP servers), 43 (Vendor specific info)
Option 60 Vendor class identifier: InfomirMAG322upgrade
The server receives and analyzes request from STB and then sends a dhcp-response with the following parameters (only certain parameters are specified):
- IP: 10.1.1.1 (0:30:48:fd:9e:5f) > 10.1.1.26 (0:1a:79:51:8:98)
- OP: 2 (BOOTPREPLY)
- YIADDR: 10.1.1.26
- SIADDR: 10.1.1.1
- CHADDR: 00:1a:79:51:08:98:00:00:00:00:00:00:00:00:00:00
OPTION 53 (1) DHCP message type: 2 (DHCPOFFER)
- OPTION: 54 ( 4) Server identifier 10.1.1.1
- OPTION: 51 ( 4) IP address leasetime 600 (10m)
- OPTION: 1 ( 4) Subnet mask 255.255.255.0
- OPTION: 3 ( 4) Routers 10.233.0.104
- OPTION: 6 ( 8) DNS server 8.8.8.8,8.8.4.4
- OPTION: 28 ( 4) Broadcast address 10.1.1.255
- OPTION: 42 ( 4) NTP servers 10.1.1.1
Option 43 Vendor specific info: tftp://10.1.1.1/stb/322/2.20.07-a6/imageupdate
After receiving settings from DHCP server, STB connects to the TFTP server and gets the imageupdate file by the path specified in these settings. The screen displays messages about the stage of the updating procedure:
Starting update from DHCP
Receive is starting tftp://10.1.1.1/stb/322/2.20.07-a6/imageupdate
Writing image to flash///
Checking signature,
etc.
Setting operator's logotype and key
class "MAG322_upglogo" { match if (( option vendor-class-identifier="InfomirMAG322upglogo")); next-server 10.1.1.1; option ntp-servers 10.1.1.1; vendor-option-space Infomir; filename "stb/322/logo.bmp.gz"; option Infomir.oppubfile "stb/322/OP.KEY"; }