1 /*********************************************************************
2  *
3  * Filename:      irlap_frame.h
4  * Version:       0.9
5  * Description:   IrLAP frame declarations
6  * Status:        Experimental.
7  * Author:        Dag Brattli <dagb@cs.uit.no>
8  * Created at:    Tue Aug 19 10:27:26 1997
9  * Modified at:   Sat Dec 25 21:07:26 1999
10  * Modified by:   Dag Brattli <dagb@cs.uit.no>
11  *
12  *     Copyright (c) 1997-1999 Dag Brattli <dagb@cs.uit.no>,
13  *     All Rights Reserved.
14  *
15  *     This program is free software; you can redistribute it and/or
16  *     modify it under the terms of the GNU General Public License as
17  *     published by the Free Software Foundation; either version 2 of
18  *     the License, or (at your option) any later version.
19  *
20  *     This program is distributed in the hope that it will be useful,
21  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
22  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  *     GNU General Public License for more details.
24  *
25  *     You should have received a copy of the GNU General Public License
26  *     along with this program; if not, write to the Free Software
27  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28  *     MA 02111-1307 USA
29  *
30  ********************************************************************/
31 
32 #ifndef IRLAP_FRAME_H
33 #define IRLAP_FRAME_H
34 
35 #include <linux/skbuff.h>
36 
37 #include <net/irda/irda.h>
38 #include <net/irda/irlap.h>
39 #include <net/irda/qos.h>
40 
41 /* Frame types and templates */
42 #define INVALID   0xff
43 
44 /* Unnumbered (U) commands */
45 #define SNRM_CMD  0x83 /* Set Normal Response Mode */
46 #define DISC_CMD  0x43 /* Disconnect */
47 #define XID_CMD   0x2f /* Exchange Station Identification */
48 #define TEST_CMD  0xe3 /* Test */
49 
50 /* Unnumbered responses */
51 #define RNRM_RSP  0x83 /* Request Normal Response Mode */
52 #define UA_RSP    0x63 /* Unnumbered Acknowledgement */
53 #define FRMR_RSP  0x87 /* Frame Reject */
54 #define DM_RSP    0x0f /* Disconnect Mode */
55 #define RD_RSP    0x43 /* Request Disconnection */
56 #define XID_RSP   0xaf /* Exchange Station Identification */
57 #define TEST_RSP  0xe3 /* Test frame */
58 
59 /* Supervisory (S) */
60 #define RR        0x01 /* Receive Ready */
61 #define REJ       0x09 /* Reject */
62 #define RNR       0x05 /* Receive Not Ready */
63 #define SREJ      0x0d /* Selective Reject */
64 
65 /* Information (I) */
66 #define I_FRAME   0x00 /* Information Format */
67 #define UI_FRAME  0x03 /* Unnumbered Information */
68 
69 #define CMD_FRAME 0x01
70 #define RSP_FRAME 0x00
71 
72 #define PF_BIT    0x10 /* Poll/final bit */
73 
74 struct xid_frame {
75 	__u8  caddr; /* Connection address */
76 	__u8  control;
77 	__u8  ident; /* Should always be XID_FORMAT */
78 	__u32 saddr; /* Source device address */
79 	__u32 daddr; /* Destination device address */
80 	__u8  flags; /* Discovery flags */
81 	__u8  slotnr;
82 	__u8  version;
83 } PACK;
84 
85 struct test_frame {
86 	__u8 caddr;          /* Connection address */
87 	__u8 control;
88 	__u32 saddr;         /* Source device address */
89 	__u32 daddr;         /* Destination device address */
90 } PACK;
91 
92 struct ua_frame {
93 	__u8 caddr;
94 	__u8 control;
95 
96 	__u32 saddr; /* Source device address */
97 	__u32 daddr; /* Dest device address */
98 } PACK;
99 
100 struct i_frame {
101 	__u8 caddr;
102 	__u8 control;
103 } PACK;
104 
105 struct snrm_frame {
106 	__u8  caddr;
107 	__u8  control;
108 	__u32 saddr;
109 	__u32 daddr;
110 	__u8  ncaddr;
111 } PACK;
112 
113 void irlap_queue_xmit(struct irlap_cb *self, struct sk_buff *skb);
114 void irlap_send_discovery_xid_frame(struct irlap_cb *, int S, __u8 s,
115 				    __u8 command, discovery_t *discovery);
116 void irlap_send_snrm_frame(struct irlap_cb *, struct qos_info *);
117 void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr,
118 			   struct sk_buff *cmd);
119 void irlap_send_ua_response_frame(struct irlap_cb *, struct qos_info *);
120 void irlap_send_dm_frame(struct irlap_cb *self);
121 void irlap_send_rd_frame(struct irlap_cb *self);
122 void irlap_send_disc_frame(struct irlap_cb *self);
123 void irlap_send_rr_frame(struct irlap_cb *self, int command);
124 
125 void irlap_send_data_primary(struct irlap_cb *, struct sk_buff *);
126 void irlap_send_data_primary_poll(struct irlap_cb *, struct sk_buff *);
127 void irlap_send_data_secondary(struct irlap_cb *, struct sk_buff *);
128 void irlap_send_data_secondary_final(struct irlap_cb *, struct sk_buff *);
129 void irlap_resend_rejected_frames(struct irlap_cb *, int command);
130 void irlap_resend_rejected_frame(struct irlap_cb *self, int command);
131 
132 void irlap_send_i_frame(struct irlap_cb *, struct sk_buff *, int command);
133 void irlap_send_ui_frame(struct irlap_cb *self, struct sk_buff *skb,
134 			 __u8 caddr, int command);
135 
136 extern int irlap_insert_qos_negotiation_params(struct irlap_cb *self,
137 					       struct sk_buff *skb);
138 
139 #endif
140