blob: a75b8f2aab1949e75db4208d086cdbcfe6f155a4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * af_llc.c - LLC User Interface SAPs
3 * Description:
4 * Functions in this module are implementation of socket based llc
5 * communications for the Linux operating system. Support of llc class
6 * one and class two is provided via SOCK_DGRAM and SOCK_STREAM
7 * respectively.
8 *
9 * An llc2 connection is (mac + sap), only one llc2 sap connection
10 * is allowed per mac. Though one sap may have multiple mac + sap
11 * connections.
12 *
13 * Copyright (c) 2001 by Jay Schulist <jschlst@samba.org>
14 * 2002-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
15 *
16 * This program can be redistributed or modified under the terms of the
17 * GNU General Public License as published by the Free Software Foundation.
18 * This program is distributed without any warranty or implied warranty
19 * of merchantability or fitness for a particular purpose.
20 *
21 * See the GNU General Public License for more details.
22 */
23#include <linux/config.h>
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -030024#include <linux/compiler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/kernel.h>
26#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/rtnetlink.h>
28#include <linux/init.h>
29#include <net/llc.h>
30#include <net/llc_sap.h>
31#include <net/llc_pdu.h>
32#include <net/llc_conn.h>
Arnaldo Carvalho de Meloc752f072005-08-09 20:08:28 -070033#include <net/tcp_states.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35/* remember: uninitialized global data is zeroed because its in .bss */
36static u16 llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
37static u16 llc_ui_sap_link_no_max[256];
38static struct sockaddr_llc llc_ui_addrnull;
39static struct proto_ops llc_ui_ops;
40
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -030041static int llc_ui_wait_for_conn(struct sock *sk, long timeout);
42static int llc_ui_wait_for_disc(struct sock *sk, long timeout);
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -030043static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45#if 0
46#define dprintk(args...) printk(KERN_DEBUG args)
47#else
48#define dprintk(args...)
49#endif
50
51/**
52 * llc_ui_next_link_no - return the next unused link number for a sap
53 * @sap: Address of sap to get link number from.
54 *
55 * Return the next unused link number for a given sap.
56 */
57static __inline__ u16 llc_ui_next_link_no(int sap)
58{
59 return llc_ui_sap_link_no_max[sap]++;
60}
61
62/**
63 * llc_proto_type - return eth protocol for ARP header type
64 * @arphrd: ARP header type.
65 *
66 * Given an ARP header type return the corresponding ethernet protocol.
67 */
68static __inline__ u16 llc_proto_type(u16 arphrd)
69{
70 return arphrd == ARPHRD_IEEE802_TR ?
71 htons(ETH_P_TR_802_2) : htons(ETH_P_802_2);
72}
73
74/**
75 * llc_ui_addr_null - determines if a address structure is null
76 * @addr: Address to test if null.
77 */
78static __inline__ u8 llc_ui_addr_null(struct sockaddr_llc *addr)
79{
80 return !memcmp(addr, &llc_ui_addrnull, sizeof(*addr));
81}
82
83/**
84 * llc_ui_header_len - return length of llc header based on operation
85 * @sk: Socket which contains a valid llc socket type.
86 * @addr: Complete sockaddr_llc structure received from the user.
87 *
88 * Provide the length of the llc header depending on what kind of
89 * operation the user would like to perform and the type of socket.
90 * Returns the correct llc header length.
91 */
92static __inline__ u8 llc_ui_header_len(struct sock *sk,
93 struct sockaddr_llc *addr)
94{
95 u8 rc = LLC_PDU_LEN_U;
96
97 if (addr->sllc_test || addr->sllc_xid)
98 rc = LLC_PDU_LEN_U;
99 else if (sk->sk_type == SOCK_STREAM)
100 rc = LLC_PDU_LEN_I;
101 return rc;
102}
103
104/**
105 * llc_ui_send_data - send data via reliable llc2 connection
106 * @sk: Connection the socket is using.
107 * @skb: Data the user wishes to send.
108 * @addr: Source and destination fields provided by the user.
109 * @noblock: can we block waiting for data?
110 *
111 * Send data via reliable llc2 connection.
112 * Returns 0 upon success, non-zero if action did not succeed.
113 */
114static int llc_ui_send_data(struct sock* sk, struct sk_buff *skb, int noblock)
115{
116 struct llc_sock* llc = llc_sk(sk);
117 int rc = 0;
118
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300119 if (unlikely(llc_data_accept_state(llc->state) || llc->p_flag)) {
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -0300120 long timeout = sock_sndtimeo(sk, noblock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
122 rc = llc_ui_wait_for_busy_core(sk, timeout);
123 }
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300124 if (unlikely(!rc))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 rc = llc_build_and_send_pkt(sk, skb);
126 return rc;
127}
128
129static void llc_ui_sk_init(struct socket *sock, struct sock *sk)
130{
131 sk->sk_type = sock->type;
132 sk->sk_sleep = &sock->wait;
133 sk->sk_socket = sock;
134 sock->sk = sk;
135 sock->ops = &llc_ui_ops;
136}
137
138static struct proto llc_proto = {
139 .name = "DDP",
140 .owner = THIS_MODULE,
141 .obj_size = sizeof(struct llc_sock),
142};
143
144/**
145 * llc_ui_create - alloc and init a new llc_ui socket
146 * @sock: Socket to initialize and attach allocated sk to.
147 * @protocol: Unused.
148 *
149 * Allocate and initialize a new llc_ui socket, validate the user wants a
150 * socket type we have available.
151 * Returns 0 upon success, negative upon failure.
152 */
153static int llc_ui_create(struct socket *sock, int protocol)
154{
155 struct sock *sk;
156 int rc = -ESOCKTNOSUPPORT;
157
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300158 if (likely(sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 rc = -ENOMEM;
160 sk = llc_sk_alloc(PF_LLC, GFP_KERNEL, &llc_proto);
161 if (sk) {
162 rc = 0;
163 llc_ui_sk_init(sock, sk);
164 }
165 }
166 return rc;
167}
168
169/**
170 * llc_ui_release - shutdown socket
171 * @sock: Socket to release.
172 *
173 * Shutdown and deallocate an existing socket.
174 */
175static int llc_ui_release(struct socket *sock)
176{
177 struct sock *sk = sock->sk;
178 struct llc_sock *llc;
179
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300180 if (unlikely(sk == NULL))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 goto out;
182 sock_hold(sk);
183 lock_sock(sk);
184 llc = llc_sk(sk);
185 dprintk("%s: closing local(%02X) remote(%02X)\n", __FUNCTION__,
186 llc->laddr.lsap, llc->daddr.lsap);
187 if (!llc_send_disc(sk))
188 llc_ui_wait_for_disc(sk, sk->sk_rcvtimeo);
189 if (!sock_flag(sk, SOCK_ZAPPED))
190 llc_sap_remove_socket(llc->sap, sk);
191 release_sock(sk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 if (llc->dev)
193 dev_put(llc->dev);
194 sock_put(sk);
195 llc_sk_free(sk);
196out:
197 return 0;
198}
199
200/**
201 * llc_ui_autoport - provide dynamically allocate SAP number
202 *
203 * Provide the caller with a dynamically allocated SAP number according
204 * to the rules that are set in this function. Returns: 0, upon failure,
205 * SAP number otherwise.
206 */
207static int llc_ui_autoport(void)
208{
209 struct llc_sap *sap;
210 int i, tries = 0;
211
212 while (tries < LLC_SAP_DYN_TRIES) {
213 for (i = llc_ui_sap_last_autoport;
214 i < LLC_SAP_DYN_STOP; i += 2) {
215 sap = llc_sap_find(i);
216 if (!sap) {
217 llc_ui_sap_last_autoport = i + 2;
218 goto out;
219 }
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -0300220 llc_sap_put(sap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 }
222 llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
223 tries++;
224 }
225 i = 0;
226out:
227 return i;
228}
229
230/**
Arnaldo Carvalho de Melo5a770c02005-09-22 03:56:26 -0300231 * llc_ui_autobind - automatically bind a socket to a sap
232 * @sock: socket to bind
233 * @addr: address to connect to
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 *
Arnaldo Carvalho de Melo5a770c02005-09-22 03:56:26 -0300235 * Used by llc_ui_connect and llc_ui_sendmsg when the user hasn't
236 * specifically used llc_ui_bind to bind to an specific address/sap
237 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 * Returns: 0 upon success, negative otherwise.
239 */
240static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
241{
242 struct sock *sk = sock->sk;
243 struct llc_sock *llc = llc_sk(sk);
244 struct llc_sap *sap;
245 int rc = -EINVAL;
246
247 if (!sock_flag(sk, SOCK_ZAPPED))
248 goto out;
249 rc = -ENODEV;
250 llc->dev = dev_getfirstbyhwtype(addr->sllc_arphrd);
251 if (!llc->dev)
252 goto out;
253 rc = -EUSERS;
254 llc->laddr.lsap = llc_ui_autoport();
255 if (!llc->laddr.lsap)
256 goto out;
257 rc = -EBUSY; /* some other network layer is using the sap */
258 sap = llc_sap_open(llc->laddr.lsap, NULL);
259 if (!sap)
260 goto out;
261 memcpy(llc->laddr.mac, llc->dev->dev_addr, IFHWADDRLEN);
262 memcpy(&llc->addr, addr, sizeof(llc->addr));
263 /* assign new connection to its SAP */
264 llc_sap_add_socket(sap, sk);
265 sock_reset_flag(sk, SOCK_ZAPPED);
266 rc = 0;
267out:
268 return rc;
269}
270
271/**
272 * llc_ui_bind - bind a socket to a specific address.
273 * @sock: Socket to bind an address to.
274 * @uaddr: Address the user wants the socket bound to.
275 * @addrlen: Length of the uaddr structure.
276 *
277 * Bind a socket to a specific address. For llc a user is able to bind to
Arnaldo Carvalho de Melo5a770c02005-09-22 03:56:26 -0300278 * a specific sap only or mac + sap.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 * If the user desires to bind to a specific mac + sap, it is possible to
280 * have multiple sap connections via multiple macs.
281 * Bind and autobind for that matter must enforce the correct sap usage
282 * otherwise all hell will break loose.
283 * Returns: 0 upon success, negative otherwise.
284 */
285static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen)
286{
287 struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr;
288 struct sock *sk = sock->sk;
289 struct llc_sock *llc = llc_sk(sk);
290 struct llc_sap *sap;
291 int rc = -EINVAL;
292
293 dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap);
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300294 if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 goto out;
296 rc = -EAFNOSUPPORT;
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300297 if (unlikely(addr->sllc_family != AF_LLC))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 goto out;
299 if (!addr->sllc_sap) {
300 rc = -EUSERS;
301 addr->sllc_sap = llc_ui_autoport();
302 if (!addr->sllc_sap)
303 goto out;
304 }
305 sap = llc_sap_find(addr->sllc_sap);
306 if (!sap) {
307 sap = llc_sap_open(addr->sllc_sap, NULL);
308 rc = -EBUSY; /* some other network layer is using the sap */
309 if (!sap)
310 goto out;
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -0300311 llc_sap_hold(sap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 } else {
313 struct llc_addr laddr, daddr;
314 struct sock *ask;
315
316 memset(&laddr, 0, sizeof(laddr));
317 memset(&daddr, 0, sizeof(daddr));
318 /*
319 * FIXME: check if the the address is multicast,
320 * only SOCK_DGRAM can do this.
321 */
322 memcpy(laddr.mac, addr->sllc_mac, IFHWADDRLEN);
323 laddr.lsap = addr->sllc_sap;
324 rc = -EADDRINUSE; /* mac + sap clash. */
325 ask = llc_lookup_established(sap, &daddr, &laddr);
326 if (ask) {
327 sock_put(ask);
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -0300328 goto out_put;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 }
330 }
331 llc->laddr.lsap = addr->sllc_sap;
332 memcpy(llc->laddr.mac, addr->sllc_mac, IFHWADDRLEN);
333 memcpy(&llc->addr, addr, sizeof(llc->addr));
334 /* assign new connection to its SAP */
335 llc_sap_add_socket(sap, sk);
336 sock_reset_flag(sk, SOCK_ZAPPED);
337 rc = 0;
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -0300338out_put:
339 llc_sap_put(sap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340out:
341 return rc;
342}
343
344/**
345 * llc_ui_shutdown - shutdown a connect llc2 socket.
346 * @sock: Socket to shutdown.
347 * @how: What part of the socket to shutdown.
348 *
349 * Shutdown a connected llc2 socket. Currently this function only supports
350 * shutting down both sends and receives (2), we could probably make this
351 * function such that a user can shutdown only half the connection but not
352 * right now.
353 * Returns: 0 upon success, negative otherwise.
354 */
355static int llc_ui_shutdown(struct socket *sock, int how)
356{
357 struct sock *sk = sock->sk;
358 int rc = -ENOTCONN;
359
360 lock_sock(sk);
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300361 if (unlikely(sk->sk_state != TCP_ESTABLISHED))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 goto out;
363 rc = -EINVAL;
364 if (how != 2)
365 goto out;
366 rc = llc_send_disc(sk);
367 if (!rc)
368 rc = llc_ui_wait_for_disc(sk, sk->sk_rcvtimeo);
369 /* Wake up anyone sleeping in poll */
370 sk->sk_state_change(sk);
371out:
372 release_sock(sk);
373 return rc;
374}
375
376/**
377 * llc_ui_connect - Connect to a remote llc2 mac + sap.
378 * @sock: Socket which will be connected to the remote destination.
379 * @uaddr: Remote and possibly the local address of the new connection.
380 * @addrlen: Size of uaddr structure.
381 * @flags: Operational flags specified by the user.
382 *
383 * Connect to a remote llc2 mac + sap. The caller must specify the
384 * destination mac and address to connect to. If the user hasn't previously
385 * called bind(2) with a smac the address of the first interface of the
386 * specified arp type will be used.
387 * This function will autobind if user did not previously call bind.
388 * Returns: 0 upon success, negative otherwise.
389 */
390static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr,
391 int addrlen, int flags)
392{
393 struct sock *sk = sock->sk;
394 struct llc_sock *llc = llc_sk(sk);
395 struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 int rc = -EINVAL;
397
398 lock_sock(sk);
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300399 if (unlikely(addrlen != sizeof(*addr)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 goto out;
401 rc = -EAFNOSUPPORT;
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300402 if (unlikely(addr->sllc_family != AF_LLC))
403 goto out;
404 if (unlikely(sk->sk_type != SOCK_STREAM))
405 goto out;
406 rc = -EALREADY;
407 if (unlikely(sock->state == SS_CONNECTING))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 goto out;
409 /* bind connection to sap if user hasn't done it. */
410 if (sock_flag(sk, SOCK_ZAPPED)) {
411 /* bind to sap with null dev, exclusive */
412 rc = llc_ui_autobind(sock, addr);
413 if (rc)
414 goto out;
415 llc->daddr.lsap = addr->sllc_sap;
416 memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN);
417 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 sock->state = SS_CONNECTING;
419 sk->sk_state = TCP_SYN_SENT;
420 llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap);
Arnaldo Carvalho de Melo774ccb42005-09-22 03:53:35 -0300421 rc = llc_establish_connection(sk, llc->dev->dev_addr,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 addr->sllc_mac, addr->sllc_sap);
423 if (rc) {
424 dprintk("%s: llc_ui_send_conn failed :-(\n", __FUNCTION__);
425 sock->state = SS_UNCONNECTED;
426 sk->sk_state = TCP_CLOSE;
427 goto out;
428 }
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300429
430 if (sk->sk_state == TCP_SYN_SENT) {
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -0300431 const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300432
433 if (!timeo || !llc_ui_wait_for_conn(sk, timeo))
434 goto out;
435
436 rc = sock_intr_errno(timeo);
437 if (signal_pending(current))
438 goto out;
439 }
440
441 if (sk->sk_state == TCP_CLOSE)
442 goto sock_error;
443
444 sock->state = SS_CONNECTED;
445 rc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446out:
447 release_sock(sk);
448 return rc;
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300449sock_error:
450 rc = sock_error(sk) ? : -ECONNABORTED;
451 sock->state = SS_UNCONNECTED;
452 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453}
454
455/**
456 * llc_ui_listen - allow a normal socket to accept incoming connections
457 * @sock: Socket to allow incoming connections on.
458 * @backlog: Number of connections to queue.
459 *
460 * Allow a normal socket to accept incoming connections.
461 * Returns 0 upon success, negative otherwise.
462 */
463static int llc_ui_listen(struct socket *sock, int backlog)
464{
465 struct sock *sk = sock->sk;
466 int rc = -EINVAL;
467
468 lock_sock(sk);
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300469 if (unlikely(sock->state != SS_UNCONNECTED))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 goto out;
471 rc = -EOPNOTSUPP;
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300472 if (unlikely(sk->sk_type != SOCK_STREAM))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 goto out;
474 rc = -EAGAIN;
475 if (sock_flag(sk, SOCK_ZAPPED))
476 goto out;
477 rc = 0;
478 if (!(unsigned)backlog) /* BSDism */
479 backlog = 1;
480 sk->sk_max_ack_backlog = backlog;
481 if (sk->sk_state != TCP_LISTEN) {
482 sk->sk_ack_backlog = 0;
483 sk->sk_state = TCP_LISTEN;
484 }
485 sk->sk_socket->flags |= __SO_ACCEPTCON;
486out:
487 release_sock(sk);
488 return rc;
489}
490
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -0300491static int llc_ui_wait_for_disc(struct sock *sk, long timeout)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492{
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300493 DEFINE_WAIT(wait);
494 int rc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -0300496 while (1) {
497 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
498 if (sk_wait_event(sk, &timeout, sk->sk_state == TCP_CLOSE))
499 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 rc = -ERESTARTSYS;
501 if (signal_pending(current))
502 break;
503 rc = -EAGAIN;
504 if (!timeout)
505 break;
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300506 rc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 }
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300508 finish_wait(sk->sk_sleep, &wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 return rc;
510}
511
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -0300512static int llc_ui_wait_for_conn(struct sock *sk, long timeout)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513{
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300514 DEFINE_WAIT(wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -0300516 while (1) {
517 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
518 if (sk_wait_event(sk, &timeout, sk->sk_state != TCP_SYN_SENT))
519 break;
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300520 if (signal_pending(current) || !timeout)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 }
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300523 finish_wait(sk->sk_sleep, &wait);
524 return timeout;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525}
526
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -0300527static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528{
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300529 DEFINE_WAIT(wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 struct llc_sock *llc = llc_sk(sk);
531 int rc;
532
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -0300533 while (1) {
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300534 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 rc = 0;
Arnaldo Carvalho de Melo54fb7f22005-09-22 04:26:14 -0300536 if (sk_wait_event(sk, &timeout,
537 (sk->sk_shutdown & RCV_SHUTDOWN) ||
538 (!llc_data_accept_state(llc->state) &&
539 !llc->p_flag)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 break;
541 rc = -ERESTARTSYS;
542 if (signal_pending(current))
543 break;
544 rc = -EAGAIN;
545 if (!timeout)
546 break;
547 }
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300548 finish_wait(sk->sk_sleep, &wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 return rc;
550}
551
Arnaldo Carvalho de Meloafdbe352005-09-22 04:37:07 -0300552int llc_wait_data(struct sock *sk, long timeo)
553{
554 int rc;
555
556 while (1) {
557 /*
558 * POSIX 1003.1g mandates this order.
559 */
560 if (sk->sk_err) {
561 rc = sock_error(sk);
562 break;
563 }
564 rc = 0;
565 if (sk->sk_shutdown & RCV_SHUTDOWN)
566 break;
567 rc = -EAGAIN;
568 if (!timeo)
569 break;
570 rc = sock_intr_errno(timeo);
571 if (signal_pending(current))
572 break;
573 rc = 0;
574 if (sk_wait_data(sk, &timeo))
575 break;
576 }
577 return rc;
578}
579
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580/**
581 * llc_ui_accept - accept a new incoming connection.
582 * @sock: Socket which connections arrive on.
583 * @newsock: Socket to move incoming connection to.
584 * @flags: User specified operational flags.
585 *
586 * Accept a new incoming connection.
587 * Returns 0 upon success, negative otherwise.
588 */
589static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags)
590{
591 struct sock *sk = sock->sk, *newsk;
592 struct llc_sock *llc, *newllc;
593 struct sk_buff *skb;
594 int rc = -EOPNOTSUPP;
595
596 dprintk("%s: accepting on %02X\n", __FUNCTION__,
597 llc_sk(sk)->laddr.lsap);
598 lock_sock(sk);
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300599 if (unlikely(sk->sk_type != SOCK_STREAM))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 goto out;
601 rc = -EINVAL;
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300602 if (unlikely(sock->state != SS_UNCONNECTED ||
603 sk->sk_state != TCP_LISTEN))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 goto out;
605 /* wait for a connection to arrive. */
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300606 if (skb_queue_empty(&sk->sk_receive_queue)) {
Arnaldo Carvalho de Meloafdbe352005-09-22 04:37:07 -0300607 rc = llc_wait_data(sk, sk->sk_rcvtimeo);
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300608 if (rc)
609 goto out;
610 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 dprintk("%s: got a new connection on %02X\n", __FUNCTION__,
612 llc_sk(sk)->laddr.lsap);
613 skb = skb_dequeue(&sk->sk_receive_queue);
614 rc = -EINVAL;
615 if (!skb->sk)
616 goto frees;
617 rc = 0;
618 newsk = skb->sk;
619 /* attach connection to a new socket. */
620 llc_ui_sk_init(newsock, newsk);
621 sock_reset_flag(newsk, SOCK_ZAPPED);
622 newsk->sk_state = TCP_ESTABLISHED;
623 newsock->state = SS_CONNECTED;
624 llc = llc_sk(sk);
625 newllc = llc_sk(newsk);
626 memcpy(&newllc->addr, &llc->addr, sizeof(newllc->addr));
627 newllc->link = llc_ui_next_link_no(newllc->laddr.lsap);
628
629 /* put original socket back into a clean listen state. */
630 sk->sk_state = TCP_LISTEN;
631 sk->sk_ack_backlog--;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 dprintk("%s: ok success on %02X, client on %02X\n", __FUNCTION__,
633 llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap);
634frees:
635 kfree_skb(skb);
636out:
637 release_sock(sk);
638 return rc;
639}
640
641/**
642 * llc_ui_recvmsg - copy received data to the socket user.
643 * @sock: Socket to copy data from.
644 * @msg: Various user space related information.
645 * @size: Size of user buffer.
646 * @flags: User specified flags.
647 *
648 * Copy received data to the socket user.
649 * Returns non-negative upon success, negative otherwise.
650 */
651static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
652 struct msghdr *msg, size_t size, int flags)
653{
654 struct sock *sk = sock->sk;
655 struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name;
656 struct sk_buff *skb;
657 size_t copied = 0;
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300658 int rc = -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 int noblock = flags & MSG_DONTWAIT;
660
661 dprintk("%s: receiving in %02X from %02X\n", __FUNCTION__,
662 llc_sk(sk)->laddr.lsap, llc_sk(sk)->daddr.lsap);
663 lock_sock(sk);
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300664 if (skb_queue_empty(&sk->sk_receive_queue)) {
Arnaldo Carvalho de Meloafdbe352005-09-22 04:37:07 -0300665 rc = llc_wait_data(sk, sock_rcvtimeo(sk, noblock));
Arnaldo Carvalho de Melob35bd112005-09-22 04:22:39 -0300666 if (rc)
667 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 }
669 skb = skb_dequeue(&sk->sk_receive_queue);
670 if (!skb) /* shutdown */
671 goto out;
672 copied = skb->len;
673 if (copied > size)
674 copied = size;
675 rc = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
676 if (rc)
677 goto dgram_free;
678 if (skb->len > copied) {
679 skb_pull(skb, copied);
680 skb_queue_head(&sk->sk_receive_queue, skb);
681 }
682 if (uaddr)
683 memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr));
684 msg->msg_namelen = sizeof(*uaddr);
David S. Miller8728b832005-08-09 19:25:21 -0700685 if (!skb->next) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686dgram_free:
687 kfree_skb(skb);
688 }
689out:
690 release_sock(sk);
691 return rc ? : copied;
692}
693
694/**
695 * llc_ui_sendmsg - Transmit data provided by the socket user.
696 * @sock: Socket to transmit data from.
697 * @msg: Various user related information.
698 * @len: Length of data to transmit.
699 *
700 * Transmit data provided by the socket user.
701 * Returns non-negative upon success, negative otherwise.
702 */
703static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock,
704 struct msghdr *msg, size_t len)
705{
706 struct sock *sk = sock->sk;
707 struct llc_sock *llc = llc_sk(sk);
708 struct sockaddr_llc *addr = (struct sockaddr_llc *)msg->msg_name;
709 int flags = msg->msg_flags;
710 int noblock = flags & MSG_DONTWAIT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 struct sk_buff *skb;
712 size_t size = 0;
713 int rc = -EINVAL, copied = 0, hdrlen;
714
715 dprintk("%s: sending from %02X to %02X\n", __FUNCTION__,
716 llc->laddr.lsap, llc->daddr.lsap);
717 lock_sock(sk);
718 if (addr) {
719 if (msg->msg_namelen < sizeof(*addr))
720 goto release;
721 } else {
722 if (llc_ui_addr_null(&llc->addr))
723 goto release;
724 addr = &llc->addr;
725 }
726 /* must bind connection to sap if user hasn't done it. */
727 if (sock_flag(sk, SOCK_ZAPPED)) {
728 /* bind to sap with null dev, exclusive. */
729 rc = llc_ui_autobind(sock, addr);
730 if (rc)
731 goto release;
732 }
Arnaldo Carvalho de Melo774ccb42005-09-22 03:53:35 -0300733 hdrlen = llc->dev->hard_header_len + llc_ui_header_len(sk, addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 size = hdrlen + len;
Arnaldo Carvalho de Melo774ccb42005-09-22 03:53:35 -0300735 if (size > llc->dev->mtu)
736 size = llc->dev->mtu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 copied = size - hdrlen;
738 release_sock(sk);
739 skb = sock_alloc_send_skb(sk, size, noblock, &rc);
740 lock_sock(sk);
741 if (!skb)
742 goto release;
Arnaldo Carvalho de Melo774ccb42005-09-22 03:53:35 -0300743 skb->dev = llc->dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 skb->protocol = llc_proto_type(addr->sllc_arphrd);
745 skb_reserve(skb, hdrlen);
746 rc = memcpy_fromiovec(skb_put(skb, copied), msg->msg_iov, copied);
747 if (rc)
748 goto out;
749 if (sk->sk_type == SOCK_DGRAM || addr->sllc_ua) {
750 llc_build_and_send_ui_pkt(llc->sap, skb, addr->sllc_mac,
751 addr->sllc_sap);
752 goto out;
753 }
754 if (addr->sllc_test) {
755 llc_build_and_send_test_pkt(llc->sap, skb, addr->sllc_mac,
756 addr->sllc_sap);
757 goto out;
758 }
759 if (addr->sllc_xid) {
760 llc_build_and_send_xid_pkt(llc->sap, skb, addr->sllc_mac,
761 addr->sllc_sap);
762 goto out;
763 }
764 rc = -ENOPROTOOPT;
765 if (!(sk->sk_type == SOCK_STREAM && !addr->sllc_ua))
766 goto out;
767 rc = llc_ui_send_data(sk, skb, noblock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768out:
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300769 if (rc) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 kfree_skb(skb);
771release:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 dprintk("%s: failed sending from %02X to %02X: %d\n",
773 __FUNCTION__, llc->laddr.lsap, llc->daddr.lsap, rc);
Arnaldo Carvalho de Melo249ff1c2005-09-22 04:32:10 -0300774 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 release_sock(sk);
776 return rc ? : copied;
777}
778
779/**
780 * llc_ui_getname - return the address info of a socket
781 * @sock: Socket to get address of.
782 * @uaddr: Address structure to return information.
783 * @uaddrlen: Length of address structure.
784 * @peer: Does user want local or remote address information.
785 *
786 * Return the address information of a socket.
787 */
788static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr,
789 int *uaddrlen, int peer)
790{
791 struct sockaddr_llc sllc;
792 struct sock *sk = sock->sk;
793 struct llc_sock *llc = llc_sk(sk);
794 int rc = 0;
795
796 lock_sock(sk);
797 if (sock_flag(sk, SOCK_ZAPPED))
798 goto out;
799 *uaddrlen = sizeof(sllc);
800 memset(uaddr, 0, *uaddrlen);
801 if (peer) {
802 rc = -ENOTCONN;
803 if (sk->sk_state != TCP_ESTABLISHED)
804 goto out;
805 if(llc->dev)
806 sllc.sllc_arphrd = llc->dev->type;
807 sllc.sllc_sap = llc->daddr.lsap;
808 memcpy(&sllc.sllc_mac, &llc->daddr.mac, IFHWADDRLEN);
809 } else {
810 rc = -EINVAL;
811 if (!llc->sap)
812 goto out;
813 sllc.sllc_sap = llc->sap->laddr.lsap;
814
815 if (llc->dev) {
816 sllc.sllc_arphrd = llc->dev->type;
817 memcpy(&sllc.sllc_mac, &llc->dev->dev_addr,
818 IFHWADDRLEN);
819 }
820 }
821 rc = 0;
822 sllc.sllc_family = AF_LLC;
823 memcpy(uaddr, &sllc, sizeof(sllc));
824out:
825 release_sock(sk);
826 return rc;
827}
828
829/**
830 * llc_ui_ioctl - io controls for PF_LLC
831 * @sock: Socket to get/set info
832 * @cmd: command
833 * @arg: optional argument for cmd
834 *
835 * get/set info on llc sockets
836 */
837static int llc_ui_ioctl(struct socket *sock, unsigned int cmd,
838 unsigned long arg)
839{
840 return dev_ioctl(cmd, (void __user *)arg);
841}
842
843/**
844 * llc_ui_setsockopt - set various connection specific parameters.
845 * @sock: Socket to set options on.
846 * @level: Socket level user is requesting operations on.
847 * @optname: Operation name.
848 * @optval User provided operation data.
849 * @optlen: Length of optval.
850 *
851 * Set various connection specific parameters.
852 */
853static int llc_ui_setsockopt(struct socket *sock, int level, int optname,
854 char __user *optval, int optlen)
855{
856 struct sock *sk = sock->sk;
857 struct llc_sock *llc = llc_sk(sk);
858 int rc = -EINVAL, opt;
859
860 lock_sock(sk);
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300861 if (unlikely(level != SOL_LLC || optlen != sizeof(int)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 goto out;
863 rc = get_user(opt, (int __user *)optval);
864 if (rc)
865 goto out;
866 rc = -EINVAL;
867 switch (optname) {
868 case LLC_OPT_RETRY:
869 if (opt > LLC_OPT_MAX_RETRY)
870 goto out;
871 llc->n2 = opt;
872 break;
873 case LLC_OPT_SIZE:
874 if (opt > LLC_OPT_MAX_SIZE)
875 goto out;
876 llc->n1 = opt;
877 break;
878 case LLC_OPT_ACK_TMR_EXP:
879 if (opt > LLC_OPT_MAX_ACK_TMR_EXP)
880 goto out;
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300881 llc->ack_timer.expire = opt * HZ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 break;
883 case LLC_OPT_P_TMR_EXP:
884 if (opt > LLC_OPT_MAX_P_TMR_EXP)
885 goto out;
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300886 llc->pf_cycle_timer.expire = opt * HZ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 break;
888 case LLC_OPT_REJ_TMR_EXP:
889 if (opt > LLC_OPT_MAX_REJ_TMR_EXP)
890 goto out;
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300891 llc->rej_sent_timer.expire = opt * HZ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 break;
893 case LLC_OPT_BUSY_TMR_EXP:
894 if (opt > LLC_OPT_MAX_BUSY_TMR_EXP)
895 goto out;
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300896 llc->busy_state_timer.expire = opt * HZ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 break;
898 case LLC_OPT_TX_WIN:
899 if (opt > LLC_OPT_MAX_WIN)
900 goto out;
901 llc->k = opt;
902 break;
903 case LLC_OPT_RX_WIN:
904 if (opt > LLC_OPT_MAX_WIN)
905 goto out;
906 llc->rw = opt;
907 break;
908 default:
909 rc = -ENOPROTOOPT;
910 goto out;
911 }
912 rc = 0;
913out:
914 release_sock(sk);
915 return rc;
916}
917
918/**
919 * llc_ui_getsockopt - get connection specific socket info
920 * @sock: Socket to get information from.
921 * @level: Socket level user is requesting operations on.
922 * @optname: Operation name.
923 * @optval: Variable to return operation data in.
924 * @optlen: Length of optval.
925 *
926 * Get connection specific socket information.
927 */
928static int llc_ui_getsockopt(struct socket *sock, int level, int optname,
929 char __user *optval, int __user *optlen)
930{
931 struct sock *sk = sock->sk;
932 struct llc_sock *llc = llc_sk(sk);
933 int val = 0, len = 0, rc = -EINVAL;
934
935 lock_sock(sk);
Arnaldo Carvalho de Meloaf426d32005-09-22 03:59:22 -0300936 if (unlikely(level != SOL_LLC))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 goto out;
938 rc = get_user(len, optlen);
939 if (rc)
940 goto out;
941 rc = -EINVAL;
942 if (len != sizeof(int))
943 goto out;
944 switch (optname) {
945 case LLC_OPT_RETRY:
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300946 val = llc->n2; break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 case LLC_OPT_SIZE:
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300948 val = llc->n1; break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 case LLC_OPT_ACK_TMR_EXP:
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300950 val = llc->ack_timer.expire / HZ; break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 case LLC_OPT_P_TMR_EXP:
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300952 val = llc->pf_cycle_timer.expire / HZ; break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 case LLC_OPT_REJ_TMR_EXP:
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300954 val = llc->rej_sent_timer.expire / HZ; break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 case LLC_OPT_BUSY_TMR_EXP:
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300956 val = llc->busy_state_timer.expire / HZ; break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 case LLC_OPT_TX_WIN:
958 val = llc->k; break;
959 case LLC_OPT_RX_WIN:
960 val = llc->rw; break;
961 default:
962 rc = -ENOPROTOOPT;
963 goto out;
964 }
965 rc = 0;
966 if (put_user(len, optlen) || copy_to_user(optval, &val, len))
967 rc = -EFAULT;
968out:
969 release_sock(sk);
970 return rc;
971}
972
973static struct net_proto_family llc_ui_family_ops = {
974 .family = PF_LLC,
975 .create = llc_ui_create,
976 .owner = THIS_MODULE,
977};
978
979static struct proto_ops llc_ui_ops = {
980 .family = PF_LLC,
981 .owner = THIS_MODULE,
982 .release = llc_ui_release,
983 .bind = llc_ui_bind,
984 .connect = llc_ui_connect,
985 .socketpair = sock_no_socketpair,
986 .accept = llc_ui_accept,
987 .getname = llc_ui_getname,
988 .poll = datagram_poll,
989 .ioctl = llc_ui_ioctl,
990 .listen = llc_ui_listen,
991 .shutdown = llc_ui_shutdown,
992 .setsockopt = llc_ui_setsockopt,
993 .getsockopt = llc_ui_getsockopt,
994 .sendmsg = llc_ui_sendmsg,
995 .recvmsg = llc_ui_recvmsg,
996 .mmap = sock_no_mmap,
997 .sendpage = sock_no_sendpage,
998};
999
1000extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
1001extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
1002
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -03001003static char llc_proc_err_msg[] __initdata =
1004 KERN_CRIT "LLC: Unable to register the proc_fs entries\n";
1005static char llc_sysctl_err_msg[] __initdata =
1006 KERN_CRIT "LLC: Unable to register the sysctl entries\n";
1007static char llc_sock_err_msg[] __initdata =
1008 KERN_CRIT "LLC: Unable to register the network family\n";
1009
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010static int __init llc2_init(void)
1011{
1012 int rc = proto_register(&llc_proto, 0);
1013
1014 if (rc != 0)
1015 goto out;
1016
1017 llc_build_offset_table();
1018 llc_station_init();
1019 llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
1020 rc = llc_proc_init();
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -03001021 if (rc != 0) {
1022 printk(llc_proc_err_msg);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023 goto out_unregister_llc_proto;
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -03001024 }
1025 rc = llc_sysctl_init();
1026 if (rc) {
1027 printk(llc_sysctl_err_msg);
1028 goto out_proc;
1029 }
1030 rc = sock_register(&llc_ui_family_ops);
1031 if (rc) {
1032 printk(llc_sock_err_msg);
1033 goto out_sysctl;
1034 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035 llc_add_pack(LLC_DEST_SAP, llc_sap_handler);
1036 llc_add_pack(LLC_DEST_CONN, llc_conn_handler);
1037out:
1038 return rc;
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -03001039out_sysctl:
1040 llc_sysctl_exit();
1041out_proc:
1042 llc_proc_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043out_unregister_llc_proto:
1044 proto_unregister(&llc_proto);
1045 goto out;
1046}
1047
1048static void __exit llc2_exit(void)
1049{
1050 llc_station_exit();
1051 llc_remove_pack(LLC_DEST_SAP);
1052 llc_remove_pack(LLC_DEST_CONN);
1053 sock_unregister(PF_LLC);
1054 llc_proc_exit();
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -03001055 llc_sysctl_exit();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 proto_unregister(&llc_proto);
1057}
1058
1059module_init(llc2_init);
1060module_exit(llc2_exit);
1061
1062MODULE_LICENSE("GPL");
1063MODULE_AUTHOR("Procom 1997, Jay Schullist 2001, Arnaldo C. Melo 2001-2003");
1064MODULE_DESCRIPTION("IEEE 802.2 PF_LLC support");
1065MODULE_ALIAS_NETPROTO(PF_LLC);