No Starch Press, Inc
Total Page:16
File Type:pdf, Size:1020Kb
A REAL-WORLD Companion CD includes a prototype G U I D E T O appliance—a home BUILDING LINUX LINUXLINUX APPLIANCEAPPLIANCE alarm system—that supports APPLIANCES the book’s lessons. APPLIANCES CD Inside DESIGNDESIGN A HANDS-ON GUIDE T O BUILDING LINUX APPLIANCES Modern appliances are complex machines with Learn to: processors, operating systems, and application software. LINUX APPLIANCE DESIGN • Separate your user interfaces from your daemons LINUX APPLIANCE DESIGN While there are books that will tell you how to run Linux BOB SMITH, JOHN HARDIN, GRAHAM PHILLIPS, AND BILL PIERCE on embedded hardware, and books on how to build • Give user interfaces run time access to configuration, a Linux application, Linux Appliance Design is the first status, and statistics book to demonstrate how to merge the two and create • Add professional network management capabilities to a Linux appliance. You’ll see for yourself why Linux is your application the embedded operating system of choice for low-cost development and a fast time to market. • Use SNMP and build a MIB Linux Appliance Design shows how to build better • Build a web-based appliance interface appliances—appliances with more types of interfaces, • Build a command line interface (CLI) more dynamic interfaces, and better debugged inter- faces. You’ll learn how to build backend daemons, • Build a framebuffer interface with an infrared control handle asynchronous events, and connect various user as input interfaces (including web, framebuffers, infrared control, • Manage logs and alarms on an appliance SNMP, and front panels) to these processes for remote configuration and control. Linux Appliance Design ABOUT THE AUTHORS also introduces the Run-Time Access library, which Bob Smith, John Hardin, Graham Phillips, and Bill Pierce provides a uniform mechanism for user interfaces to have experience in embedded systems, commercial Linux communicate with daemons. and BSD appliances, network management systems, and designing software solutions for business problems. PHILIPS, AND HARDIN, PIERCE SMITH, THE FINEST IN GEEK ENTERTAINMENT ™ $59.95 ($74.95 CDN) OPERATING SYSTEMS/LINUX SHELVE IN: www.nostarch.com ® “I LAY FLAT.” ® This book uses RepKover —a durable binding that won’t snap shut. ® LINUX APPLIANCE DESIGN LINUX APPLIANCE DESIGN A Hands-On Guide to Building Linux Appliances by Bob Smith, John Hardin, Graham Phillips, and Bill Pierce ® San Francisco lad_TITLE_COPY.fm Page iv Thursday, March 15, 2007 2:38 PM LINUX APPLIANCE DESIGN. Copyright © 2007 by Bob Smith, John Hardin, Graham Phillips, and Bill Pierce. All “Tux’s Workshop” illustrations © 2006 by Jon Colton. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. Printed on recycled paper in the United States of America 11 10 09 08 07 1 2 3 4 5 6 7 8 9 ISBN-10: 1-59327-140-9 ISBN-13: 978-1-59327-140-4 Publisher: William Pollock Production Editor: Elizabeth Campbell Cover and Interior Design: Octopod Studios Developmental Editor: William Pollock Technical Reviewer: Bob Lynch Copyeditor: Megan Dunchak Compositor: Riley Hoffman Proofreader: Publication Services, Inc. Indexer: Publication Services, Inc. For information on book distributors or translations, please contact No Starch Press, Inc. directly: No Starch Press, Inc. 555 De Haro Street, Suite 250, San Francisco, CA 94107 phone: 415.863.9900; fax: 415.863.9950; [email protected]; www.nostarch.com Library of Congress Cataloging-in-Publication Data Linux appliance design : a hands-on guide to building linux appliances / Bob Smith ... [et al.]. p. cm. Includes index. ISBN-13: 978-1-59327-140-4 ISBN-10: 1-59327-140-9 1. Linux. 2. Application software--Development. 3. Electric apparatus and appliances--Design and construction. I. Smith, Robert W. (Robert William), 1952- QA76.76.O63L545115 2007 005.3--dc22 2006020778 No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in it. BRIEF CONTENTS Acknowledgments ..........................................................................................................xv Introduction .................................................................................................................xvii Chapter 1: Appliance Architecture ....................................................................................1 Chapter 2: Managing Daemons........................................................................................7 Chapter 3: Using Run-Time Access ..................................................................................19 Chapter 4: Building and Securing Daemons .....................................................................43 Chapter 5: The Laddie Alarm System: A Sample Appliance................................................61 Chapter 6: Logging .......................................................................................................77 Chapter 7: Laddie Event Handling...................................................................................91 Chapter 8: Designing a Web Interface ..........................................................................105 Chapter 9: Designing a Command Line Interface ............................................................135 Chapter 10: Building a Front Panel Interface ..................................................................147 Chapter 11: Designing a Framebuffer Interface...............................................................169 Chapter 12: Infrared Remote Control.............................................................................197 Chapter 13: Hands-on Introduction to SNMP..................................................................223 Chapter 14: Designing an SNMP MIB ...........................................................................243 Chapter 15: Implementing Your SNMP MIB....................................................................261 Appendix A: RTA Reference .........................................................................................289 Appendix B: Review of SNMP ......................................................................................309 Appendix C: Installing a Framebuffer Device Driver.........................................................325 Appendix D: A DB-to-File Utility.....................................................................................331 Appendix E: The Laddie Appliance Bootable CD ............................................................337 Index .........................................................................................................................345 vi Brief Contents CONTENTS IN DETAIL ACKNOWLEDGMENTS xv INTRODUCTION xvii What This Book Is About ........................................................................................xviii What This Book Is Not About ..................................................................................xviii Who Should Read This Book ................................................................................... xix Why Use Linux? ..................................................................................................... xix Availability of Source Code ........................................................................ xix Range of Hardware Supported .................................................................. xix Availability of Linux Developers .................................................................. xix Reliability .................................................................................................. xx Quality Compilers ...................................................................................... xx Good Documentation ................................................................................. xx Existing Software Packages ......................................................................... xx Low Development Cost ................................................................................ xx No Licensing Fees for Deployment ................................................................ xx Security .................................................................................................... xxi Linux Appliance Design ........................................................................................... xxi 1 APPLIANCE ARCHITECTURE 1 UIs and Daemons ..................................................................................................... 2 Daemons .................................................................................................... 2 User Interfaces ...........................................................................................