This commit was manufactured by cvs2svn to create branch 'decode'.
[gnokii.git] / Docs / developers / other / sniffs / irda / tools / include / irlap.h
1 /*********************************************************************
2  *
3  * Filename:      irlap.h
4  * Version:
5  * Description:   in this file you can only find define´s for parts
6  *                of the irlap-layer. If you want read the typedef´s
7  *                for struct´s look into irda.h
8  * Status:        Experimental.
9  * Author:        Thomas Schneider <nok-trace-men@dev-thomynet.de>
10  * Created at:    
11  * Modified at:   
12  * Modified by:   Thomas Schneider <nok-trace-men@dev-thomynet.de>
13  *
14  *     Copyright (c) 1999 Thomas Schneider, All Rights Reserved.
15  *
16  *     This program is free software; you can redistribute it and/or
17  *     modify it under the terms of the GNU General Public License as
18  *     published by the Free Software Foundation; either version 2 of
19  *     the License, or (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24  * General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software 
28  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29  *
30  * IN NO EVENT SHALL THOMAS SCHNEIDER BE LIABLE TO ANY PARTY FOR
31  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 
32  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
33  * IF THOMAS SCHNEIDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 
34  * DAMAGE.
35  *
36  * THOMAS SCHNEIDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
37  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
38  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER
39  * IS ON AN "AS IS" BASIS, AND THOMAS SCHNEIDER HAS NO OBLIGATION TO 
40  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR 
41  * MODIFICATIONS.
42  *
43  *         This material is provided "AS-IS" and at no charge.
44  *
45  ********************************************************************/
46 /*
47  * in this file you can only find define´s for parts
48  * of the irlap-layer. If you want read the typedef´s
49  * for struct´s look into irda.h
50  */
51
52 #ifndef __IRLAP_H
53 #define __IRLAP_H
54
55 #include <glib.h>
56
57
58 #define IRDA_XBOF 0xFF
59 #define IRDA_BOF  0xC0
60 #define IRDA_EOF  0xC1
61
62 /*
63  * IrLAP-OFFSETS
64  * -------------
65  */
66 #define IRLAP_A_OFF 0x00
67 #define IRLAP_C_OFF 0x01
68 #define IRLAP_I_OFF 0x02
69
70 /*
71  * IrLAP-DEFINES
72  * -------------
73  */
74 #define IRLAP_XBOF 0xFF
75 #define IRLAP_BOF  0xC0
76 #define IRLAP_EOF  0xC1
77 #define IRLAP_CE   0x7D
78 #define IRLAP_ESC  IRLAP_CE
79
80 #define IRLAP_ESC_MASK (~0xDF)
81
82 #define IRLAP_A_LENGTH   1
83 #define IRLAP_C_LENGTH   1
84 #define IRLAP_FCS_LENGTH 2
85 #define IRLAP_EOF_LENGTH 1
86
87 #define IRLAP_C_MASK            0x03
88 #define IRLAP_U_FRAME           0x03
89 #define IRLAP_S_FRAME           0x01
90 #define IRLAP_PF_BIT_MASK     (~0xEF)
91 #define IRLAP_PF_BIT_CLR_MASK (~0x10)
92 #define IRLAP_Nr_CLR_MASK       0x1F
93
94 /*
95  * IRLAP U cmd/response
96  * --------------------
97  * - all defines use a cleared P/F-Bit
98  *   (irlap_frame -> c & IRLAP_PF_BIT_CLR_MASK)
99  * - page 26 in IrLAP-spec
100  * - if no _CMD or _RSP name is _CMD_RSP (e.g. 0x83)
101  */
102 #define IRLAP_SNRM_RNRM 0x83
103 #define IRLAP_DISC_RD   0x43
104 #define IRLAP_UI_UI     0x03
105 #define IRLAP_XID_CMD   0x2F
106 #define IRLAP_TEST_TEST 0xE3
107 #define IRLAP_UA_RSP    0x63
108 #define IRLAP_FRMR_RSP  0x87
109 #define IRLAP_DM_RSP    0x0F
110 #define IRLAP_XID_RSP   0xAF
111
112 /*
113  * IRLAP S cmd/response
114  * --------------------
115  * - all defines use a cleared P/F-Bit and cleared Nr
116  *   (irlap_frame -> c & IRLAP_PF_BIT_CLR_MASK & IRLAP_Nr_CLR_MASK)
117  * - page 32 in IrLAP-spec
118  * - for both (cmd and response) the same mask is defined
119  */
120 #define IRLAP_RR   0x01
121 #define IRLAP_RNR  0x05
122 #define IRLAP_REJ  0x09
123 #define IRLAP_SREJ 0x0D
124
125
126 /*
127  * irlap-connection-states
128  * -----------------------
129  * - negotation defines are also conn-states
130  */
131 #define IRLAP_DISC     0x00             /* disconnected          */
132 #define IRLAP_NDM      0x01             /* normaldisconnect mode */
133 #define IRLAP_NRM      0x02             /* normal response mode  */
134
135 /*
136  * negotation-defines
137  * ------------------
138  */
139 /* negotation-states */
140 #define NEG_SNRM_OK     0x01
141 #define NEG_WAIT_FOR_UA 0x02
142 #define NEG_UA_OK       0x03
143 #define NEG_COMPLETE    0x04
144
145 #define B576000   576000
146 #define B1152000 1152000
147
148 #define IRLAP_SNRM_SRC_ADR       0x00 /* src in SNRM               */
149 #define IRLAP_SNRM_DEST_ADR      0x04 /* dest in SNRM              */
150 #define IRLAP_SNRM_CONN_ADR      0x08 /* connection-adr in SNRM    */
151 #define IRLAP_UA_SRC_ADR         0x00 /* src in UA                 */
152 #define IRLAP_UA_DEST_ADR        0x04 /* dest in UA                */
153 #define IRLAP_NEG_SNRM_PARAM_OFF 0x09 /* src(U32) dest(U32) adr(8) */
154 #define IRLAP_NEG_UA_PARAM_OFF   0x08 /* src(U32) dest(U32)        */
155 #define IRLAP_NEG_BPS_PI         0x01 /* IrLAP page 39             */
156 #define IRLAP_PI_LENGTH 1       /* no more longer used */
157 #define IRLAP_PL_LENGTH 1       /* no more longer used */
158
159 /*
160  * defines for decode xid-cmd
161  * --------------------------
162  */
163 #define XID_C_FI_OFFSET    0x00 /* offset for format identifier (U8)  */
164 #define XID_C_SRC_ADR_OFF  0x01 /* offset for source address    (U32) */
165 #define XID_C_DEST_ADR_OFF 0x05 /* offset for dest address      (U32) */
166 #define XID_C_DISC_F_OFF   0x09 /* offset for discovery flags   (U8)  */
167 #define XID_C_SLOT_NR_OFF  0x0A /* offset for slot number       (U8)  */
168 #define XID_C_VERSION_OFF  0x0B /* offset for version           (U8)  */
169 #define XID_C_DISC_I_OFF   0x0C /* offset for discovery information   */
170 #define XID_C_FLAG_TRUE    0x01 /* flags in cmd only if FI == 0x01    */
171 #define XID_C_F_SLOT_MASK  0x03 /* mask for slot numbers in di-flag   */
172 #define XID_C_F_NEW_ADR_M  0x04 /* mask for new device-address-gen.   */
173 #define XID_C_LAST_SLOT    0xFF /* nr.  for last slot in xid-cmd      */
174 #define XID_C_DISC_I_M_L   0x20 /* max length of discovery info       */
175 #define XID_C_DI_S_H_OFF   0x0C /* 1. service hint offset in disc-inf */
176 #define XID_C_DI_S_H_EX_M  0x07 /* serv.hint extent. mask in disc_inf */
177
178 /*
179  * defines for decode xid-rsp
180  * --------------------------
181  */
182 #define XID_R_FI_OFFSET    0x00 /* offset for format identifier (U8)  */
183 #define XID_R_SRC_ADR_OFF  0x01 /* offset for source address    (U32) */
184 #define XID_R_DEST_ADR_OFF 0x05 /* offset for dest address      (U32) */
185 #define XID_R_DISC_F_OFF   0x09 /* offset for discovery flags   (U8)  */
186 #define XID_R_SLOT_NR_OFF  0x0A /* offset for slot number       (U8)  */
187 #define XID_R_VERSION_OFF  0x0B /* offset for version           (U8)  */
188 #define XID_R_DISC_I_OFF   0x0C /* offset for discovery information   */
189 #define XID_R_FLAG_TRUE    0x01 /* flags in rsp only if FI == 0x01    */
190 #define XID_R_F_SLOT_MASK  0x03 /* mask for slot numbers in di-flag   */
191 #define XID_R_F_NEW_ADR_M  0x04 /* mask for new device-address-gen.   */
192 #define XID_R_LAST_SLOT    0xFF /* nr.  for last slot in xid-cmd/rsp  */
193 #define XID_R_DISC_I_M_L   0x20 /* max length of discovery info       */
194 #define XID_R_DI_S_H_OFF   0x0C /* 1. service hint offset in disc-inf */
195 #define XID_R_DI_S_H_EX_M  0x07 /* serv.hint extent. mask in disc_inf */
196 #define XID_R_SNIFF_FRAME  0xFFFFFFFF /* dest address for sniffing    */
197
198 /* 
199  * defines for snrm-cmd
200  * --------------------
201  */
202 #define SNRM_CMD_RESET_LEN   0x00 /* no i-field is present              */
203 #define SNRM_EST_CONNECT_ADR 0xFF /* conn.adr. in case con.establish    */
204 #define SNRM_C_SRC_ADR_OFF   0x00 /* offset for source address    (U32) */
205 #define SNRM_C_DEST_ADR_OFF  0x04 /* offset for dest address      (U32) */
206 #define SNRM_C_N_C_ADR_OFF   0x08 /* new conn. adr. offset        (U8)  */
207 #define SNRM_C_NEG_OFF       0x09 /* negotation-fields offset           */
208 #define SNRM_BPS_PI          0x01 /* bps-pi                             */
209 #define SNRM_MAX_TAT_PI      0x82 /* max. turn around time pi           */
210 #define SNRM_DATA_SIZE_PI    0x83 /* data size pi                       */
211 #define SNRM_WIN_SIZE_PI     0x84 /* window size pi                     */
212 #define SNRM_ADD_BOF_PI      0x85 /* addition BOFs pi                   */
213 #define SNRM_MIN_TAT_PI      0x86 /* min. turn around time pi           */
214 #define SNRM_LD_TT_PI        0x08 /* link disc./threshold time pi       */
215
216 /*
217  * defines for ua-rsp-frame
218  * ------------------------
219  */
220 #define UA_CONNECT_MIN_LENGTH 0x0E /* 14 are min length to use the frame
221                                     * for response to snrm used to
222                                     * establish a connection - look at
223                                     * page 39 - negotation: type 0 params
224                                     * must be negotiated at both stations
225                                     * bps and link disc/threshold time -
226                                     * in this case also src and dest are
227                                     * used ( 4 + 4 + 3 + 3), page 31      */
228 #define UA_WITH_SRC_DST_LEN   0x08 /* ua len with src and dest            */
229 #define UA_SRC_ADR_OFF        0x00 /* offset for source address    (U32) */
230 #define UA_DEST_ADR_OFF       0x04 /* offset for dest address      (U32) */
231 #define UA_NEG_OFF            0x08 /* negotation-fields offset           */
232 #define UA_BPS_PI             0x01 /* bps-pi                             */
233 #define UA_MAX_TAT_PI         0x82 /* max. turn around time pi           */
234 #define UA_DATA_SIZE_PI       0x83 /* data size pi                       */
235 #define UA_WIN_SIZE_PI        0x84 /* window size pi                     */
236 #define UA_ADD_BOF_PI         0x85 /* addition BOFs pi                   */
237 #define UA_MIN_TAT_PI         0x86 /* min. turn around time pi           */
238 #define UA_LD_TT_PI           0x08 /* link disc./threshold time pi       */
239
240
241 #endif /* __IRLAP_H */
242