blob: 9a4e4bb36c26a02a93e4ad9c2d2349e85610bdea (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>anytun: signalController.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.1 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li id="current"><a href="files.html"><span>Files</span></a></li>
</ul></div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>File Members</span></a></li>
</ul></div>
<h1>signalController.h</h1><a href="signalController_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * anytun</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * The secure anycast tunneling protocol (satp) defines a protocol used</span>
<a name="l00005"></a>00005 <span class="comment"> * for communication between any combination of unicast and anycast</span>
<a name="l00006"></a>00006 <span class="comment"> * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel</span>
<a name="l00007"></a>00007 <span class="comment"> * mode and allows tunneling of every ETHER TYPE protocol (e.g.</span>
<a name="l00008"></a>00008 <span class="comment"> * ethernet, ip, arp ...). satp directly includes cryptography and</span>
<a name="l00009"></a>00009 <span class="comment"> * message authentication based on the methodes used by SRTP. It is</span>
<a name="l00010"></a>00010 <span class="comment"> * intended to deliver a generic, scaleable and secure solution for</span>
<a name="l00011"></a>00011 <span class="comment"> * tunneling and relaying of packets of any protocol.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * Copyright (C) 2007 anytun.org <satp@wirdorange.org></span>
<a name="l00015"></a>00015 <span class="comment"> *</span>
<a name="l00016"></a>00016 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00017"></a>00017 <span class="comment"> * it under the terms of the GNU General Public License version 2</span>
<a name="l00018"></a>00018 <span class="comment"> * as published by the Free Software Foundation.</span>
<a name="l00019"></a>00019 <span class="comment"> *</span>
<a name="l00020"></a>00020 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00021"></a>00021 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00022"></a>00022 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00023"></a>00023 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00024"></a>00024 <span class="comment"> *</span>
<a name="l00025"></a>00025 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00026"></a>00026 <span class="comment"> * along with this program (see the file COPYING included with this</span>
<a name="l00027"></a>00027 <span class="comment"> * distribution); if not, write to the Free Software Foundation, Inc.,</span>
<a name="l00028"></a>00028 <span class="comment"> * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00029"></a>00029 <span class="comment"> */</span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="preprocessor">#ifndef _SIGNAL_CONTROLLER_H_</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#define _SIGNAL_CONTROLLER_H_</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span>
<a name="l00034"></a>00034 <span class="preprocessor">#include <csignal></span>
<a name="l00035"></a>00035 <span class="preprocessor">#include <map></span>
<a name="l00036"></a>00036 <span class="preprocessor">#include <queue></span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="threadUtils_8hpp.html">threadUtils.hpp</a>"</span>
<a name="l00039"></a>00039
<a name="l00040"></a><a class="code" href="classSignalHandler.html">00040</a> <span class="keyword">class </span><a class="code" href="classSignalHandler.html">SignalHandler</a>
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042 <span class="keyword">public</span>:
<a name="l00043"></a><a class="code" href="classSignalHandler.html#a1109d38f8b43bde75420aaeecc1f2b7">00043</a> <span class="keyword">virtual</span> <a class="code" href="classSignalHandler.html#a1109d38f8b43bde75420aaeecc1f2b7">~SignalHandler</a>() {}
<a name="l00044"></a>00044
<a name="l00045"></a><a class="code" href="classSignalHandler.html#e3dbda0de9b4aa4544390818a0d29e28">00045</a> <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classSignalHandler.html#e3dbda0de9b4aa4544390818a0d29e28">handle</a>() { <span class="keywordflow">return</span> 0; }
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="keyword">protected</span>:
<a name="l00048"></a><a class="code" href="classSignalHandler.html#8f920534650e9cd3cdfbe3c3f8409b4d">00048</a> <a class="code" href="classSignalHandler.html#8f920534650e9cd3cdfbe3c3f8409b4d">SignalHandler</a>(<span class="keywordtype">int</span> s) : <a class="code" href="classSignalHandler.html#0585573af0ea6bebf37bda54e5c3c39d">sigNum</a>(s) {}
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="keyword">private</span>:
<a name="l00051"></a><a class="code" href="classSignalHandler.html#0585573af0ea6bebf37bda54e5c3c39d">00051</a> <span class="keywordtype">int</span> <a class="code" href="classSignalHandler.html#0585573af0ea6bebf37bda54e5c3c39d">sigNum</a>;
<a name="l00052"></a><a class="code" href="classSignalHandler.html#9b5c65d0274d45f20c9ed28852dd66fa">00052</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classSignalController.html">SignalController</a>;
<a name="l00053"></a>00053 };
<a name="l00054"></a>00054
<a name="l00055"></a><a class="code" href="classSigIntHandler.html">00055</a> <span class="keyword">class </span><a class="code" href="classSigIntHandler.html">SigIntHandler</a> : <span class="keyword">public</span> <a class="code" href="classSignalHandler.html">SignalHandler</a>
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057 <span class="keyword">public</span>:
<a name="l00058"></a><a class="code" href="classSigIntHandler.html#ac25b5ac048a76d4c0c26d5ad4c4273d">00058</a> <a class="code" href="classSigIntHandler.html#ac25b5ac048a76d4c0c26d5ad4c4273d">SigIntHandler</a>() : <a class="code" href="classSignalHandler.html">SignalHandler</a>(SIGINT) {}
<a name="l00059"></a>00059 <span class="keywordtype">int</span> <a class="code" href="classSigIntHandler.html#6a7d9a841a5c9b1f50041a8c37774063">handle</a>();
<a name="l00060"></a>00060 };
<a name="l00061"></a>00061
<a name="l00062"></a><a class="code" href="classSigQuitHandler.html">00062</a> <span class="keyword">class </span><a class="code" href="classSigQuitHandler.html">SigQuitHandler</a> : <span class="keyword">public</span> <a class="code" href="classSignalHandler.html">SignalHandler</a>
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064 <span class="keyword">public</span>:
<a name="l00065"></a><a class="code" href="classSigQuitHandler.html#45885e5ddfa14f9bfc13c72de425e1c6">00065</a> <a class="code" href="classSigQuitHandler.html#45885e5ddfa14f9bfc13c72de425e1c6">SigQuitHandler</a>() : <a class="code" href="classSignalHandler.html">SignalHandler</a>(SIGQUIT) {}
<a name="l00066"></a>00066 <span class="keywordtype">int</span> <a class="code" href="classSigQuitHandler.html#799f0272c91e7b1bf09411b80811b4dc">handle</a>();
<a name="l00067"></a>00067 };
<a name="l00068"></a>00068
<a name="l00069"></a><a class="code" href="classSigHupHandler.html">00069</a> <span class="keyword">class </span><a class="code" href="classSigHupHandler.html">SigHupHandler</a> : <span class="keyword">public</span> <a class="code" href="classSignalHandler.html">SignalHandler</a>
<a name="l00070"></a>00070 {
<a name="l00071"></a>00071 <span class="keyword">public</span>:
<a name="l00072"></a><a class="code" href="classSigHupHandler.html#a1ee03b63ca11d8b5aae82fae1f2d6a3">00072</a> <a class="code" href="classSigHupHandler.html#a1ee03b63ca11d8b5aae82fae1f2d6a3">SigHupHandler</a>() : <a class="code" href="classSignalHandler.html">SignalHandler</a>(SIGHUP) {}
<a name="l00073"></a>00073 <span class="keywordtype">int</span> <a class="code" href="classSigHupHandler.html#84734b7f79663badeedb720896302d4e">handle</a>();
<a name="l00074"></a>00074 };
<a name="l00075"></a>00075
<a name="l00076"></a><a class="code" href="classSigUsr1Handler.html">00076</a> <span class="keyword">class </span><a class="code" href="classSigUsr1Handler.html">SigUsr1Handler</a> : <span class="keyword">public</span> <a class="code" href="classSignalHandler.html">SignalHandler</a>
<a name="l00077"></a>00077 {
<a name="l00078"></a>00078 <span class="keyword">public</span>:
<a name="l00079"></a><a class="code" href="classSigUsr1Handler.html#aabaa57b0f2bb331a85f95cf90dd121d">00079</a> <a class="code" href="classSigUsr1Handler.html#aabaa57b0f2bb331a85f95cf90dd121d">SigUsr1Handler</a>() : <a class="code" href="classSignalHandler.html">SignalHandler</a>(SIGUSR1) {}
<a name="l00080"></a>00080 <span class="keywordtype">int</span> <a class="code" href="classSigUsr1Handler.html#578f3ea18e617689032fc165b6436695">handle</a>();
<a name="l00081"></a>00081 };
<a name="l00082"></a>00082
<a name="l00083"></a><a class="code" href="classSigUsr2Handler.html">00083</a> <span class="keyword">class </span><a class="code" href="classSigUsr2Handler.html">SigUsr2Handler</a> : <span class="keyword">public</span> <a class="code" href="classSignalHandler.html">SignalHandler</a>
<a name="l00084"></a>00084 {
<a name="l00085"></a>00085 <span class="keyword">public</span>:
<a name="l00086"></a><a class="code" href="classSigUsr2Handler.html#30478acdc28555b412d80f1419af622a">00086</a> <a class="code" href="classSigUsr2Handler.html#30478acdc28555b412d80f1419af622a">SigUsr2Handler</a>() : <a class="code" href="classSignalHandler.html">SignalHandler</a>(SIGUSR2) {}
<a name="l00087"></a>00087 <span class="keywordtype">int</span> <a class="code" href="classSigUsr2Handler.html#825a621f1ff10556bb8b289703273e7d">handle</a>();
<a name="l00088"></a>00088 };
<a name="l00089"></a>00089
<a name="l00090"></a><a class="code" href="classSigTermHandler.html">00090</a> <span class="keyword">class </span><a class="code" href="classSigTermHandler.html">SigTermHandler</a> : <span class="keyword">public</span> <a class="code" href="classSignalHandler.html">SignalHandler</a>
<a name="l00091"></a>00091 {
<a name="l00092"></a>00092 <span class="keyword">public</span>:
<a name="l00093"></a><a class="code" href="classSigTermHandler.html#8f6c3da13e1ec7fc8ef122bd0db457e4">00093</a> <a class="code" href="classSigTermHandler.html#8f6c3da13e1ec7fc8ef122bd0db457e4">SigTermHandler</a>() : <a class="code" href="classSignalHandler.html">SignalHandler</a>(SIGTERM) {}
<a name="l00094"></a>00094 <span class="keywordtype">int</span> <a class="code" href="classSigTermHandler.html#820fa7f8bb5ef6390133c33c919dbf6f">handle</a>();
<a name="l00095"></a>00095 };
<a name="l00096"></a>00096
<a name="l00097"></a><a class="code" href="classSignalController.html">00097</a> <span class="keyword">class </span><a class="code" href="classSignalController.html">SignalController</a>
<a name="l00098"></a>00098 {
<a name="l00099"></a>00099 <span class="keyword">public</span>:
<a name="l00100"></a><a class="code" href="classSignalController.html#d057c96011d444cce15e2a398a0a8bbf">00100</a> <a class="code" href="classSignalController.html#d057c96011d444cce15e2a398a0a8bbf">SignalController</a>() {}
<a name="l00101"></a>00101 <a class="code" href="classSignalController.html#e8d687dc4fcc75bffff50e8cda37c7aa">~SignalController</a>();
<a name="l00102"></a>00102 <span class="keyword">static</span> <span class="keywordtype">void</span>* <a class="code" href="classSignalController.html#5df4d6ebe373117a9bf072035e16997f">handle</a>(<span class="keywordtype">void</span>* s);
<a name="l00103"></a>00103
<a name="l00104"></a>00104 <span class="keywordtype">void</span> <a class="code" href="classSignalController.html#0d66065172b1c7ac0d55757d178e6911">init</a>();
<a name="l00105"></a>00105 <span class="keywordtype">int</span> <a class="code" href="classSignalController.html#0f7657b70cb2e8457539d9f844a93619">run</a>();
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <span class="keyword">private</span>:
<a name="l00108"></a><a class="code" href="classSignalController.html#659eb661ef3d40565d739a50bbe4b554">00108</a> <span class="keyword">typedef</span> std::map<int, SignalHandler*> <a class="code" href="classSignalController.html#659eb661ef3d40565d739a50bbe4b554">HandlerMap</a>;
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <a class="code" href="classSignalController.html#d057c96011d444cce15e2a398a0a8bbf">SignalController</a>(<span class="keyword">const</span> <a class="code" href="classSignalController.html">SignalController</a> &s);
<a name="l00111"></a>00111 <span class="keywordtype">void</span> <a class="code" href="classSignalController.html#7bfe78f3e8c5d40ddd51c313d30cf6a2">operator=</a>(<span class="keyword">const</span> <a class="code" href="classSignalController.html">SignalController</a> &s);
<a name="l00112"></a>00112
<a name="l00113"></a><a class="code" href="classSignalController.html#543fa6d49a071df92cdfcc7bc96de161">00113</a> std::queue<int> <a class="code" href="classSignalController.html#543fa6d49a071df92cdfcc7bc96de161">sigQueue</a>;
<a name="l00114"></a><a class="code" href="classSignalController.html#6b7853059aa422fac6c2cc77e00d28ee">00114</a> <a class="code" href="classMutex.html">Mutex</a> <a class="code" href="classSignalController.html#6b7853059aa422fac6c2cc77e00d28ee">sigQueueMutex</a>;
<a name="l00115"></a><a class="code" href="classSignalController.html#4dfee82061341e1af5ca827333c8bd10">00115</a> <a class="code" href="classSemaphore.html">Semaphore</a> <a class="code" href="classSignalController.html#4dfee82061341e1af5ca827333c8bd10">sigQueueSem</a>;
<a name="l00116"></a>00116
<a name="l00117"></a><a class="code" href="classSignalController.html#79c5fbfa55aa9edc2a45c5ed3197b782">00117</a> pthread_t <a class="code" href="classSignalController.html#79c5fbfa55aa9edc2a45c5ed3197b782">thread</a>;
<a name="l00118"></a><a class="code" href="classSignalController.html#f76d2f570d55019dd15921eba71efe0b">00118</a> <a class="code" href="classSignalController.html#659eb661ef3d40565d739a50bbe4b554">HandlerMap</a> <a class="code" href="classSignalController.html#f76d2f570d55019dd15921eba71efe0b">handler</a>;
<a name="l00119"></a>00119 };
<a name="l00120"></a>00120
<a name="l00121"></a>00121 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Oct 7 23:43:49 2007 for anytun by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address>
</body>
</html>
|