Copyright update for 2011
[bcusdk.git] / eibd / libserver / layer3.h
blob447d61c7c61a3ac5f685651685fd5880d64d7c7a
1 /*
2 EIBD eib bus access and management daemon
3 Copyright (C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef LAYER3_H
21 #define LAYER3_H
23 #include "layer2.h"
25 /** stores a registered busmonitor callback */
26 typedef struct
28 L_Busmonitor_CallBack *cb;
29 } Busmonitor_Info;
31 /** stores a registered broadcast callback */
32 typedef struct
34 L_Data_CallBack *cb;
35 } Broadcast_Info;
37 /** stores a registered group callback */
38 typedef struct
40 L_Data_CallBack *cb;
41 /** group address, for which the frames should be delivered */
42 eibaddr_t dest;
43 } Group_Info;
45 typedef enum
47 /** perform no locking */
48 Individual_Lock_None,
49 /** pervent other connections of Individual_Lock_Connection */
50 Individual_Lock_Connection
51 } Individual_Lock;
53 /** stores a registered individual callback */
54 typedef struct
56 L_Data_CallBack *cb;
57 /** source address, from which the frames should be delivered */
58 eibaddr_t src;
59 /** destiation address, for which the frames should be delivered */
60 eibaddr_t dest;
61 /** lock of the connection */
62 Individual_Lock lock;
63 } Individual_Info;
65 typedef struct
67 CArray data;
68 timestamp_t end;
70 } IgnoreInfo;
72 /** Layer 3 frame dispatches */
73 class Layer3:private Thread
75 /** Layer 2 interface */
76 Layer2Interface *layer2;
77 /** debug output */
78 Trace *t;
79 /** working mode (bus monitor/normal operation) */
80 int mode;
81 Array < IgnoreInfo > ignore;
83 /** busmonitor callbacks */
84 Array < Busmonitor_Info > busmonitor;
85 /** vbusmonitor callbacks */
86 Array < Busmonitor_Info > vbusmonitor;
87 /** broadcast callbacks */
88 Array < Broadcast_Info > broadcast;
89 /** group callbacks */
90 Array < Group_Info > group;
91 /** individual callbacks */
92 Array < Individual_Info > individual;
94 void Run (pth_sem_t * stop);
95 public:
96 Layer3 (Layer2Interface * l2, Trace * tr);
97 virtual ~ Layer3 ();
99 /** register a busmonitor callback, return true, if successful*/
100 bool registerBusmonitor (L_Busmonitor_CallBack * c);
101 /** register a vbusmonitor callback, return true, if successful*/
102 bool registerVBusmonitor (L_Busmonitor_CallBack * c);
103 /** register a broadcast callback, return true, if successful*/
104 bool registerBroadcastCallBack (L_Data_CallBack * c);
105 /** register a group callback, return true, if successful
106 * @param c callback
107 * @param addr group address (0 means all)
109 bool registerGroupCallBack (L_Data_CallBack * c, eibaddr_t addr);
110 /** register a individual callback, return true, if successful
111 * @param c callback
112 * @param src source individual address (0 means all)
113 * @param dest destination individual address (0 means default address)
114 * @param lock Locktype of the connection
116 bool registerIndividualCallBack (L_Data_CallBack * c, Individual_Lock lock,
117 eibaddr_t src, eibaddr_t dest = 0);
119 /** deregister a busmonitor callback, return true, if successful*/
120 bool deregisterBusmonitor (L_Busmonitor_CallBack * c);
121 /** deregister a vbusmonitor callback, return true, if successful*/
122 bool deregisterVBusmonitor (L_Busmonitor_CallBack * c);
123 /** register a broadcast callback, return true, if successful*/
124 bool deregisterBroadcastCallBack (L_Data_CallBack * c);
125 /** deregister a group callback, return true, if successful
126 * @param c callback
127 * @param addr group address (0 means all)
129 bool deregisterGroupCallBack (L_Data_CallBack * c, eibaddr_t addr);
130 /** register a individual callback, return true, if successful
131 * @param c callback
132 * @param src source individual address (0 means all)
133 * @param dest destination individual address (0 means default address)
135 bool deregisterIndividualCallBack (L_Data_CallBack * c, eibaddr_t src,
136 eibaddr_t dest = 0);
137 /** sends a L_Data frame asynchronouse */
138 void send_L_Data (L_Data_PDU * l);
142 #endif