Linux Appliance Design: A Hands-on Guide to Building Linux Appliances 9781593271404, 1593271409

While there are books that tell readers how to run Linux on embedded hardware and books on how to build a Linux applicat

125 68 9MB

English Pages 388 Year 2007

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Contents
Acknowledgments
Introduction
What This Book Is About
What This Book Is Not About
Who Should Read This Book
Why Use Linux?
Availability of Source Code
Range of Hardware Supported
Availability of Linux Developers
Reliability
Quality Compilers
Good Documentation
Existing Software Packages
Low Development Cost
No Licensing Fees for Deployment
Security
Linux Appliance Design
1 Appliance Architecture
UIs and Daemons
Daemons
User Interfaces
Interprocess Communication
The Architecture of the Laddie Appliance
Summary
2 Managing Daemons
Common Approaches to Managing Daemons
File-Based Management
A Daemon-Based Web Interface
An All-in-One Approach
Control and Status Protocols
Requirements for a Control and Status Protocol
Common Control and Status Protocols
Summary
3 Using Run-Time Access
RTA Appliance Architecture
RTA Daemon Architecture
Telling RTA About Your Columns and Tables
Columns
Tables
Building Your First RTA Program
Defining the Problem
Reviewing the Code
Installing RTA
Building and Linking
Testing
A Little SQL
SELECT
UPDATE
WHERE
LIMIT
Introduction to RTA’s Built-in Tables
rta_dbg
rta_stat
rta_tables
rta_columns
The RTA Table Editor
Summary
4 Building and Securing Daemons
How to Build a Daemon
Load the Daemon’s Configuration
Go into the Background
Become the Process and Session Leader
Set the Working Directory
Redirect stdin, stdout, and stderr
Set Up Logging
Set Group and User IDs
Check for a pidfile
Set the umask
Set Up Signal Handlers
How to Secure a Daemon
Designing a Secure Daemon
Write a Secure Daemon
Limit Damage in Case of a Breach
A Prototype Daemon
Summary
Further Reading
5 The Laddie Alarm System: A Sample Appliance
Introduction to Alarm Systems
Sensors
Enabling a Zone
A Functional Specification for Laddie
ladd’s Configuration and Status
ladd’s Alarm Handling
Laddie’s Hardware Design
Laddie’s Software Design
The appInit() Callback Subroutine
The poll_timeout() Callback Subroutine
The user_update() Callback Subroutine
Building and Testing ladd
Summary
6 Logging
Do You Need Logging?
Architecture of a Logging System
Message Sources
Message Routing
Message Destinations
syslog
syslog Architecture
Using syslog
The syslog Protocol
Using the syslogd Daemon
Limitations, Advantages, and Alternatives to syslogd
On-Demand Logging
Summary
7 Laddie Event Handling
Rationale for a New Event-Handling System
Features and Capabilities of logmuxd
Configuring logmuxd
logmuxd Sources
logmuxd Filters and Rewriting
logmuxd Destinations
Examples Using logmuxd
Example 1: A logmuxd Demonstration
Example 2: logmuxd and Accepted TCP Connections
Example 3: logmuxd and SNMP Traps
Summary
8 Designing a Web Interface
Web Basics
DNS and TCP
The Webserver
CGI
JavaScript
Evolving Technologies
Establishing Requirements
Choosing a Webserver
Choices
Use PHP
Case Study: Linksys WRT54G Wireless Router
Case Study: The TUX Webserver
Comparison of Webservers
UI Design
Menu System
Dialog Boxes
Error Messages
Improving Responsiveness with Ajax
Implementation
Interfacing with the Daemons
Alarm Status Page
Alarm Setup Page
Page Layout and Menu System
Webserver Independence
Asynchronous Updates Using Ajax
Improving Our Design
Resources
Summary
9 Designing a Command Line Interface
Why You Need a CLI
Security
Availability
Bandwidth
Scriptability
Configuration Backup and Restore
Types of CLIs
Sentences
Wizards
Menus
Stateful
Character vs. Line Interfaces
Giving Users Access to a CLI
The Laddie CLI
Laddie Command Summary
set logs on
dump
help
Code Review for the test Command
CLI Vocabulary: token.l
CLI Grammar: syntax.y
C Code
Code Review Notes
Summary
10 Building a Front Panel Interface
Buttons, LEDs, and LCDs
Buttons
LEDs
LCDs
Designing a Front Panel UI
Be Simple
Try, Fail, Try Again
Use LCD Menus and Modes
Be Quick!
The Laddie Front Panel
Laddie LCD Menu System
Laddie Front Panel Hardware
Laddie Front Panel UI
Improving Our Design
Summary
11 Designing a Framebuffer Interface
How Video Memory Works
How Bytes in Video Memory are Interpreted
How Video Memory Is Mapped to the Display
The Linux Framebuffer Device Driver
Manipulating the Framebuffer with open, read, write, and close
Configuring the Framebuffer with the ioctl Command
A Simple Graphics Program for the Framebuffer
Graphics Libraries
“Hello, world!” with SDL
Initialize the Libraries
Initialize the Framebuffer
Create a Surface
Display the Surface
Handle Events
Graphical UI Toolkits
Building Simple UIs with STBmenu
“Hello, world!” with STBmenu
The Laddie Framebuffer UI
Summary
12 Infrared Remote Control
Communicating with Infrared Light
Protocols for Encoding Remote Control Commands
Reducing Interference by Modulating the Infrared Signal
Controlling an Appliance with Infrared Light
Hardware for Remote Control Receivers
Detecting and Demodulating the IR Signal
Decoding Remote Control Waveforms
Infrared Remote Control Hardware for the Laddie Appliance
Installing and Configuring LIRC for the Laddie Appliance
Installing the LIRC Software
Configuring the lirc_serial Kernel Device Driver
Testing the lirc_serial Driver
Configuring the lircd Daemon
Testing the lircd Daemon
LIRC Tools for Controlling Applications
Controlling the Laddie Appliance
Summary
13 Hands-on Introduction to SNMP
A Quick Note on Terminology
The Software
Installing SNMP
Download and Install
Check the Installation
Configure the Agent
Start the Agent
Exploring with SNMP
MIB Files for Readable Names
A Networked Printer
The snmptable Command
MIB-2: The TCP Connection Table
MIB-2: The UDP Table
MIB-2 Contents
Writing Values with SNMP
Setting sysContact
Setting sysName
SNMP Traps
Receiving Traps with snmptrapd
Traps That Carry Data: linkUp and linkDown
Summary
14 Designing an SNMP MIB
Our Goal
Your Enterprise Number
The MIB Files
LADDIE-GROUP-SMI
Creating the LAD-MIB
Module Definition
Version and Number of Zones
The Alarm Table
The Traps
Validating Your MIB
Summary
15 Implementing Your SNMP MIB
The Net-SNMP Agent
The MIB Skeleton: mib2c
The Header File: ladProject.h
The Code File: ladProject.c
Includes
The Base OID
MIB Objects Definitions
RTA Access Routines
The Initialization Routine
The Scalars
Reading the Alarm Table
Writing the Alarm Table
Makefile Revisited
Debugging
Traps
Summary
A RTA Reference
Overview of RTA
RTA Constants
Data Structures
API Subroutines
The dbcommand() Subroutine
The rta_add_table() Subroutine
The SQL_string() Subroutine
The rta_config_dir() Subroutine
The rta_save() Subroutine
The rta_load() Subroutine
SELECT and UPDATE Syntax
The SELECT Command
The UPDATE Command
Internal RTA Tables
The rta_tables Table
The rta_columns Table
Debug Configuration
Error Messages
SQL Request Errors
Internal Debug Messages
Callback Routines
Read Callbacks
Write Callbacks
B Review of SNMP
Why SNMP?
Agents and Managers
Namespace, Grammar, and Protocol
The MIB
The OID
MIB-2
The SMI
The SNMP Protocol
The Basic Commands: GET, SET, GETNEXT
Walking a MIB with GETNEXT
Traps and Informs
Command-Line Tools: Examples
SNMPv1, SNMPv2, and SNMPv3
SNMP Data Types
SNMP Tables
Defining New Types
Structure of a MIB File
Summary
C Installing a Framebuffer Device Driver
Finding Framebuffer Device Drivers for Your Video Card
The vesafb Driver
Hardware-Specific Drivers
Drivers Not Included on the Laddie CD
Configuring the Framebuffer Device Driver
The vesafb Driver
Hardware-Specific Drivers
D A DB-to-File Utility
Overview
Table Definitions
The tbl2file Table
The tbl2field Table
A tbl2filed Example
Security Notes
E The Laddie Appliance Bootable CD
Running the Laddie Appliance
Booting the CD
Navigating the Framebuffer User Interface
Accessing the Web Interface
Experimenting with the Linux Shell and Other User Interfaces
Shutting Down the Laddie Appliance
Exploring the CD Contents
Laddie Appliance Source Code
Laddie Appliance Libraries
Startup Scripts
The Linux From-Scratch Distribution and Additional Packages
Rebuilding the Laddie Appliance
Index
Updates

Linux Appliance Design: A Hands-on Guide to Building Linux Appliances
 9781593271404, 1593271409

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Recommend Papers