1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include <linux/netdevice.h>
22#include <net/llc.h>
23#include <net/llc_pdu.h>
24#include <net/llc_s_ac.h>
25#include <net/llc_s_ev.h>
26#include <net/llc_sap.h>
27
28
29
30
31
32
33
34
35
36
37int llc_sap_action_unitdata_ind(struct llc_sap *sap, struct sk_buff *skb)
38{
39 llc_sap_rtn_pdu(sap, skb);
40 return 0;
41}
42
43
44
45
46
47
48
49
50
51
52int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb)
53{
54 struct llc_sap_state_ev *ev = llc_sap_ev(skb);
55 int rc;
56
57 llc_pdu_header_init(skb, LLC_PDU_TYPE_U, ev->saddr.lsap,
58 ev->daddr.lsap, LLC_PDU_CMD);
59 llc_pdu_init_as_ui_cmd(skb);
60 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac);
61 if (likely(!rc)) {
62 skb_get(skb);
63 rc = dev_queue_xmit(skb);
64 }
65 return rc;
66}
67
68
69
70
71
72
73
74
75
76
77int llc_sap_action_send_xid_c(struct llc_sap *sap, struct sk_buff *skb)
78{
79 struct llc_sap_state_ev *ev = llc_sap_ev(skb);
80 int rc;
81
82 llc_pdu_header_init(skb, LLC_PDU_TYPE_U, ev->saddr.lsap,
83 ev->daddr.lsap, LLC_PDU_CMD);
84 llc_pdu_init_as_xid_cmd(skb, LLC_XID_NULL_CLASS_2, 0);
85 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac);
86 if (likely(!rc)) {
87 skb_get(skb);
88 rc = dev_queue_xmit(skb);
89 }
90 return rc;
91}
92
93
94
95
96
97
98
99
100
101int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb)
102{
103 u8 mac_da[ETH_ALEN], mac_sa[ETH_ALEN], dsap;
104 int rc = 1;
105 struct sk_buff *nskb;
106
107 llc_pdu_decode_sa(skb, mac_da);
108 llc_pdu_decode_da(skb, mac_sa);
109 llc_pdu_decode_ssap(skb, &dsap);
110 nskb = llc_alloc_frame(NULL, skb->dev, LLC_PDU_TYPE_U,
111 sizeof(struct llc_xid_info));
112 if (!nskb)
113 goto out;
114 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
115 LLC_PDU_RSP);
116 llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 0);
117 rc = llc_mac_hdr_init(nskb, mac_sa, mac_da);
118 if (likely(!rc))
119 rc = dev_queue_xmit(nskb);
120out:
121 return rc;
122}
123
124
125
126
127
128
129
130
131
132
133int llc_sap_action_send_test_c(struct llc_sap *sap, struct sk_buff *skb)
134{
135 struct llc_sap_state_ev *ev = llc_sap_ev(skb);
136 int rc;
137
138 llc_pdu_header_init(skb, LLC_PDU_TYPE_U, ev->saddr.lsap,
139 ev->daddr.lsap, LLC_PDU_CMD);
140 llc_pdu_init_as_test_cmd(skb);
141 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac);
142 if (likely(!rc)) {
143 skb_get(skb);
144 rc = dev_queue_xmit(skb);
145 }
146 return rc;
147}
148
149int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb)
150{
151 u8 mac_da[ETH_ALEN], mac_sa[ETH_ALEN], dsap;
152 struct sk_buff *nskb;
153 int rc = 1;
154 u32 data_size;
155
156 llc_pdu_decode_sa(skb, mac_da);
157 llc_pdu_decode_da(skb, mac_sa);
158 llc_pdu_decode_ssap(skb, &dsap);
159
160
161 data_size = ntohs(eth_hdr(skb)->h_proto) - 3;
162 nskb = llc_alloc_frame(NULL, skb->dev, LLC_PDU_TYPE_U, data_size);
163 if (!nskb)
164 goto out;
165 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
166 LLC_PDU_RSP);
167 llc_pdu_init_as_test_rsp(nskb, skb);
168 rc = llc_mac_hdr_init(nskb, mac_sa, mac_da);
169 if (likely(!rc))
170 rc = dev_queue_xmit(nskb);
171out:
172 return rc;
173}
174
175
176
177
178
179
180
181
182
183int llc_sap_action_report_status(struct llc_sap *sap, struct sk_buff *skb)
184{
185 return 0;
186}
187
188
189
190
191
192
193
194
195
196int llc_sap_action_xid_ind(struct llc_sap *sap, struct sk_buff *skb)
197{
198 llc_sap_rtn_pdu(sap, skb);
199 return 0;
200}
201
202
203
204
205
206
207
208
209
210int llc_sap_action_test_ind(struct llc_sap *sap, struct sk_buff *skb)
211{
212 llc_sap_rtn_pdu(sap, skb);
213 return 0;
214}
215