o LLC: split llc into llc_core and llc2 modules

For this some more functions had to be moved around, now one doesn't
have to explicitely select LLC to have access in the menu to ipx,
appletalk, token ring, etc.

This is not yet as good as I want it to be, but at least makes it
easier for the hordes of users to select stuff, making it look more
like how it was in 2.4.

In the next changesets I'll fix the fact that CONFIG_TR is a bool
and makes psnap, p8022 and llc_core to be built statically even tho
the token ring drivers are being build as modules.
parent 51383b5f
......@@ -2,13 +2,14 @@
# Token Ring driver configuration
#
menu "Token Ring devices (depends on LLC=y)"
menu "Token Ring devices"
depends on NETDEVICES
# So far, we only have PCI, ISA, and MCA token ring devices
config TR
bool "Token Ring driver support"
depends on (PCI || ISA || MCA || CCW) && LLC=y
depends on (PCI || ISA || MCA || CCW)
select LLC_CORE
help
Token Ring is IBM's way of communication on a local network; the
rest of the world uses Ethernet. To participate on a Token Ring
......
......@@ -79,13 +79,5 @@ enum llc_sockopts {
#define LLC_SAP_DYN_TRIES 4
#define llc_ui_skb_cb(__skb) ((struct sockaddr_llc *)&((__skb)->cb[0]))
#ifdef CONFIG_LLC_UI
extern int llc_ui_init(void);
extern void llc_ui_exit(void);
#else
#define llc_ui_init()
#define llc_ui_exit()
#endif
#endif /* __KERNEL__ */
#endif /* __LINUX_LLC_H */
......@@ -100,6 +100,9 @@ extern struct sock *llc_lookup_established(struct llc_sap *sap,
struct llc_addr *laddr);
extern struct sock *llc_lookup_listener(struct llc_sap *sap,
struct llc_addr *laddr);
extern void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk);
extern void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk);
extern u8 llc_data_accept_state(u8 state);
extern void llc_build_offset_table(void);
extern int llc_release_sockets(struct llc_sap *sap);
......
......@@ -40,8 +40,6 @@ struct llc_sap {
} sk_list;
};
extern void llc_sap_assign_sock(struct llc_sap *sap, struct sock *sk);
extern void llc_sap_unassign_sock(struct llc_sap *sap, struct sock *sk);
extern void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb);
extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb);
extern void llc_save_primitive(struct sk_buff* skb, u8 prim);
......
......@@ -370,24 +370,11 @@ config ATM_BR2684_IPFILTER
config VLAN_8021Q
tristate "802.1Q VLAN Support"
config LLC
tristate "ANSI/IEEE 802.2 - aka LLC (IPX, Appletalk, Token Ring)"
help
This is a Logical Link Layer protocol used for Appletalk, IPX,
Token Ring devices, the linux-sna.org project and in the future by
NetBEUI. It originally came from Procom Inc. that released the code
for 2.0.36 and was heavily modified to work with 2.{4,5}.
Select this if you want to have support for those protocols or if
you want to have the sockets interface for LLC.
config LLC_UI
bool "LLC sockets interface"
depends on LLC
source "net/llc/Kconfig"
config IPX
tristate "The IPX protocol"
depends on LLC
select LLC_CORE
---help---
This is support for the Novell networking protocol, IPX, commonly
used for local networks of Windows machines. You need it if you
......@@ -424,7 +411,7 @@ source "net/ipx/Kconfig"
config ATALK
tristate "Appletalk protocol support"
depends on LLC
select LLC_CORE
---help---
AppleTalk is the protocol that Apple computers can use to communicate
on a network. If your Linux box is connected to such a network and you
......@@ -479,9 +466,8 @@ config X25
using the X.21 protocol (not yet supported by Linux) or one can do
X.25 over a standard telephone line using an ordinary modem (say Y
to "X.25 async driver" below) or over Ethernet using an ordinary
Ethernet card and either the 802.2 LLC protocol (say Y to "802.2
LLC" below) or LAPB over Ethernet (say Y to "LAPB Data Link Driver"
and "LAPB over Ethernet driver" below).
Ethernet card and the LAPB over Ethernet (say Y to "LAPB Data Link
Driver" and "LAPB over Ethernet driver" below).
If you want to compile this driver as a module ( = code which can be
inserted in and removed from the running kernel whenever you want),
......
......@@ -12,7 +12,7 @@ obj-$(CONFIG_NET) := socket.o core/
obj-$(CONFIG_COMPAT) += compat.o
# LLC has to be linked before the files in net/802/
obj-$(CONFIG_LLC) += llc/
obj-$(CONFIG_LLC_CORE) += llc/
obj-$(CONFIG_NET) += ethernet/ 802/ sched/ netlink/
obj-$(CONFIG_INET) += ipv4/ xfrm/
obj-$(CONFIG_UNIX) += unix/
......
config LLC_CORE
tristate
depends on NET
config LLC2
tristate "ANSI/IEEE 802.2 LLC type 2 Support"
select LLC_CORE
help
This is a Logical Link Layer type 2, connection oriented support.
Select this if you want to have support for PF_LLC sockets.
......@@ -2,7 +2,7 @@
# Makefile for the Linux 802.2 LLC (fully-functional) layer.
#
# Copyright (c) 1997 by Procom Technology,Inc.
# 2001, 2002 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
# 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
#
# This program can be redistributed or modified under the terms of the
# GNU General Public License as published by the Free Software Foundation.
......@@ -12,9 +12,14 @@
# See the GNU General Public License for more details.
###########################################################################
obj-$(CONFIG_LLC) += llc.o
obj-$(CONFIG_LLC_CORE) += llc_core.o
llc-y := llc_if.o llc_c_ev.o llc_c_ac.o llc_mac.o llc_sap.o llc_s_st.o \
llc_main.o llc_s_ac.o llc_conn.o llc_c_st.o llc_stat.o llc_actn.o \
llc_s_ev.o llc_evnt.o llc_pdu.o llc_proc.o
llc-$(CONFIG_LLC_UI) += af_llc.o
llc_core-y := llc_mac.o llc_sap.o llc_s_st.o llc_s_ac.o llc_s_ev.o llc_main.o \
llc_actn.o llc_stat.o llc_evnt.o
obj-$(CONFIG_LLC2) += llc2.o
llc2-y := llc_if.o llc_c_ev.o llc_c_ac.o llc_conn.o llc_c_st.o llc_pdu.o \
af_llc.o
llc2-$(CONFIG_PROC_FS) += llc_proc.o
......@@ -29,6 +29,7 @@
#include <net/llc_conn.h>
#include <net/llc_mac.h>
#include <net/llc_main.h>
#include <net/llc_proc.h>
#include <linux/rtnetlink.h>
#include <linux/init.h>
......@@ -182,7 +183,7 @@ static int llc_ui_release(struct socket *sock)
if (!llc_send_disc(sk))
llc_ui_wait_for_disc(sk, sk->sk_rcvtimeo);
if (!sk->sk_zapped)
llc_sap_unassign_sock(llc->sap, sk);
llc_sap_remove_socket(llc->sap, sk);
release_sock(sk);
if (llc->sap && hlist_empty(&llc->sap->sk_list.list)) {
llc_release_sockets(llc->sap);
......@@ -305,7 +306,7 @@ static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr)
memcpy(llc->daddr.mac, addr->sllc_dmac, IFHWADDRLEN);
memcpy(&llc->addr, addr, sizeof(llc->addr));
/* assign new connection to its SAP */
llc_sap_assign_sock(sap, sk);
llc_sap_add_socket(sap, sk);
rc = sk->sk_zapped = 0;
out:
return rc;
......@@ -1044,14 +1045,36 @@ static struct proto_ops llc_ui_ops = {
.sendpage = sock_no_sendpage,
};
int __init llc_ui_init(void)
extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
static int __init llc2_init(void)
{
int rc;
llc_build_offset_table();
llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
sock_register(&llc_ui_family_ops);
return 0;
rc = llc_proc_init();
if (!rc) {
sock_register(&llc_ui_family_ops);
llc_add_pack(LLC_DEST_SAP, llc_sap_handler);
llc_add_pack(LLC_DEST_CONN, llc_conn_handler);
}
return rc;
}
void __exit llc_ui_exit(void)
static void __exit llc2_exit(void)
{
llc_remove_pack(LLC_DEST_SAP);
llc_remove_pack(LLC_DEST_CONN);
sock_unregister(PF_LLC);
llc_proc_exit();
}
module_init(llc2_init);
module_exit(llc2_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Procom 1997, Jay Schullist 2001, Arnaldo C. Melo 2001-2003");
MODULE_DESCRIPTION("IEEE 802.2 PF_LLC support");
MODULE_ALIAS_NETPROTO(PF_LLC);
......@@ -613,6 +613,36 @@ static int llc_find_offset(int state, int ev_type)
return rc;
}
/**
* llc_sap_add_socket - adds a socket to a SAP
* @sap: SAP
* @sk: socket
*
* This function adds a socket to sk_list of a SAP.
*/
void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk)
{
write_lock_bh(&sap->sk_list.lock);
llc_sk(sk)->sap = sap;
sk_add_node(sk, &sap->sk_list.list);
write_unlock_bh(&sap->sk_list.lock);
}
/**
* llc_sap_remove_socket - removes a socket from SAP
* @sap: SAP
* @sk: socket
*
* This function removes a connection from sk_list.list of a SAP if
* the connection was in this list.
*/
void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk)
{
write_lock_bh(&sap->sk_list.lock);
sk_del_node_init(sk);
write_unlock_bh(&sap->sk_list.lock);
}
/**
* llc_conn_rcv - sends received pdus to the connection state machine
* @sk: current connection structure.
......@@ -664,7 +694,7 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb)
llc = llc_sk(sk);
memcpy(&llc->laddr, &daddr, sizeof(llc->laddr));
memcpy(&llc->daddr, &saddr, sizeof(llc->daddr));
llc_sap_assign_sock(sap, sk);
llc_sap_add_socket(sap, sk);
sock_hold(sk);
sock_put(parent);
skb->sk = parent;
......@@ -902,4 +932,3 @@ void llc_sk_reset(struct sock *sk)
llc->failed_data_req = 0 ;
llc->last_nr = 0;
}
......@@ -29,58 +29,6 @@
u8 llc_mac_null_var[IFHWADDRLEN];
/**
* llc_build_and_send_test_pkt - TEST interface for upper layers.
* @sap: sap to use
* @skb: packet to send
* @dmac: destination mac address
* @dsap: destination sap
*
* This function is called when upper layer wants to send a TEST pdu.
* Returns 0 for success, 1 otherwise.
*/
void llc_build_and_send_test_pkt(struct llc_sap *sap,
struct sk_buff *skb, u8 *dmac, u8 dsap)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
ev->saddr.lsap = sap->laddr.lsap;
ev->daddr.lsap = dsap;
memcpy(ev->saddr.mac, skb->dev->dev_addr, IFHWADDRLEN);
memcpy(ev->daddr.mac, dmac, IFHWADDRLEN);
ev->type = LLC_SAP_EV_TYPE_PRIM;
ev->prim = LLC_TEST_PRIM;
ev->prim_type = LLC_PRIM_TYPE_REQ;
llc_sap_state_process(sap, skb);
}
/**
* llc_build_and_send_xid_pkt - XID interface for upper layers
* @sap: sap to use
* @skb: packet to send
* @dmac: destination mac address
* @dsap: destination sap
*
* This function is called when upper layer wants to send a XID pdu.
* Returns 0 for success, 1 otherwise.
*/
void llc_build_and_send_xid_pkt(struct llc_sap *sap, struct sk_buff *skb,
u8 *dmac, u8 dsap)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
ev->saddr.lsap = sap->laddr.lsap;
ev->daddr.lsap = dsap;
memcpy(ev->saddr.mac, skb->dev->dev_addr, IFHWADDRLEN);
memcpy(ev->daddr.mac, dmac, IFHWADDRLEN);
ev->type = LLC_SAP_EV_TYPE_PRIM;
ev->prim = LLC_XID_PRIM;
ev->prim_type = LLC_PRIM_TYPE_REQ;
llc_sap_state_process(sap, skb);
}
/**
* llc_build_and_send_pkt - Connection data sending for upper layers.
* @sk: connection
......
......@@ -300,12 +300,9 @@ static int __init llc_init(void)
llc_main_station.ack_timer.data = (unsigned long)&llc_main_station;
llc_main_station.ack_timer.function = llc_station_ack_tmr_cb;
if (llc_proc_init())
goto err;
skb = alloc_skb(0, GFP_ATOMIC);
if (!skb)
goto err_skb;
llc_build_offset_table();
goto err;
ev = llc_station_ev(skb);
memset(ev, 0, sizeof(*ev));
if (dev_base->next)
......@@ -319,13 +316,10 @@ static int __init llc_init(void)
ev->type = LLC_STATION_EV_TYPE_SIMPLE;
ev->prim_type = LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK;
rc = llc_station_next_state(&llc_main_station, skb);
llc_ui_init();
dev_add_pack(&llc_packet_type);
dev_add_pack(&llc_tr_packet_type);
out:
return rc;
err_skb:
llc_proc_exit();
err:
printk(llc_error_msg);
rc = 1;
......@@ -334,8 +328,6 @@ static int __init llc_init(void)
static void __exit llc_exit(void)
{
llc_ui_exit();
llc_proc_exit();
dev_remove_pack(&llc_packet_type);
dev_remove_pack(&llc_tr_packet_type);
}
......@@ -343,7 +335,11 @@ static void __exit llc_exit(void)
module_init(llc_init);
module_exit(llc_exit);
EXPORT_SYMBOL(llc_sap_find);
EXPORT_SYMBOL(llc_alloc_frame);
EXPORT_SYMBOL(llc_main_station);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Procom, 1997, Arnaldo C. Melo, Jay Schullist, 2001-2003");
MODULE_DESCRIPTION("LLC 2.0, IEEE 802.2 extended support");
MODULE_AUTHOR("Procom 1997, Jay Schullist 2001, Arnaldo C. Melo 2001-2003");
MODULE_DESCRIPTION("LLC IEEE 802.2 extended support");
MODULE_ALIAS_NETPROTO(PF_LLC);
......@@ -39,36 +39,6 @@ void llc_save_primitive(struct sk_buff* skb, u8 prim)
llc_pdu_decode_ssap(skb, &addr->sllc_ssap);
}
/**
* llc_sap_assign_sock - adds a connection to a SAP
* @sap: pointer to SAP.
* @conn: pointer to connection.
*
* This function adds a connection to connection_list of a SAP.
*/
void llc_sap_assign_sock(struct llc_sap *sap, struct sock *sk)
{
write_lock_bh(&sap->sk_list.lock);
llc_sk(sk)->sap = sap;
sk_add_node(sk, &sap->sk_list.list);
write_unlock_bh(&sap->sk_list.lock);
}
/**
* llc_sap_unassign_sock - removes a connection from SAP
* @sap: SAP
* @sk: pointer to connection
*
* This function removes a connection from sk_list.list of a SAP if
* the connection was in this list.
*/
void llc_sap_unassign_sock(struct llc_sap *sap, struct sock *sk)
{
write_lock_bh(&sap->sk_list.lock);
sk_del_node_init(sk);
write_unlock_bh(&sap->sk_list.lock);
}
/**
* llc_sap_rtn_pdu - Informs upper layer on rx of an UI, XID or TEST pdu.
* @sap: pointer to SAP
......@@ -240,6 +210,58 @@ void llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
llc_sap_state_process(sap, skb);
}
/**
* llc_build_and_send_test_pkt - TEST interface for upper layers.
* @sap: sap to use
* @skb: packet to send
* @dmac: destination mac address
* @dsap: destination sap
*
* This function is called when upper layer wants to send a TEST pdu.
* Returns 0 for success, 1 otherwise.
*/
void llc_build_and_send_test_pkt(struct llc_sap *sap,
struct sk_buff *skb, u8 *dmac, u8 dsap)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
ev->saddr.lsap = sap->laddr.lsap;
ev->daddr.lsap = dsap;
memcpy(ev->saddr.mac, skb->dev->dev_addr, IFHWADDRLEN);
memcpy(ev->daddr.mac, dmac, IFHWADDRLEN);
ev->type = LLC_SAP_EV_TYPE_PRIM;
ev->prim = LLC_TEST_PRIM;
ev->prim_type = LLC_PRIM_TYPE_REQ;
llc_sap_state_process(sap, skb);
}
/**
* llc_build_and_send_xid_pkt - XID interface for upper layers
* @sap: sap to use
* @skb: packet to send
* @dmac: destination mac address
* @dsap: destination sap
*
* This function is called when upper layer wants to send a XID pdu.
* Returns 0 for success, 1 otherwise.
*/
void llc_build_and_send_xid_pkt(struct llc_sap *sap, struct sk_buff *skb,
u8 *dmac, u8 dsap)
{
struct llc_sap_state_ev *ev = llc_sap_ev(skb);
ev->saddr.lsap = sap->laddr.lsap;
ev->daddr.lsap = dsap;
memcpy(ev->saddr.mac, skb->dev->dev_addr, IFHWADDRLEN);
memcpy(ev->daddr.mac, dmac, IFHWADDRLEN);
ev->type = LLC_SAP_EV_TYPE_PRIM;
ev->prim = LLC_XID_PRIM;
ev->prim_type = LLC_PRIM_TYPE_REQ;
llc_sap_state_process(sap, skb);
}
/**
* llc_sap_rcv - sends received pdus to the sap state machine
* @sap: current sap component structure.
......@@ -376,4 +398,8 @@ void llc_sap_close(struct llc_sap *sap)
EXPORT_SYMBOL(llc_sap_open);
EXPORT_SYMBOL(llc_sap_close);
EXPORT_SYMBOL(llc_save_primitive);
EXPORT_SYMBOL(llc_build_and_send_test_pkt);
EXPORT_SYMBOL(llc_build_and_send_ui_pkt);
EXPORT_SYMBOL(llc_build_and_send_xid_pkt);
EXPORT_SYMBOL(llc_sap_handler);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment