set keyword svn property on more files
[senf.git] / Mainpage.dox
1 // $Id$
2 //
3 // Copyright (C) 2007 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS) 
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY 
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \mainpage SENF: The Simple and Extensible Network Framework
24
25     The SENF Simple and Extensible Network Framework aims to be a complete set of libraries to
26     facilitate the development of network applications focusing on network protocols on the layers
27     below the application layer. However, the framework includes many general purpose utilities and
28     will be expedient to use well beyond its primary objective.
29
30     \section Goals
31
32     The main goals of this library are (in no particular order):
33
34     \li modular framework design
35     \li utilizing the power of modern C++
36     \li very low overhead for frequently called members
37     \li extensible design
38     \li concise interface
39
40     \section start Getting started
41
42     To get started using this library, begin by checking out the code from the <a
43     href="http://developer.berlios.de/svn/?group_id=7489">BerliOS SVN repository</a>. You may find
44     help on using the library at '\ref senf_usage'. If you are interested in SENF, feel free to subscribe
45     to the <a href="http://developer.berlios.de/mail/?group_id=7489">SENF mailing lists</a>. If you
46     want to contribute, read the docs and \e please adhere to the \ref senf_conventions.
47
48     \see \ref senf_usage\n
49          <a href="../../Examples/doc/html/index.html">Examples</a>
50 */
51
52 /** \page senf_usage Using the SENF framework
53
54     The SENF Framework is a collection of loosely coupled modules. The libraries are heavily object
55     oriented and template based. For compatibility reasons, the libraries are therefore built
56     together with every project making use of the framework.
57
58     When starting a new project based on the SENF framework, it is advisable, to make use of the
59     SENFSCons build environment and use SVN to manage the code repository. This is the
60     configuration, described in this documentation.
61
62     \see \ref senf_build \n
63          \ref senf_components \n
64          \ref senf_svnsetup \n
65          \ref senf_overview
66
67     \section senf_preliminaries Preliminaries
68
69     Before starting the development, make sure to fulfill the following requirements:
70
71     \li GNU g++, version at least 3.4
72     \li The Boost libraries (http://www.boost.org)
73     \li The SCons build tool (http://www.scons.org)
74
75     If you want to build the documentation, you additionally need
76
77     \li Doxygen (http://www.doxygen.org)
78     \li The \c dia diagram editor (http://www.gnome.org/projects/dia/)
79     \li HTML \c tidy (http://tidy.sourceforge.net/)
80     \li The \c xsltproc XSLT processor (http://xmlsoft.org/XSLT/xsltproc2.html)
81     \li The \c graphviz library (http://www.graphviz.org)
82
83
84     The library is only tested with gcc-3.4 and 4.0 on Linux. On other POSIX platforms with a BSD
85     Socket API, the library should be usable, possibly with some tweaking (except for the Scheduler,
86     which relies on \c epoll)
87  */
88
89 /** \page senf_build Building the framework
90
91     This procedure will test building the complete framework including the unit tests and the
92     Sniffer test application. This build is \e not needed to use the framework since every project
93     will include the full SENF source code itself (via Subversion).
94
95     After you have successfully built the library tests, you can continue to setup your own project
96     using SENF.
97
98     \see \ref senf_components \n
99          \ref senf_svnsetup
100
101     \section senf_checkout Getting the code
102
103     To access the code, check out the code from the BerliOS repository. Change to your development
104     directory and use the following subversion command
105
106     <pre>
107     $ svn checkout http://svn.berlios.de/svnroot/repos/senf/trunk senf
108     </pre>
109
110     This will create a new directory \c senf within the current directory. For further documentation
111     on the use of Subversion, see the \c svn manpage or the subversion homepage at
112     http://subversion.tigris.org. A very good introduction and reference to subversion is available
113     at http://svnbook.red-bean.com.
114
115     \section senf_compile Building
116
117     To build the library, execute all unit tests and build the Sniffer test application, use
118
119     <pre>
120     $ scons
121     $ scons all_tests
122     </pre>
123
124     in the \c senf directory. This assumes, that you want to build the library with your default gcc
125     and requires the boost libraries to be available in the system include paths. If this is not the
126     case, you can take a look at <tt>SConfig.template</tt> file. Copy this file to <tt>SConfig</tt>
127     and comment out all the variables you don't want to change (The \e values in the template file
128     are just arbitrary examples).
129  */
130
131 /** \page senf_components The SENF modules
132
133     The framework is made up of several modular components. When using the library, it is possible
134     to selectively choose to use only a subset of the implemented modules.
135
136     \see \ref senf_build \n
137          \ref senf_svnsetup
138
139     \section libPPI libPPI: Packet Processing Infrastructure
140
141     The Packet Processing Infrastructure implements a modular framework for implementing packet
142     oriented network applications. The library provides a larget set of pre-defined modules as well
143     as the necessary helpers to implement application specific processing modules.
144
145     \see <a href="../../PPI/doc/html/index.html">libPPI API reference</a>
146
147     \section libSocket libSocket: C++ abstraction of the BSD socket API
148
149     This library provides a high performance and object oriented abstraction of the standard socket
150     API. It utilizes a flexible and extensible policy based design. The library provides predefined
151     types for the important socket types (UDP and TCP sockets etc) including raw and packet sockets.
152
153     \see <a href="../../Socket/doc/html/index.html">libSocket API reference</a>
154
155     \section libPackets libPackets: Network packet manipulation
156
157     This library provides a very flexible infrastructure to parse, create and otherwise manipulate
158     packetized network data. Included is a library of several protocol parsers covering the basic
159     IPv4 and IPv6 network protocols down to the Ethernet layer.
160
161     \see <a href="../../Packets/doc/html/index.html">libPackets API reference</a>
162
163     \section libScheduler libScheduler: Asynchronous event handling
164
165     The scheduler library provides an object oriented interface to the standard UNIX \c select type
166     event dispatcher. It is based on the high performance \c epoll system call. It provides support
167     for read/write events as well as simple timer based events.
168
169     \see <a href="../../Scheduler/doc/html/index.html">libScheduler API reference</a>
170
171     \section libUtils libUtils: Collection of arbitrary utilities
172
173     This library is used be most all of the other modules for miscellaneous tools and utilities. We
174     have
175
176     \li Simple functions to manage daemon processes
177     \li Standard exception classes
178     \li senf::intrusive_refcount to simplify the implementation of classes usable with
179         boost::intrusive_ptr
180     \li boost::bind extensions
181     \li An interface to the \c g++ demangler integrated with type_info
182     \li Typedefs and rudimentary methods to simplify handling high-resolution time values
183
184     \see <a href="../../Utils/doc/html/index.html">libUtils API reference</a>
185
186     \section senfscons SENFSCons, the SENF build environment
187
188     SENF relies on SCons (http://www.scons.org) to build. To further simplify the common tasks, SENF
189     includes a library of custom routines and builders comprising a very concise build
190     environment. Included are a number of templates to help bootstrapping a new project or
191     component.
192
193     \see <a href="../../senfscons/doc/html/index.html">SENFSCons reference</a>
194  */
195
196 /** \page senf_svnsetup Setting up a new project using SENF
197
198     The preferred way to use SENF in a new project is to rely on Subversion and make use of the
199     SENFSCons build environment. The following sections will describe, how this setup works.
200
201     \see \ref senf_build \n
202          \ref senf_components \n
203          \ref senf_overview
204
205     \section svnext Setting up the project repository
206
207     The most seamless integration is possible if you rely on Subversion to manage the new
208     project. Subversion does support 'external repositories'. This allows to import code from a
209     foreign repository into the checkout without importing it into your repository. The code will
210     always stay at the remote repository, updates are automatically available.
211
212     First setup a new empty repository as described for example in the Subversion book at
213     http://svnbook.red-bean.com or as mandated by your site policy. We will call the project 'Foo'
214     and assume, that the project has been checked out into the 'Foo' directory.
215
216     You now have to decide, which modules you want to use. Every module resides in it's own
217     subdirectory in the SENF repository. Instead of directly checking out the code, we will use \c
218     svn:externals. This will instruct \c svn to automatically check out the needed directories from
219     the BerliOS SENF repository. Change to the 'Foo' directory and type
220
221     <pre>
222     $ svn propedit svn:externals .
223     </pre>
224
225     The default editor (probably VI) will be started with the current value of the svn:externals
226     property (which will probably be empty). Now add all the modules you want plus \c senfscons and
227     possibly \c doclib (if you want to build the documentation). You will almost certainly need the
228     \c Utils module, since all other modules depend on it.
229
230     For example, if you want to use the \c Scheduler and \c Socket module, the file will look like
231
232     <pre>
233     senfscons http://svn.berlios.de/svnroot/repos/senf/trunk/senfscons
234     Utils http://svn.berlios.de/svnroot/repos/senf/trunk/Utils
235     Scheduler http://svn.berlios.de/svnroot/repos/senf/trunk/Scheduler
236     Socket http://svn.berlios.de/svnroot/repos/senf/trunk/Socket
237     </pre>
238
239     exit the editor and the property will be set. Now run
240
241     <pre>
242     $ svn update
243     </pre>
244
245     and the code will be checked out into the corresponding directories.
246
247     \section senf_new_conf Configuring SENFSCons
248
249     To set up the build environment, copy the <tt>senfscons/SConstruct.template</tt> to
250     <tt>SConstruct</tt> in the project root. The default setup of this file is to build all
251     subdirectories (using the \c SConscript files of the subdirectories). You can add additional
252     global targets and configuration parameters here.
253
254     If you want to use a non-default compiler or the boost library is not installed in the system
255     directories, you will have to copy <tt>senfscons/SConfig.template</tt> to <tt>SConfig</tt> in
256     the project root and edit it there. You should \e never add \c SConfig to the repository since
257     it should only contain local settings necessary for building on your local system. You should
258     therefore add \c SConfig to the list of files ignored by Subversion in the project root. In the
259     project root execute
260
261     <pre>
262     $ svn propedit svn:ignore .
263     </pre>
264
265     and add \c SConfig as a new line to the property.
266
267     \section new_build Building the project
268
269     You should now be able to build your project using
270
271     <pre>
272     $ scons
273     </pre>
274
275     If you have not changed the \c SConstruct file, this will build all modules you have imported
276     into your project. To build and execute the unit tests, use
277
278     <pre>
279     $ scons all_tests
280     </pre>
281
282     you can also build only a subdirectory by changing to it and running
283
284     <pre>
285     $ scons -u [target]
286     </pre>
287
288     \see <a href="../../senfscons/doc/html/index.html">SENFSCons reference</a> \n
289          <a href="http://www.scons.org/documentation.php">SCons documentation</a> \n
290          <a href="http://svnbook.red-bean.com">Subversion online book</a> \n
291          <a href="http://subversion.tigris.org">Subversion Homepage</a>
292  */
293
294 /** \page senf_overview Introduction to the framework
295
296     The SENF framework is relatively complex and makes use of advanced features of the C++
297     language. To make the most efficient use of the framework, you should have at least a basic
298     understanding of C++ templates and the standard library concepts.
299
300     The library implementation at places makes heavy use of advanced template techniques and relies
301     on some very advanced template libraries from Boost. The aim was however for the \e external
302     interface of the library to be as simple as possible without sacrificing important functionality
303     or adversely impacting the runtime performance.
304
305     As already mentioned several times, the library relies on Boost (http://www.boost.org) as a
306     generic library of high quality reusable C++ components. It also makes frequent use of the
307     standard library. It is designed, to integrate well into both libraries and to use the same
308     concepts and ideas.
309
310     \section senf_startup Getting starting developing with SENF
311
312     To introduce the framework and it's general structure, a simple example application is provided
313     in the SENF repository in the \c Sniffer module. Peruse this example to get a first look at how
314     to make use of SENF.
315
316     When building a network Application with SENF, you will use several modules:
317
318     \li Use the <a href="../../Socket/doc/html/index.html">Socket library</a> for network
319         communication needs. This library includes support for raw and packet sockets to allow low
320         level network access.
321     \li Use the <a href="../../Scheduler/doc/html/index.html">Scheduler library</a> to coordinate
322         the asynchronous event processing. This drastically reduces the number of threads needed in
323         your application and will greatly enhance the overall responsiveness.
324     \li To interpret low level network packets, use the <a
325         href="../../Packets/doc/html/index.html">Packets library</a>. This library will provide
326         efficient and convenient access to all protocol fields. It supports parsing as well as
327         modifying and creating packets. It has default support for the most important internet
328         protocols and is highly extensible with new protocols.
329     \li Go over the <a href="../../Utils/doc/html/index.html">Utils library</a>. It contains small
330         helpers to simplify tasks like daemonization, exception handling, debugging and so on.
331
332     The simplest way to get started is: copy the Sniffer application and start to modify it.
333
334     \see <a href="../../Examples/doc/html/index.html">Examples</a> \n
335          \ref senf_components \n
336          \ref senf_svnsetup \n
337          \ref senf_build
338
339     \section senf_conventions Coding Conventions
340     
341     Here we have laid down the coding conventions used throughout the SENF framework. Please ad here
342     to these conventions when changing or adding code. If you use emacs, you can use the C++ IDE for
343     emacs from http://g0dil.de which greatly simplifies following these conventions.
344
345     \subsection senf_conventions_file_naming File Naming
346
347     Files should be named according to the main class they define. A single header file should
348     define only one main class. Exceptions to this rule are OK.
349
350     \par Rationale:
351         This simplifies finding the implementation/header for a given class and also reduces the
352         size of each single file.
353     
354     The implementation is divided into a number of different files:
355
356     <table class="glossary"> <tr><td>\c .h</td><td>C public header</td></tr>
357
358     <tr><td>\c .hh</td><td>C++ public header</td></tr>
359
360     <tr><td>\c .ih</td><td>C++ internal header used only by the implementation. This header will
361     probably be included indirectly by the public header but is not meant to be perused by the
362     library user</td></tr>
363
364     <tr><td>\c .c</td><td>C implementation</td></tr>
365
366     <tr><td>\c .cc</td><td>C++ implementation of non-inline non-template functions and
367     members</td></tr>
368
369     <tr><td>\c .ct</td><td>C++ implementation of non-inline template functions and members</td></tr>
370
371     <tr><td>\c .cci</td><td>C++ implementation of inline non-template functions and
372     members</td></tr>
373     
374     <tr><td>\c .cti</td><td>C++ implementation of inline template functions and members</td></tr>
375
376     <tr><td>\c .mpp</td><td>Special include file used for external iteration by the
377     Boost.Preprocessor library</td></tr> </table>
378
379     \par Rationale:
380         There are two part's to this: First, separating the implementation of inlines and templates
381         out of the header file makes the header file much easier to read. This is important, since
382         the header file will be used as a reference by the developers.
383     \par
384         Separating inline from non-inline members is used together with the \c prefix_ convention
385         below to ensure the correct placement of inline vs non-inline members in the source
386         code. The C++ language requires, that inline members must be included into \e every
387         compilation unit, non-inline members however must be included \e only in one compilation
388         unit. Placing the inline members into a separate file allows to automate this: Simply moving
389         an implementation from one of the inline files into one of the non-inline files will change
390         the type of implementation accordingly.
391
392     \subsection senf_conventions_type_naming Type Naming
393
394     SENF prefers the use of the CapitalziedLettersToSeparateWords convention for class names. In
395     this case, class names must start with a capital letter. There are some exceptions to this rule:
396     Types which define new basic data types to be used like other built-in types may be named using
397     lowercase letters plus underscores. Also, if a type or class is directly related to some other
398     library (STL or Boost) which uses the underscore convention, it might be more sensible to follow
399     this convention. This is open to debate.
400
401     \par Rationale:
402         Naming types with capital letters nicely gives a visual clue, that a symbol is a type
403         name. This can also be used by the editor to highlight type names correctly. Additionally,
404         this convention is compact and does not add additional or repeated overhead.
405
406     \subsection senf_conventions_impl Implementation
407
408     Only in very few places, SENF allows the use of inline implementations (not to be confused with
409     inline functions). An \e implementation is inline, if it is written directly into the class
410     definition in the header file. Again there are exceptions to this rule but they are very few:
411     \li When defining simple exception classes, the 'what()' member may be defined inline if it
412         returns a string constant.
413     \li It may be OK to use inline implementations for one-line implementations in internal
414         headers. 
415     \li The Packet library allows inline implementations for the definition of parsers since doing
416         so outside the declaration just gets to verbose and parsers definitions are quite length but
417         very simple and straight forward.
418
419     \par Rationale:
420         Implementing members inline inside the class declaration makes the declaration much harder
421         to read. Since the declaration in the header file will be used as a reference by the
422         developer, the header files should be as readable as possible.
423
424     Every function or method implementation in one of the implementation files must \e always be
425     prefixed with \c prefix_. This symbol is defined at the beginning of the file and undefined at
426     the end. The symbol must be defined to be \c inline in the \c .cti and \c .cci files and must be
427     defined empty in the \c .cc and \c .ct files.
428
429     \par Rationale:
430         Together with splitting inlines and non-inlines into separate files, this allows to
431         automatically include the inline definitions at the right places. See above.
432
433     Private data members are named with a trailing underscore character.
434
435     \par Rationale:
436         This helps distinguishing local variables from parameter names. The trailing underscore
437         does not interfere with other naming conventions and is allowed by the standard (underscore
438         at the beginning of the name are problematic since some classes of names beginning with an
439         underscore are reserved for the standard library implementation)
440  */
441
442 \f
443 // Local Variables:
444 // mode: c++
445 // fill-column: 100
446 // c-file-style: "senf"
447 // indent-tabs-mode: nil
448 // ispell-local-dictionary: "american"
449 // mode: flyspell
450 // mode: auto-fill
451 // End: