summaryrefslogtreecommitdiffstats
path: root/private/ntos/tdi/irda/inc/decdirda.h
blob: d93b0d9e39104ffa2fb7b40990834843becd86b6 (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// returns pointers pOutStr
TCHAR *DecodeIRDA(int  *pFrameType,// return frame type (-1 = bad frame)
				BYTE *pFrameBuf, // pointer to buffer containing IRLAP frame
				UINT FrameLen, 	 // length of buffer 
				TCHAR *pOutStr,	 // string where decode packet is placed	
                UINT DecodeLayer,// 2-LAP only, 3-LAP/LMP, 4-LAP/LMP/TTP
				BOOL fNoConnAddr,// TRUE->Don't show connection address in str
                int DispMode    // DISP_ASCII/HEX/BOTH
);

#define DISP_ASCII  1
#define DISP_HEX    2
#define DISP_BOTH   3

extern int BaudBitMask;

#define IRLAP_BOF 0xC0
#define IRLAP_EOF 0xC1
#define IRLAP_ESC 0x7D
#define IRLAP_COMP_BIT 0x20 

#define IRLAP_BROADCAST      0xfe
#define _IRLAP_CMD           0x01
#define _IRLAP_RSP           0x00

#define IRLAP_I_FRM          0x00
#define IRLAP_S_FRM          0x01
#define IRLAP_U_FRM          0x03

/*
** Unnumbered Frame types with P/F bit set to 0
*/
#define IRLAP_UI             0x03
#define IRLAP_XID_CMD        0x2f
#define IRLAP_TEST           0xe3
#define IRLAP_SNRM           0x83
#define IRLAP_DISC           0x43
#define IRLAP_UA             0x63
#define IRLAP_FRMR           0x87
#define IRLAP_DM             0x0f
#define IRLAP_XID_RSP        0xaf

/*
** Supervisory Frames
*/
#define IRLAP_RR             0x01
#define IRLAP_RNR            0x05
#define IRLAP_REJ            0x09
#define IRLAP_SREJ           0x0d


#define IRLAP_GET_ADDR(addr)       (addr >> 1)
#define IRLAP_GET_CRBIT(addr)      (addr & 1) 
#define IRLAP_GET_PFBIT(cntl)      ((cntl >>4) & 1)
#define IRLAP_GET_UCNTL(cntl)      (cntl & 0xEF)
#define IRLAP_GET_SCNTL(cntl)      (cntl & 0x0F)
#define IRLAP_FRAME_TYPE(cntl)     (cntl & 0x01 ? (cntl & 3) : 0)
#define IRLAP_GET_NR(cntl)         ((cntl & 0xE0) >> 5)
#define IRLAP_GET_NS(cntl)         ((cntl & 0xE) >> 1)     

/*
** XID stuff
*/
#define XID_DISCV_FORMAT_ID     0x01
#define XID_NEGPARMS_FORMAT_ID 0x02

typedef struct 
{
    BYTE    SrcAddr[4];
    BYTE    DestAddr[4];
    BYTE    NoOfSlots:2;
    BYTE    GenNewAddr:1;
    BYTE    Reserved:5;
    BYTE    SlotNo;
    BYTE    Version;
} XID_DISCV_FORMAT;

/*
** SNRM
*/
typedef struct
{
    BYTE     SrcAddr[4];
    BYTE     DestAddr[4];
    BYTE     ConnAddr;
    BYTE     FirstPI;
} SNRM_FORMAT;

/*
** UA
*/
typedef struct
{
    BYTE     SrcAddr[4];
    BYTE     DestAddr[4];
    BYTE     FirstPI;
} UA_FORMAT;

/*
** LM-PDU stuff
*/
typedef struct
{
    BYTE    DLSAP_SEL:7;    
    BYTE    CntlBit:1;
    BYTE    SLSAP_SEL:7;
    BYTE    RsvrdBi1:1;    
} LM_HEADER;

/* LM-PDU frame types */
#define LM_PDU_CNTL_FRAME 1
#define LM_PDU_DATA_FRAME 0

typedef struct
{
    BYTE    OpCode:7;
    BYTE    ABit:1;
} LM_CNTL_FORMAT;

/* Opcodes */
#define LM_PDU_CONNECT    1
#define LM_PDU_DISCONNECT 2
#define LM_PDU_ACCESSMODE 3

#define LM_PDU_REQUEST 0
#define LM_PDU_CONFIRM 1

#define LM_PDU_SUCCESS        0
#define LM_PDU_FAILURE        1
#define LM_PDU_UNSUPPORTED 0xFF

#define LM_PDU_MULTIPLEXED 0
#define LM_PDU_EXCLUSIVE   1

/* Max disconnect reason code, see _LM_PDU_DscReason[] in decdirda.c */
#define LM_PDU_MAX_DSC_REASON  0x8

/*
** Negotiation Parameter Identifiers
*/
#define NEG_PI_BAUD        0x01
#define NEG_PI_MAX_TAT     0x82
#define NEG_PI_DATA_SZ     0x83
#define NEG_PI_WIN_SZ      0x84
#define NEG_PI_BOFS        0x85
#define NEG_PI_MIN_TAT     0x86
#define NEG_PI_DISC_THRESH 0x08

// Tiny TP!

#define TTP_PFLAG_NO_PARMS  0
#define TTP_PFLAG_PARMS     1

#define TTP_MBIT_NOT_FINAL  1
#define TTP_MBIT_FINAL      0

typedef struct
{
    BYTE    InitialCredit : 7;
    BYTE    ParmFlag      : 1;
} TTP_CONN_HEADER;

typedef struct
{
    BYTE    AdditionalCredit : 7;
    BYTE    MoreBit          : 1;
} TTP_DATA_HEADER;

#define net_short(x) 		((((x)&0xff) << 8) | (((x)&0xff00) >> 8))

#define net_long(x) 		(((((DWORD UNALIGNED)(x))&0xffL)<<24) | \
							((((DWORD UNALIGNED)(x))&0xff00L)<<8) | \
							((((DWORD UNALIGNED)(x))&0xff0000L)>>8) | \
							((((DWORD UNALIGNED)(x))&0xff000000L)>>24))