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 rc = dev_queue_xmit(skb);
63 return rc;
64}
65
66
67
68
69
70
71
72
73
74
75int llc_sap_action_send_xid_c(struct llc_sap *sap, struct sk_buff *skb)
76{
77 struct llc_sap_state_ev *ev = llc_sap_ev(skb);
78 int rc;
79
80 llc_pdu_header_init(skb, LLC_PDU_TYPE_U, ev->saddr.lsap,
81 ev->daddr.lsap, LLC_PDU_CMD);
82 llc_pdu_init_as_xid_cmd(skb, LLC_XID_NULL_CLASS_2, 0);
83 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac);
84 if (likely(!rc))
85 rc = dev_queue_xmit(skb);
86 return rc;
87}
88
89
90
91
92
93
94
95
96
97int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb)
98{
99 u8 mac_da[ETH_ALEN], mac_sa[ETH_ALEN], dsap;
100 int rc = 1;
101 struct sk_buff *nskb;
102
103 llc_pdu_decode_sa(skb, mac_da);
104 llc_pdu_decode_da(skb, mac_sa);
105 llc_pdu_decode_ssap(skb, &dsap);
106 nskb = llc_alloc_frame(NULL, skb->dev, LLC_PDU_TYPE_U,
107 sizeof(struct llc_xid_info));
108 if (!nskb)
109 goto out;
110 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
111 LLC_PDU_RSP);
112 llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 0);
113 rc = llc_mac_hdr_init(nskb, mac_sa, mac_da);
114 if (likely(!rc))
115 rc = dev_queue_xmit(nskb);
116out:
117 return rc;
118}
119
120
121
122
123
124
125
126
127
128
129int llc_sap_action_send_test_c(struct llc_sap *sap, struct sk_buff *skb)
130{
131 struct llc_sap_state_ev *ev = llc_sap_ev(skb);
132 int rc;
133
134 llc_pdu_header_init(skb, LLC_PDU_TYPE_U, ev->saddr.lsap,
135 ev->daddr.lsap, LLC_PDU_CMD);
136 llc_pdu_init_as_test_cmd(skb);
137 rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac);
138 if (likely(!rc))
139 rc = dev_queue_xmit(skb);
140 return rc;
141}
142
143int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb)
144{
145 u8 mac_da[ETH_ALEN], mac_sa[ETH_ALEN], dsap;
146 struct sk_buff *nskb;
147 int rc = 1;
148 u32 data_size;
149
150 llc_pdu_decode_sa(skb, mac_da);
151 llc_pdu_decode_da(skb, mac_sa);
152 llc_pdu_decode_ssap(skb, &dsap);
153
154
155 data_size = ntohs(eth_hdr(skb)->h_proto) - 3;
156 nskb = llc_alloc_frame(NULL, skb->dev, LLC_PDU_TYPE_U, data_size);
157 if (!nskb)
158 goto out;
159 llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
160 LLC_PDU_RSP);
161 llc_pdu_init_as_test_rsp(nskb, skb);
162 rc = llc_mac_hdr_init(nskb, mac_sa, mac_da);
163 if (likely(!rc))
164 rc = dev_queue_xmit(nskb);
165out:
166 return rc;
167}
168
169
170
171
172
173
174
175
176
177int llc_sap_action_report_status(struct llc_sap *sap, struct sk_buff *skb)
178{
179 return 0;
180}
181
182
183
184
185
186
187
188
189
190int llc_sap_action_xid_ind(struct llc_sap *sap, struct sk_buff *skb)
191{
192 llc_sap_rtn_pdu(sap, skb);
193 return 0;
194}
195
196
197
198
199
200
201
202
203
204int llc_sap_action_test_ind(struct llc_sap *sap, struct sk_buff *skb)
205{
206 llc_sap_rtn_pdu(sap, skb);
207 return 0;
208}
209