# Remote Management

## Introduction

The Atheros Open Powerline Toolkit includes several example applications that perform basic powerline device management from a remote host. Each example implements a different network protocol, such as HTTP, SNMP or TR-069. These applications merely demonstrate the underlying concepts but none perform full network device management. That is left to our customers because their needs vary.

All examples are proxy implementations where a local host communicates with one powerline device over Ethernet. That device then communicates with other devices over powerline or coax. All management functionality is programmed into the local host but other hosts are able to request information or services from it over Ethernet. The local host could be either part of the local powerline device or an external workstation.

## HTTP Protocol

### Overview

HTTP provides a simple means for one device to interact with one or more remote hosts. The device merely needs requires a basic web server with Common Gateway Interface (CGI) support. With CGI support, one can write programs that read structured data from their standard input and write HTML to their standard output. Generally, the HTML output is a form that the user can complete and submit for subsequent processing by some application on device.

The basic chain of events looks something like this:

1. A user connects the client (some remote computer) to the server (some powerline device) using a web browser.

2. The server executes the application (some CGI program) designated as the default Uniform Resource Locator (URL) and passes any associated data to the application. Initially there is no data to pass.

3. The application sees there is no data on stdin and prints an HTML form on stdout. The form contains one or more submit buttons and assigns some URL as the ultimate recipient of form data.

4. The server forwards the form to the requesting client.

5. The client displays the form.

6. The user completes the form and presses one of the submit buttons. This creates some data for the application to process.

7. The client forwards the form to the URL designated by the application. Often, this URL is an application on the originating server but it could be an application on another server.

8. The server executes the application designated by the URL and passes the associated data to the application.

9. The application reads the form data from stdin, processes it and writes new HTML to stdout. This could be the same form with new data or new fields or new submit buttons or a different form.

The chain of events described above is the same even for scripting languages such as PHP, ASP and JSP. The only difference is the nature of the application. In our case, the application is a compiled C Language program because we do not want the overhead of a full scripting language. We also elected of have one application process all forms to minimize the number of files that must be distributed and maintained.

One design consideration is the method used to store information from one data exchange to the next. We cannot store the information in memory because the application does not run continuously. Consequently, we defined a data structure to hold all the required information then write the structure directly to a file in binary format on exit and read it back on start up. This data structure is known as a session variable and the process of reading and writing it in binary is known as serialization.

1. Read session state from a file.

2. Read form data from stdin and parse it. Update the session state based on the form data. For example, record which submit button was pressed by the user. Store the content of form fields changed by the user.

3. Inspect the session state and perform any tasks indicated. Update the session state based on task results.

4. Write new HTML to stdout. Indicate the new session state for the user to see. This could include new data in form fields, new form fields, a new form or new submit buttons.

5. Save the session state to a file.

6. Terminate the application.

### Installation

## SNMP Protocol

## TR-069 Protocol