Commit e6737a9d authored by David S. Miller's avatar David S. Miller

Merge nuts.ninka.net:/home/davem/src/BK/BAK-net-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents 80e4e144 51bd89d6
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# #
mainmenu_option next_comment mainmenu_option next_comment
comment 'Appletalk devices'
dep_mbool 'Appletalk interfaces support' CONFIG_DEV_APPLETALK $CONFIG_ATALK dep_mbool 'Appletalk interfaces support' CONFIG_DEV_APPLETALK $CONFIG_ATALK
if [ "$CONFIG_DEV_APPLETALK" = "y" ]; then if [ "$CONFIG_DEV_APPLETALK" = "y" ]; then
tristate ' Apple/Farallon LocalTalk PC support' CONFIG_LTPC tristate ' Apple/Farallon LocalTalk PC support' CONFIG_LTPC
...@@ -18,4 +17,3 @@ if [ "$CONFIG_DEV_APPLETALK" = "y" ]; then ...@@ -18,4 +17,3 @@ if [ "$CONFIG_DEV_APPLETALK" = "y" ]; then
bool ' Appletalk-IP to IP Decapsulation support' CONFIG_IPDDP_DECAP bool ' Appletalk-IP to IP Decapsulation support' CONFIG_IPDDP_DECAP
fi fi
fi fi
endmenu
...@@ -399,7 +399,7 @@ static u16 bond_check_dev_link(struct net_device *dev) ...@@ -399,7 +399,7 @@ static u16 bond_check_dev_link(struct net_device *dev)
{ {
static int (* ioctl)(struct net_device *, struct ifreq *, int); static int (* ioctl)(struct net_device *, struct ifreq *, int);
struct ifreq ifr; struct ifreq ifr;
struct mii_ioctl_data mii; struct mii_ioctl_data *mii;
struct ethtool_value etool; struct ethtool_value etool;
if ((ioctl = dev->do_ioctl) != NULL) { /* ioctl to access MII */ if ((ioctl = dev->do_ioctl) != NULL) { /* ioctl to access MII */
...@@ -425,21 +425,24 @@ static u16 bond_check_dev_link(struct net_device *dev) ...@@ -425,21 +425,24 @@ static u16 bond_check_dev_link(struct net_device *dev)
} }
} }
ifr.ifr_data = (char*)&mii; /*
/* try MIIPHY first then, if that doesn't work, try MIIREG */ * We cannot assume that SIOCGMIIPHY will also read a
if (ioctl(dev, &ifr, SIOCGMIIPHY) == 0) { * register; not all network drivers support that.
/* now, mii.phy_id contains info about link status :
- mii.phy_id & 0x04 means link up
- mii.phy_id & 0x20 means end of auto-negociation
*/ */
return mii.phy_id;
/* Yes, the mii is overlaid on the ifreq.ifr_ifru */
mii = (struct mii_ioctl_data *)&ifr.ifr_data;
if (ioctl(dev, &ifr, SIOCGMIIPHY) != 0) {
return MII_LINK_READY; /* can't tell */
} }
mii.reg_num = 1; /* the MII register we want to read */ mii->reg_num = 1;
if (ioctl(dev, &ifr, SIOCGMIIREG) == 0) { if (ioctl(dev, &ifr, SIOCGMIIREG) == 0) {
/* mii.val_out contians the same link info as phy_id */ /*
/* above */ * mii->val_out contains MII reg 1, BMSR
return mii.val_out; * 0x0004 means link established
*/
return mii->val_out;
} }
} }
...@@ -641,12 +644,6 @@ static void set_multicast_list(struct net_device *master) ...@@ -641,12 +644,6 @@ static void set_multicast_list(struct net_device *master)
*/ */
write_lock_irqsave(&bond->lock, flags); write_lock_irqsave(&bond->lock, flags);
/*
* Lock the master device so that noone trys to transmit
* while we're changing things
*/
spin_lock_bh(&master->xmit_lock);
/* set promiscuity flag to slaves */ /* set promiscuity flag to slaves */
if ( (master->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC) ) if ( (master->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC) )
bond_set_promiscuity(bond, 1); bond_set_promiscuity(bond, 1);
...@@ -680,7 +677,6 @@ static void set_multicast_list(struct net_device *master) ...@@ -680,7 +677,6 @@ static void set_multicast_list(struct net_device *master)
bond_mc_list_destroy (bond); bond_mc_list_destroy (bond);
bond_mc_list_copy (master->mc_list, bond, GFP_KERNEL); bond_mc_list_copy (master->mc_list, bond, GFP_KERNEL);
spin_unlock_bh(&master->xmit_lock);
write_unlock_irqrestore(&bond->lock, flags); write_unlock_irqrestore(&bond->lock, flags);
} }
......
...@@ -29,13 +29,11 @@ ...@@ -29,13 +29,11 @@
* compare-and-swap cpus (Sparc64). So we control which * compare-and-swap cpus (Sparc64). So we control which
* implementation to use with a __BRLOCK_USE_ATOMICS define. -DaveM * implementation to use with a __BRLOCK_USE_ATOMICS define. -DaveM
* *
* Added BR_LLC_LOCK for use in net/core/ext8022.c -acme
*/ */
/* Register bigreader lock indices here. */ /* Register bigreader lock indices here. */
enum brlock_indices { enum brlock_indices {
BR_NETPROTO_LOCK, BR_NETPROTO_LOCK,
BR_LLC_LOCK,
__BR_END __BR_END
}; };
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <asm/byteorder.h>
/* Optimization barrier */ /* Optimization barrier */
/* The "volatile" is due to gcc bugs */ /* The "volatile" is due to gcc bugs */
...@@ -116,11 +117,17 @@ extern const char *print_tainted(void); ...@@ -116,11 +117,17 @@ extern const char *print_tainted(void);
((unsigned char *)&addr)[2], \ ((unsigned char *)&addr)[2], \
((unsigned char *)&addr)[3] ((unsigned char *)&addr)[3]
#if defined(__LITTLE_ENDIAN)
#define HIPQUAD(addr) \ #define HIPQUAD(addr) \
((unsigned char *)&addr)[3], \ ((unsigned char *)&addr)[3], \
((unsigned char *)&addr)[2], \ ((unsigned char *)&addr)[2], \
((unsigned char *)&addr)[1], \ ((unsigned char *)&addr)[1], \
((unsigned char *)&addr)[0] ((unsigned char *)&addr)[0]
#elif defined(__BIG_ENDIAN)
#define HIPQUAD NIPQUAD
#else
#error "Please fix asm/byteorder.h"
#endif /* __LITTLE_ENDIAN */
/* /*
* min()/max() macros that also do * min()/max() macros that also do
......
...@@ -162,7 +162,7 @@ struct netif_rx_stats ...@@ -162,7 +162,7 @@ struct netif_rx_stats
unsigned fastroute_deferred_out; unsigned fastroute_deferred_out;
unsigned fastroute_latency_reduction; unsigned fastroute_latency_reduction;
unsigned cpu_collision; unsigned cpu_collision;
} __attribute__ ((__aligned__(SMP_CACHE_BYTES))); } ____cacheline_aligned;
extern struct netif_rx_stats netdev_rx_stat[]; extern struct netif_rx_stats netdev_rx_stat[];
...@@ -501,7 +501,7 @@ struct softnet_data ...@@ -501,7 +501,7 @@ struct softnet_data
struct sk_buff *completion_queue; struct sk_buff *completion_queue;
struct net_device backlog_dev; /* Sorry. 8) */ struct net_device backlog_dev; /* Sorry. 8) */
} __attribute__((__aligned__(SMP_CACHE_BYTES))); } ____cacheline_aligned;
extern struct softnet_data softnet_data[NR_CPUS]; extern struct softnet_data softnet_data[NR_CPUS];
......
...@@ -2,24 +2,17 @@ ...@@ -2,24 +2,17 @@
#define _NET_INET_DATALINK_H_ #define _NET_INET_DATALINK_H_
struct datalink_proto { struct datalink_proto {
unsigned short type_len;
unsigned char type[8]; unsigned char type[8];
const char *string_name;
union { struct llc_sap *sap;
struct llc_pinfo *llc;
} ll_pinfo;
struct llc_sc_info *llc_sc;
struct sock *sock;
unsigned short header_length; unsigned short header_length;
int (*rcvfunc)(struct sk_buff *, struct net_device *, int (*rcvfunc)(struct sk_buff *, struct net_device *,
struct packet_type *); struct packet_type *);
void (*datalink_header)(struct datalink_proto *, struct sk_buff *, int (*request)(struct datalink_proto *, struct sk_buff *,
unsigned char *); unsigned char *);
struct datalink_proto *next; struct list_head node;
}; };
#endif #endif
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#define LLC_GLOBAL_DEFAULT_MAX_NBR_SAPS 4 #define LLC_GLOBAL_DEFAULT_MAX_NBR_SAPS 4
#define LLC_GLOBAL_DEFAULT_MAX_NBR_CONNS 64 #define LLC_GLOBAL_DEFAULT_MAX_NBR_CONNS 64
extern struct llc_prim_if_block llc_ind_prim, llc_cfm_prim;
/* LLC station component (SAP and connection resource manager) */ /* LLC station component (SAP and connection resource manager) */
/* Station component; one per adapter */ /* Station component; one per adapter */
struct llc_station { struct llc_station {
......
...@@ -198,6 +198,11 @@ struct llc_pdu_sn { ...@@ -198,6 +198,11 @@ struct llc_pdu_sn {
u8 ctrl_2; u8 ctrl_2;
}; };
static __inline__ struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb)
{
return (struct llc_pdu_sn *)skb->nh.raw;
}
/* Un-numbered PDU format (3 bytes in length) */ /* Un-numbered PDU format (3 bytes in length) */
struct llc_pdu_un { struct llc_pdu_un {
u8 dsap; u8 dsap;
...@@ -205,6 +210,16 @@ struct llc_pdu_un { ...@@ -205,6 +210,16 @@ struct llc_pdu_un {
u8 ctrl_1; u8 ctrl_1;
}; };
static __inline__ struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb)
{
return (struct llc_pdu_un *)skb->nh.raw;
}
static __inline__ void *llc_set_pdu_hdr(struct sk_buff *skb, void *ptr)
{
return skb->nh.raw = ptr;
}
/* LLC Type 1 XID command/response information fields format */ /* LLC Type 1 XID command/response information fields format */
struct llc_xid_info { struct llc_xid_info {
u8 fmt_id; /* always 0x18 for LLC */ u8 fmt_id; /* always 0x18 for LLC */
......
...@@ -12,23 +12,38 @@ ...@@ -12,23 +12,38 @@
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
*/ */
#include <linux/skbuff.h> #include <linux/skbuff.h>
/* Defines the SAP component */ /**
* struct llc_sap - Defines the SAP component
*
* @p_bit - only lowest-order bit used
* @f_bit - only lowest-order bit used
* @req - provided by LLC layer
* @resp - provided by LLC layer
* @ind - provided by network layer
* @conf - provided by network layer
* @laddr - SAP value in this 'lsap'
* @node - entry in station sap_list
* @sk_list - LLC sockets this one manages
* @mac_pdu_q - PDUs ready to send to MAC
*/
struct llc_sap { struct llc_sap {
u8 state;
struct llc_station *parent_station; struct llc_station *parent_station;
u8 p_bit; /* only lowest-order bit used */ u8 state;
u8 f_bit; /* only lowest-order bit used */ u8 p_bit;
llc_prim_call_t req; /* provided by LLC layer */ u8 f_bit;
llc_prim_call_t resp; /* provided by LLC layer */ llc_prim_call_t req;
llc_prim_call_t ind; /* provided by network layer */ llc_prim_call_t resp;
llc_prim_call_t conf; /* provided by network layer */ llc_prim_call_t ind;
struct llc_addr laddr; /* SAP value in this 'lsap' */ llc_prim_call_t conf;
struct list_head node; /* entry in station sap_list */ struct llc_prim_if_block llc_ind_prim, llc_cfm_prim;
union llc_u_prim_data llc_ind_data_prim, llc_cfm_data_prim;
struct llc_addr laddr;
struct list_head node;
struct { struct {
spinlock_t lock; spinlock_t lock;
struct list_head list; struct list_head list;
} sk_list; /* LLC sockets this one manages */ } sk_list;
struct sk_buff_head mac_pdu_q; /* PDUs ready to send to MAC */ struct sk_buff_head mac_pdu_q;
}; };
struct llc_sap_state_ev; struct llc_sap_state_ev;
......
#ifndef _NET_P8022_H #ifndef _NET_P8022_H
#define _NET_P8022_H #define _NET_P8022_H
#include <net/llc_if.h>
extern struct datalink_proto *register_8022_client(unsigned char type, extern struct datalink_proto *register_8022_client(unsigned char type,
int (*rcvfunc) int (*indicate)(struct llc_prim_if_block *prim));
(struct sk_buff *, extern void unregister_8022_client(struct datalink_proto *proto);
struct net_device *,
struct packet_type *));
extern void unregister_8022_client(unsigned char type);
#endif #endif
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
#define _NET_PSNAP_H #define _NET_PSNAP_H
extern struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct net_device *, struct packet_type *)); extern struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct net_device *, struct packet_type *));
extern void unregister_snap_client(unsigned char *desc); extern void unregister_snap_client(struct datalink_proto *proto);
#endif #endif
...@@ -23,103 +23,48 @@ ...@@ -23,103 +23,48 @@
#include <linux/in.h> #include <linux/in.h>
#include <linux/init.h> #include <linux/init.h>
#include <net/p8022.h> #include <net/p8022.h>
#include <net/llc_sap.h>
extern void llc_register_sap(unsigned char sap, static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
int (*rcvfunc)(struct sk_buff *, unsigned char *dest)
struct net_device *,
struct packet_type *));
extern void llc_unregister_sap(unsigned char sap);
static struct datalink_proto *p8022_list;
/*
* We don't handle the loopback SAP stuff, the extended
* 802.2 command set, multicast SAP identifiers and non UI
* frames. We have the absolute minimum needed for IPX,
* IP and Appletalk phase 2. See the llc_* routines for
* support libraries if your protocol needs these.
*/
static struct datalink_proto *find_8022_client(unsigned char type)
{
struct datalink_proto *proto = p8022_list;
while (proto && *(proto->type) != type)
proto = proto->next;
return proto;
}
int p8022_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt)
{
struct datalink_proto *proto;
int rc = 0;
proto = find_8022_client(*(skb->h.raw));
if (!proto) {
skb->sk = NULL;
kfree_skb(skb);
goto out;
}
skb->h.raw += 3;
skb->nh.raw += 3;
skb_pull(skb, 3);
rc = proto->rcvfunc(skb, dev, pt);
out: return rc;
}
static void p8022_datalink_header(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node)
{ {
struct net_device *dev = skb->dev; union llc_u_prim_data prim_data;
unsigned char *rawp = skb_push(skb, 3); struct llc_prim_if_block prim;
*rawp++ = dl->type[0]; prim.data = &prim_data;
*rawp++ = dl->type[0]; prim.sap = dl->sap;
*rawp = 0x03; /* UI */ prim.prim = LLC_DATAUNIT_PRIM;
dev->hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len); prim_data.test.skb = skb;
prim_data.test.saddr.lsap = dl->sap->laddr.lsap;
prim_data.test.daddr.lsap = dl->sap->laddr.lsap;
memcpy(prim_data.test.saddr.mac, skb->dev->dev_addr, IFHWADDRLEN);
memcpy(prim_data.test.daddr.mac, dest, IFHWADDRLEN);
return dl->sap->req(&prim);
} }
struct datalink_proto *register_8022_client(unsigned char type, struct datalink_proto *register_8022_client(unsigned char type,
int (*rcvfunc)(struct sk_buff *, int (*indicate)(struct llc_prim_if_block *prim))
struct net_device *,
struct packet_type *))
{ {
struct datalink_proto *proto = NULL; struct datalink_proto *proto;
if (find_8022_client(type))
goto out;
proto = kmalloc(sizeof(*proto), GFP_ATOMIC); proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
if (proto) { if (proto) {
proto->type[0] = type; proto->type[0] = type;
proto->type_len = 1;
proto->rcvfunc = rcvfunc;
proto->header_length = 3; proto->header_length = 3;
proto->datalink_header = p8022_datalink_header; proto->request = p8022_request;
proto->string_name = "802.2"; proto->sap = llc_sap_open(indicate, NULL, type);
proto->next = p8022_list; if (!proto->sap) {
p8022_list = proto; kfree(proto);
llc_register_sap(type, p8022_rcv); proto = NULL;
} }
out: return proto; }
return proto;
} }
void unregister_8022_client(unsigned char type) void unregister_8022_client(struct datalink_proto *proto)
{ {
struct datalink_proto *tmp, **clients = &p8022_list; llc_sap_close(proto->sap);
unsigned long flags; kfree(proto);
save_flags(flags);
cli();
while (*clients) {
tmp = *clients;
if (tmp->type[0] == type) {
*clients = tmp->next;
kfree(tmp);
llc_unregister_sap(type);
break;
}
clients = &tmp->next;
}
restore_flags(flags);
} }
EXPORT_SYMBOL(register_8022_client); EXPORT_SYMBOL(register_8022_client);
......
...@@ -24,11 +24,12 @@ ...@@ -24,11 +24,12 @@
* addresses, we just need to give it the buffer length. * addresses, we just need to give it the buffer length.
*/ */
static void p8023_datalink_header(struct datalink_proto *dl, static int p8023_request(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node) struct sk_buff *skb, unsigned char *dest_node)
{ {
struct net_device *dev = skb->dev; struct net_device *dev = skb->dev;
dev->hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len); dev->hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len);
return dev_queue_xmit(skb);
} }
/* /*
...@@ -42,10 +43,8 @@ struct datalink_proto *make_8023_client(void) ...@@ -42,10 +43,8 @@ struct datalink_proto *make_8023_client(void)
proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC); proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
if (proto != NULL) if (proto != NULL)
{ {
proto->type_len = 0;
proto->header_length = 0; proto->header_length = 0;
proto->datalink_header = p8023_datalink_header; proto->request = p8023_request;
proto->string_name = "802.3";
} }
return proto; return proto;
} }
......
...@@ -15,61 +15,90 @@ ...@@ -15,61 +15,90 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <net/datalink.h> #include <net/datalink.h>
#include <net/p8022.h>
#include <net/psnap.h> #include <net/psnap.h>
#include <net/llc_if.h>
#include <net/llc_sap.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/brlock.h>
static struct datalink_proto *snap_list; LIST_HEAD(snap_list);
static struct datalink_proto *snap_dl; /* 802.2 DL for SNAP */ static struct llc_sap *snap_sap;
/* /*
* Find a snap client by matching the 5 bytes. * Find a snap client by matching the 5 bytes.
*/ */
static struct datalink_proto *find_snap_client(unsigned char *desc) static struct datalink_proto *find_snap_client(unsigned char *desc)
{ {
struct datalink_proto *proto = snap_list; struct list_head *entry;
struct datalink_proto *proto = NULL, *p;
for (; proto && memcmp(proto->type, desc, 5); proto = proto->next); if (list_empty(&snap_list))
goto out;
list_for_each(entry, &snap_list) {
p = list_entry(entry, struct datalink_proto, node);
if (!memcmp(p->type, desc, 5)) {
proto = p;
break;
}
}
out:
return proto; return proto;
} }
/* /*
* A SNAP packet has arrived * A SNAP packet has arrived
*/ */
int snap_rcv(struct sk_buff *skb, struct net_device *dev, static int snap_indicate(struct llc_prim_if_block *prim)
struct packet_type *pt)
{ {
struct sk_buff *skb;
struct datalink_proto *proto;
int rc = 1;
static struct packet_type psnap_packet_type = { static struct packet_type psnap_packet_type = {
.type = __constant_htons(ETH_P_SNAP), .type = __constant_htons(ETH_P_SNAP),
.func = snap_rcv,
}; };
struct datalink_proto *proto = find_snap_client(skb->h.raw); if (prim->prim != LLC_DATAUNIT_PRIM)
goto out;
skb = prim->data->udata.skb;
proto = find_snap_client(skb->h.raw);
if (proto) { if (proto) {
/* Pass the frame on. */ /* Pass the frame on. */
skb->h.raw += 5; skb->h.raw += 5;
skb->nh.raw += 5;
skb_pull(skb, 5); skb_pull(skb, 5);
rc = proto->rcvfunc(skb, skb->dev, &psnap_packet_type);
return proto->rcvfunc(skb, dev, &psnap_packet_type); } else {
}
skb->sk = NULL; skb->sk = NULL;
kfree_skb(skb); kfree_skb(skb);
return 0; rc = 1;
}
out:
return rc;
} }
/* /*
* Put a SNAP header on a frame and pass to 802.2 * Put a SNAP header on a frame and pass to 802.2
*/ */
static void snap_datalink_header(struct datalink_proto *dl, static int snap_request(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node) struct sk_buff *skb, u8 *dest)
{ {
union llc_u_prim_data prim_data;
struct llc_prim_if_block prim;
memcpy(skb_push(skb, 5), dl->type, 5); memcpy(skb_push(skb, 5), dl->type, 5);
snap_dl->datalink_header(snap_dl, skb, dest_node); prim.data = &prim_data;
prim.sap = snap_sap;
prim.prim = LLC_DATAUNIT_PRIM;
prim_data.test.skb = skb;
prim_data.test.saddr.lsap = snap_sap->laddr.lsap;
prim_data.test.daddr.lsap = snap_sap->laddr.lsap;
memcpy(prim_data.test.saddr.mac, skb->dev->dev_addr, IFHWADDRLEN);
memcpy(prim_data.test.daddr.mac, dest, IFHWADDRLEN);
return snap_sap->req(&prim);
} }
/* /*
...@@ -80,9 +109,9 @@ EXPORT_SYMBOL(unregister_snap_client); ...@@ -80,9 +109,9 @@ EXPORT_SYMBOL(unregister_snap_client);
static int __init snap_init(void) static int __init snap_init(void)
{ {
snap_dl = register_8022_client(0xAA, snap_rcv); snap_sap = llc_sap_open(snap_indicate, NULL, 0xAA);
if (!snap_dl) if (!snap_sap)
printk(KERN_CRIT "SNAP - unable to register with 802.2\n"); printk(KERN_CRIT "SNAP - unable to register with 802.2\n");
return 0; return 0;
...@@ -90,6 +119,14 @@ static int __init snap_init(void) ...@@ -90,6 +119,14 @@ static int __init snap_init(void)
module_init(snap_init); module_init(snap_init);
static void __exit snap_exit(void)
{
llc_sap_close(snap_sap);
}
module_exit(snap_exit);
/* /*
* Register SNAP clients. We don't yet use this for IP. * Register SNAP clients. We don't yet use this for IP.
*/ */
...@@ -100,46 +137,35 @@ struct datalink_proto *register_snap_client(unsigned char *desc, ...@@ -100,46 +137,35 @@ struct datalink_proto *register_snap_client(unsigned char *desc,
{ {
struct datalink_proto *proto = NULL; struct datalink_proto *proto = NULL;
br_write_lock_bh(BR_NETPROTO_LOCK);
if (find_snap_client(desc)) if (find_snap_client(desc))
goto out; goto out;
proto = kmalloc(sizeof(*proto), GFP_ATOMIC); proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
if (proto) { if (proto) {
memcpy(proto->type, desc,5); memcpy(proto->type, desc,5);
proto->type_len = 5;
proto->rcvfunc = rcvfunc; proto->rcvfunc = rcvfunc;
proto->header_length = 5 + snap_dl->header_length; proto->header_length = 5 + 3; /* snap + 802.2 */
proto->datalink_header = snap_datalink_header; proto->request = snap_request;
proto->string_name = "SNAP"; list_add(&proto->node, &snap_list);
proto->next = snap_list;
snap_list = proto;
} }
out: out:
br_write_unlock_bh(BR_NETPROTO_LOCK);
return proto; return proto;
} }
/* /*
* Unregister SNAP clients. Protocols no longer want to play with us ... * Unregister SNAP clients. Protocols no longer want to play with us ...
*/ */
void unregister_snap_client(unsigned char *desc) void unregister_snap_client(struct datalink_proto *proto)
{ {
struct datalink_proto **clients = &snap_list; br_write_lock_bh(BR_NETPROTO_LOCK);
struct datalink_proto *tmp;
unsigned long flags;
save_flags(flags);
cli();
while ((tmp = *clients) != NULL) { list_del(&proto->node);
if (!memcmp(tmp->type, desc, 5)) { kfree(proto);
*clients = tmp->next;
kfree(tmp);
break;
} else
clients = &tmp->next;
}
restore_flags(flags); br_write_unlock_bh(BR_NETPROTO_LOCK);
} }
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -44,13 +44,17 @@ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then ...@@ -44,13 +44,17 @@ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
fi fi
tristate '802.1Q VLAN Support' CONFIG_VLAN_8021Q tristate '802.1Q VLAN Support' CONFIG_VLAN_8021Q
comment ' ' tristate 'ANSI/IEEE 802.2 Data link layer protocol' CONFIG_LLC
tristate 'The IPX protocol' CONFIG_IPX if [ "$CONFIG_LLC" != "n" ]; then
tristate ' LLC sockets interface' CONFIG_LLC_UI
fi
dep_tristate 'The IPX protocol' CONFIG_IPX $CONFIG_LLC
if [ "$CONFIG_IPX" != "n" ]; then if [ "$CONFIG_IPX" != "n" ]; then
source net/ipx/Config.in source net/ipx/Config.in
fi fi
tristate 'Appletalk protocol support' CONFIG_ATALK dep_tristate 'Appletalk protocol support' CONFIG_ATALK $CONFIG_LLC
source drivers/net/appletalk/Config.in source drivers/net/appletalk/Config.in
tristate 'DECnet Support' CONFIG_DECNET tristate 'DECnet Support' CONFIG_DECNET
...@@ -61,11 +65,6 @@ dep_tristate '802.1d Ethernet Bridging' CONFIG_BRIDGE $CONFIG_INET ...@@ -61,11 +65,6 @@ dep_tristate '802.1d Ethernet Bridging' CONFIG_BRIDGE $CONFIG_INET
if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
tristate 'CCITT X.25 Packet Layer (EXPERIMENTAL)' CONFIG_X25 tristate 'CCITT X.25 Packet Layer (EXPERIMENTAL)' CONFIG_X25
tristate 'LAPB Data Link Driver (EXPERIMENTAL)' CONFIG_LAPB tristate 'LAPB Data Link Driver (EXPERIMENTAL)' CONFIG_LAPB
tristate 'ANSI/IEEE 802.2 Data link layer protocol' CONFIG_LLC
if [ "$CONFIG_LLC" != "n" ]; then
# When NETBEUI is added the following line will be a tristate
define_bool CONFIG_LLC_UI y
fi
bool 'Frame Diverter (EXPERIMENTAL)' CONFIG_NET_DIVERT bool 'Frame Diverter (EXPERIMENTAL)' CONFIG_NET_DIVERT
if [ "$CONFIG_INET" = "y" ]; then if [ "$CONFIG_INET" = "y" ]; then
tristate 'Acorn Econet/AUN protocols (EXPERIMENTAL)' CONFIG_ECONET tristate 'Acorn Econet/AUN protocols (EXPERIMENTAL)' CONFIG_ECONET
......
...@@ -163,11 +163,8 @@ static void __aarp_send_query(struct aarp_entry *a) ...@@ -163,11 +163,8 @@ static void __aarp_send_query(struct aarp_entry *a)
eah->pa_dst_net = a->target_addr.s_net; eah->pa_dst_net = a->target_addr.s_net;
eah->pa_dst_node = a->target_addr.s_node; eah->pa_dst_node = a->target_addr.s_node;
/* Add ELAP headers and set target to the AARP multicast */
aarp_dl->datalink_header(aarp_dl, skb, aarp_eth_multicast);
/* Send it */ /* Send it */
dev_queue_xmit(skb); aarp_dl->request(aarp_dl, skb, aarp_eth_multicast);
/* Update the sending count */ /* Update the sending count */
a->xmit_count++; a->xmit_count++;
} }
...@@ -213,10 +210,8 @@ static void aarp_send_reply(struct net_device *dev, struct atalk_addr *us, ...@@ -213,10 +210,8 @@ static void aarp_send_reply(struct net_device *dev, struct atalk_addr *us,
eah->pa_dst_net = them->s_net; eah->pa_dst_net = them->s_net;
eah->pa_dst_node = them->s_node; eah->pa_dst_node = them->s_node;
/* Add ELAP headers and set target to the AARP multicast */
aarp_dl->datalink_header(aarp_dl, skb, sha);
/* Send it */ /* Send it */
dev_queue_xmit(skb); aarp_dl->request(aarp_dl, skb, sha);
} }
/* /*
...@@ -261,10 +256,8 @@ void aarp_send_probe(struct net_device *dev, struct atalk_addr *us) ...@@ -261,10 +256,8 @@ void aarp_send_probe(struct net_device *dev, struct atalk_addr *us)
eah->pa_dst_net = us->s_net; eah->pa_dst_net = us->s_net;
eah->pa_dst_node = us->s_node; eah->pa_dst_node = us->s_node;
/* Add ELAP headers and set target to the AARP multicast */
aarp_dl->datalink_header(aarp_dl, skb, aarp_eth_multicast);
/* Send it */ /* Send it */
dev_queue_xmit(skb); aarp_dl->request(aarp_dl, skb, aarp_eth_multicast);
} }
/* /*
...@@ -602,8 +595,9 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -602,8 +595,9 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
/* Do we have a resolved entry? */ /* Do we have a resolved entry? */
if (sa->s_node == ATADDR_BCAST) { if (sa->s_node == ATADDR_BCAST) {
ddp_dl->datalink_header(ddp_dl, skb, ddp_eth_multicast); /* Send it */
goto sendit; ddp_dl->request(ddp_dl, skb, ddp_eth_multicast);
goto sent;
} }
spin_lock_bh(&aarp_lock); spin_lock_bh(&aarp_lock);
...@@ -611,9 +605,9 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -611,9 +605,9 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
if (a) { /* Return 1 and fill in the address */ if (a) { /* Return 1 and fill in the address */
a->expires_at = jiffies + (sysctl_aarp_expiry_time * 10); a->expires_at = jiffies + (sysctl_aarp_expiry_time * 10);
ddp_dl->datalink_header(ddp_dl, skb, a->hwaddr); ddp_dl->request(ddp_dl, skb, a->hwaddr);
spin_unlock_bh(&aarp_lock); spin_unlock_bh(&aarp_lock);
goto sendit; goto sent;
} }
/* Do we have an unresolved entry: This is the less common path */ /* Do we have an unresolved entry: This is the less common path */
...@@ -663,6 +657,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, ...@@ -663,6 +657,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
if (skb->sk) if (skb->sk)
skb->priority = skb->sk->priority; skb->priority = skb->sk->priority;
dev_queue_xmit(skb); dev_queue_xmit(skb);
sent:
return 1; return 1;
} }
...@@ -690,10 +685,7 @@ static void __aarp_resolved(struct aarp_entry **list, struct aarp_entry *a, ...@@ -690,10 +685,7 @@ static void __aarp_resolved(struct aarp_entry **list, struct aarp_entry *a,
while ((skb = skb_dequeue(&a->packet_queue)) != NULL) { while ((skb = skb_dequeue(&a->packet_queue)) != NULL) {
a->expires_at = jiffies + a->expires_at = jiffies +
sysctl_aarp_expiry_time * 10; sysctl_aarp_expiry_time * 10;
ddp_dl->datalink_header(ddp_dl, skb, a->hwaddr); ddp_dl->request(ddp_dl, skb, a->hwaddr);
if (skb->sk)
skb->priority = skb->sk->priority;
dev_queue_xmit(skb);
} }
} else } else
list = &((*list)->next); list = &((*list)->next);
...@@ -989,7 +981,7 @@ void aarp_cleanup_module(void) ...@@ -989,7 +981,7 @@ void aarp_cleanup_module(void)
{ {
del_timer(&aarp_timer); del_timer(&aarp_timer);
unregister_netdevice_notifier(&aarp_notifier); unregister_netdevice_notifier(&aarp_notifier);
unregister_snap_client(aarp_snap_id); unregister_snap_client(aarp_dl);
} }
#endif /* MODULE */ #endif /* MODULE */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
......
...@@ -1782,13 +1782,7 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len, ...@@ -1782,13 +1782,7 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len,
SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk); SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk);
/* loop back */ /* loop back */
skb_orphan(skb); skb_orphan(skb);
ddp_dl->datalink_header(ddp_dl, skb, dev->dev_addr); ddp_dl->request(ddp_dl, skb, dev->dev_addr);
skb->mac.raw = skb->data;
skb->h.raw = skb->data + ddp_dl->header_length +
dev->hard_header_len;
skb_pull(skb, dev->hard_header_len);
skb_pull(skb, ddp_dl->header_length);
atalk_rcv(skb, dev, NULL);
} else { } else {
SOCK_DEBUG(sk, "SK %p: send out.\n", sk); SOCK_DEBUG(sk, "SK %p: send out.\n", sk);
if (rt->flags & RTF_GATEWAY) { if (rt->flags & RTF_GATEWAY) {
...@@ -2040,7 +2034,7 @@ static void __exit atalk_exit(void) ...@@ -2040,7 +2034,7 @@ static void __exit atalk_exit(void)
unregister_netdevice_notifier(&ddp_notifier); unregister_netdevice_notifier(&ddp_notifier);
dev_remove_pack(&ltalk_packet_type); dev_remove_pack(&ltalk_packet_type);
dev_remove_pack(&ppptalk_packet_type); dev_remove_pack(&ppptalk_packet_type);
unregister_snap_client(ddp_snap_id); unregister_snap_client(ddp_dl);
sock_unregister(PF_APPLETALK); sock_unregister(PF_APPLETALK);
} }
module_exit(atalk_exit); module_exit(atalk_exit);
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
# Makefile for the Linux networking core. # Makefile for the Linux networking core.
# #
export-objs := ext8022.o
obj-y := sock.o skbuff.o iovec.o datagram.o scm.o obj-y := sock.o skbuff.o iovec.o datagram.o scm.o
ifeq ($(CONFIG_SYSCTL),y) ifeq ($(CONFIG_SYSCTL),y)
...@@ -16,11 +14,6 @@ obj-$(CONFIG_FILTER) += filter.o ...@@ -16,11 +14,6 @@ obj-$(CONFIG_FILTER) += filter.o
obj-$(CONFIG_NET) += dev.o dev_mcast.o dst.o neighbour.o rtnetlink.o utils.o obj-$(CONFIG_NET) += dev.o dev_mcast.o dst.o neighbour.o rtnetlink.o utils.o
# See p8022 in net/802/Makefile for config options to check
ifneq ($(CONFIG_LLC)$(CONFIG_TR)$(CONFIG_IPX)$(CONFIG_ATALK),)
obj-y += ext8022.o
endif
obj-$(CONFIG_NETFILTER) += netfilter.o obj-$(CONFIG_NETFILTER) += netfilter.o
obj-$(CONFIG_NET_DIVERT) += dv.o obj-$(CONFIG_NET_DIVERT) += dv.o
obj-$(CONFIG_NET_PROFILE) += profile.o obj-$(CONFIG_NET_PROFILE) += profile.o
......
/*
* (ext8022.c)
*
* Copyright (c) 1997 by Procom Technology, Inc.
* 2001 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.
* This program is distributed without any warranty or implied warranty
* of merchantability or fitness for a particular purpose.
*
* See the GNU General Public License for more details.
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/brlock.h>
typedef int (*func_type)(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt);
static int llc_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *);
static func_type llc_sap_table[128];
static int llc_users;
static struct packet_type llc_packet_type = {
.type = __constant_htons(ETH_P_802_2),
.func = llc_rcv,
};
static struct packet_type llc_tr_packet_type = {
.type = __constant_htons(ETH_P_TR_802_2),
.func = llc_rcv,
};
static int llc_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt)
{
unsigned char n = (*(skb->h.raw)) >> 1;
br_read_lock(BR_LLC_LOCK);
if (llc_sap_table[n])
llc_sap_table[n](skb, dev, pt);
else
kfree_skb(skb);
br_read_unlock(BR_LLC_LOCK);
return 0;
}
void llc_register_sap(unsigned char sap, func_type rcvfunc)
{
sap >>= 1;
br_write_lock_bh(BR_LLC_LOCK);
llc_sap_table[sap] = rcvfunc;
if (!llc_users) {
dev_add_pack(&llc_packet_type);
dev_add_pack(&llc_tr_packet_type);
}
llc_users++;
br_write_unlock_bh(BR_LLC_LOCK);
}
void llc_unregister_sap(unsigned char sap)
{
sap >>= 1;
br_write_lock_bh(BR_LLC_LOCK);
llc_sap_table[sap] = NULL;
if (!--llc_users) {
dev_remove_pack(&llc_packet_type);
dev_remove_pack(&llc_tr_packet_type);
}
br_write_unlock_bh(BR_LLC_LOCK);
}
EXPORT_SYMBOL(llc_register_sap);
EXPORT_SYMBOL(llc_unregister_sap);
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/in.h> #include <linux/in.h>
static void static int pEII_request(struct datalink_proto *dl,
pEII_datalink_header(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node) struct sk_buff *skb, unsigned char *dest_node)
{ {
struct net_device *dev = skb->dev; struct net_device *dev = skb->dev;
...@@ -13,6 +12,7 @@ pEII_datalink_header(struct datalink_proto *dl, ...@@ -13,6 +12,7 @@ pEII_datalink_header(struct datalink_proto *dl,
skb->protocol = htons (ETH_P_IPX); skb->protocol = htons (ETH_P_IPX);
if(dev->hard_header) if(dev->hard_header)
dev->hard_header(skb, dev, ETH_P_IPX, dest_node, NULL, skb->len); dev->hard_header(skb, dev, ETH_P_IPX, dest_node, NULL, skb->len);
return dev_queue_xmit(skb);
} }
struct datalink_proto * struct datalink_proto *
...@@ -22,10 +22,8 @@ make_EII_client(void) ...@@ -22,10 +22,8 @@ make_EII_client(void)
proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC); proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
if (proto != NULL) { if (proto != NULL) {
proto->type_len = 0;
proto->header_length = 0; proto->header_length = 0;
proto->datalink_header = pEII_datalink_header; proto->request = pEII_request;
proto->string_name = "EtherII";
} }
return proto; return proto;
......
This diff is collapsed.
...@@ -777,10 +777,9 @@ static int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb, ...@@ -777,10 +777,9 @@ static int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb,
/* set up data link and physical headers */ /* set up data link and physical headers */
skb->dev = dev; skb->dev = dev;
skb->protocol = htons(ETH_P_IPX); skb->protocol = htons(ETH_P_IPX);
dl->datalink_header(dl, skb, dest_node);
/* Send it out */ /* Send it out */
dev_queue_xmit(skb); dl->request(dl, skb, dest_node);
out: return 0; out: return 0;
} }
...@@ -2253,6 +2252,22 @@ drop: kfree_skb(skb); ...@@ -2253,6 +2252,22 @@ drop: kfree_skb(skb);
out: return ret; out: return ret;
} }
static int ipx_8022_indicate(struct llc_prim_if_block *prim)
{
int rc = 1;
static struct packet_type p8022_packet_type = {
.type = __constant_htons(ETH_P_802_2),
};
if (prim->prim == LLC_DATAUNIT_PRIM) {
struct sk_buff *skb = prim->data->udata.skb;
rc = ipx_rcv(skb, skb->dev, &p8022_packet_type);
}
return rc;
}
static int ipx_sendmsg(struct socket *sock, struct msghdr *msg, int len, static int ipx_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct scm_cookie *scm) struct scm_cookie *scm)
{ {
...@@ -2545,7 +2560,7 @@ static int __init ipx_init(void) ...@@ -2545,7 +2560,7 @@ static int __init ipx_init(void)
else else
printk(ipx_8023_err_msg); printk(ipx_8023_err_msg);
p8022_datalink = register_8022_client(ipx_8022_type, ipx_rcv); p8022_datalink = register_8022_client(ipx_8022_type, ipx_8022_indicate);
if (!p8022_datalink) if (!p8022_datalink)
printk(ipx_llc_err_msg); printk(ipx_llc_err_msg);
...@@ -2593,10 +2608,10 @@ static void __exit ipx_proto_finito(void) ...@@ -2593,10 +2608,10 @@ static void __exit ipx_proto_finito(void)
unregister_netdevice_notifier(&ipx_dev_notifier); unregister_netdevice_notifier(&ipx_dev_notifier);
unregister_snap_client(ipx_snap_id); unregister_snap_client(pSNAP_datalink);
pSNAP_datalink = NULL; pSNAP_datalink = NULL;
unregister_8022_client(ipx_8022_type); unregister_8022_client(p8022_datalink);
p8022_datalink = NULL; p8022_datalink = NULL;
dev_remove_pack(&ipx_8023_packet_type); dev_remove_pack(&ipx_8023_packet_type);
......
...@@ -61,15 +61,18 @@ int llc_conn_ac_clear_remote_busy(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -61,15 +61,18 @@ int llc_conn_ac_clear_remote_busy(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev) int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev)
{ {
int rc = 1; int rc = 1;
u8 dsap;
struct sk_buff *skb = ev->data.pdu.skb; struct sk_buff *skb = ev->data.pdu.skb;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &llc_ind_prim;
struct llc_sap *sap; struct llc_sap *sap;
struct llc_opt *llc = llc_sk(sk);
llc_pdu_decode_dsap(skb, &prim_data->conn.daddr.lsap); llc_pdu_decode_dsap(skb, &dsap);
sap = llc_sap_find(prim_data->conn.daddr.lsap); sap = llc_sap_find(dsap);
if (sap) { if (sap) {
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
struct llc_opt *llc = llc_sk(sk);
prim_data->conn.daddr.lsap = dsap;
llc_pdu_decode_sa(skb, llc->daddr.mac); llc_pdu_decode_sa(skb, llc->daddr.mac);
llc_pdu_decode_da(skb, llc->laddr.mac); llc_pdu_decode_da(skb, llc->laddr.mac);
llc->dev = skb->dev; llc->dev = skb->dev;
...@@ -90,14 +93,11 @@ int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -90,14 +93,11 @@ int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev) int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
{ {
union llc_u_prim_data *prim_data = llc_cfm_prim.data;
struct sk_buff *skb = ev->data.pdu.skb; struct sk_buff *skb = ev->data.pdu.skb;
/* FIXME: wtf, this is global, so the whole thing is really
* non reentrant...
*/
struct llc_prim_if_block *prim = &llc_cfm_prim;
struct llc_opt *llc = llc_sk(sk); struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->conn.sk = sk; prim_data->conn.sk = sk;
prim_data->conn.pri = 0; prim_data->conn.pri = 0;
...@@ -106,7 +106,7 @@ int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -106,7 +106,7 @@ int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
if (skb) if (skb)
prim_data->conn.dev = skb->dev; prim_data->conn.dev = skb->dev;
else else
printk(KERN_ERR __FUNCTION__ "ev->data.pdu.skb == NULL\n"); printk(KERN_ERR "%s: ev->data.pdu.skb == NULL\n", __FUNCTION__);
prim->data = prim_data; prim->data = prim_data;
prim->prim = LLC_CONN_PRIM; prim->prim = LLC_CONN_PRIM;
prim->sap = sap; prim->sap = sap;
...@@ -118,17 +118,19 @@ int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -118,17 +118,19 @@ int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
static int llc_conn_ac_data_confirm(struct sock *sk, static int llc_conn_ac_data_confirm(struct sock *sk,
struct llc_conn_state_ev *ev) struct llc_conn_state_ev *ev)
{ {
struct llc_prim_if_block *prim = &llc_cfm_prim; struct llc_opt *llc = llc_sk(sk);
union llc_u_prim_data *prim_data = llc_cfm_prim.data; struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->data.sk = sk; prim_data->data.sk = sk;
prim_data->data.pri = 0; prim_data->data.pri = 0;
prim_data->data.link = llc_sk(sk)->link; prim_data->data.link = llc->link;
prim_data->data.status = LLC_STATUS_RECEIVED; prim_data->data.status = LLC_STATUS_RECEIVED;
prim_data->data.skb = NULL; prim_data->data.skb = NULL;
prim->data = prim_data; prim->data = prim_data;
prim->prim = LLC_DATA_PRIM; prim->prim = LLC_DATA_PRIM;
prim->sap = llc_sk(sk)->sap; prim->sap = sap;
ev->flag = 1; ev->flag = 1;
ev->cfm_prim = prim; ev->cfm_prim = prim;
return 0; return 0;
...@@ -144,12 +146,9 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -144,12 +146,9 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
{ {
u8 reason = 0; u8 reason = 0;
int rc = 1; int rc = 1;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &llc_ind_prim;
if (ev->type == LLC_CONN_EV_TYPE_PDU) { if (ev->type == LLC_CONN_EV_TYPE_PDU) {
struct llc_pdu_un *pdu = struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
(struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
if (!LLC_PDU_IS_RSP(pdu) && if (!LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
...@@ -170,12 +169,17 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -170,12 +169,17 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
rc = 1; rc = 1;
} }
if (!rc) { if (!rc) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->disc.sk = sk; prim_data->disc.sk = sk;
prim_data->disc.reason = reason; prim_data->disc.reason = reason;
prim_data->disc.link = llc_sk(sk)->link; prim_data->disc.link = llc->link;
prim->data = prim_data; prim->data = prim_data;
prim->prim = LLC_DISC_PRIM; prim->prim = LLC_DISC_PRIM;
prim->sap = llc_sk(sk)->sap; prim->sap = llc->sap;
ev->flag = 1; ev->flag = 1;
ev->ind_prim = prim; ev->ind_prim = prim;
} }
...@@ -184,15 +188,17 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -184,15 +188,17 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_disc_confirm(struct sock *sk, struct llc_conn_state_ev *ev) int llc_conn_ac_disc_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
{ {
union llc_u_prim_data *prim_data = llc_cfm_prim.data; struct llc_opt *llc = llc_sk(sk);
struct llc_prim_if_block *prim = &llc_cfm_prim; struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->disc.sk = sk; prim_data->disc.sk = sk;
prim_data->disc.reason = ev->status; prim_data->disc.reason = ev->status;
prim_data->disc.link = llc_sk(sk)->link; prim_data->disc.link = llc->link;
prim->data = prim_data; prim->data = prim_data;
prim->prim = LLC_DISC_PRIM; prim->prim = LLC_DISC_PRIM;
prim->sap = llc_sk(sk)->sap; prim->sap = sap;
ev->flag = 1; ev->flag = 1;
ev->cfm_prim = prim; ev->cfm_prim = prim;
return 0; return 0;
...@@ -202,9 +208,7 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -202,9 +208,7 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
{ {
u8 reason = 0; u8 reason = 0;
int rc = 1; int rc = 1;
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &llc_ind_prim;
struct llc_opt *llc = llc_sk(sk); struct llc_opt *llc = llc_sk(sk);
switch (ev->type) { switch (ev->type) {
...@@ -237,12 +241,16 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -237,12 +241,16 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
break; break;
} }
if (!rc) { if (!rc) {
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->res.sk = sk; prim_data->res.sk = sk;
prim_data->res.reason = reason; prim_data->res.reason = reason;
prim_data->res.link = llc->link; prim_data->res.link = llc->link;
prim->data = prim_data; prim->data = prim_data;
prim->prim = LLC_RESET_PRIM; prim->prim = LLC_RESET_PRIM;
prim->sap = llc->sap; prim->sap = sap;
ev->flag = 1; ev->flag = 1;
ev->ind_prim = prim; ev->ind_prim = prim;
} }
...@@ -251,14 +259,16 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -251,14 +259,16 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_rst_confirm(struct sock *sk, struct llc_conn_state_ev *ev) int llc_conn_ac_rst_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
{ {
union llc_u_prim_data *prim_data = llc_cfm_prim.data; struct llc_opt *llc = llc_sk(sk);
struct llc_prim_if_block *prim = &llc_cfm_prim; struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->res.sk = sk; prim_data->res.sk = sk;
prim_data->res.link = llc_sk(sk)->link; prim_data->res.link = llc->link;
prim->data = prim_data; prim->data = prim_data;
prim->prim = LLC_RESET_PRIM; prim->prim = LLC_RESET_PRIM;
prim->sap = llc_sk(sk)->sap; prim->sap = sap;
ev->flag = 1; ev->flag = 1;
ev->cfm_prim = prim; ev->cfm_prim = prim;
return 0; return 0;
......
This diff is collapsed.
...@@ -82,7 +82,7 @@ int llc_conn_send_ev(struct sock *sk, struct llc_conn_state_ev *ev) ...@@ -82,7 +82,7 @@ int llc_conn_send_ev(struct sock *sk, struct llc_conn_state_ev *ev)
/* check if the connection was freed by the state machine by /* check if the connection was freed by the state machine by
* means of llc_conn_disc */ * means of llc_conn_disc */
if (rc == 2) { if (rc == 2) {
printk(KERN_INFO __FUNCTION__ ": rc == 2\n"); printk(KERN_INFO "%s: rc == 2\n", __FUNCTION__);
rc = -ECONNABORTED; rc = -ECONNABORTED;
goto out; goto out;
} }
...@@ -134,16 +134,18 @@ void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb) ...@@ -134,16 +134,18 @@ void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb)
void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb, void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb,
struct llc_conn_state_ev *ev) struct llc_conn_state_ev *ev)
{ {
struct llc_prim_if_block *prim = &llc_ind_prim; struct llc_opt *llc = llc_sk(sk);
union llc_u_prim_data *prim_data = llc_ind_prim.data; struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->data.sk = sk; prim_data->data.sk = sk;
prim_data->data.pri = 0; prim_data->data.pri = 0;
prim_data->data.skb = skb; prim_data->data.skb = skb;
prim_data->data.link = llc_sk(sk)->link; prim_data->data.link = llc->link;
prim->data = prim_data; prim->data = prim_data;
prim->prim = LLC_DATA_PRIM; prim->prim = LLC_DATA_PRIM;
prim->sap = llc_sk(sk)->sap; prim->sap = sap;
ev->flag = 1; ev->flag = 1;
/* saving prepd prim in event for future use in llc_conn_send_ev */ /* saving prepd prim in event for future use in llc_conn_send_ev */
ev->ind_prim = prim; ev->ind_prim = prim;
......
...@@ -56,7 +56,7 @@ int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct llc_station *station, ...@@ -56,7 +56,7 @@ int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct llc_station *station,
int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station, int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station,
struct llc_station_state_ev *ev) struct llc_station_state_ev *ev)
{ {
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU && return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_CMD(pdu) && /* command PDU */ !LLC_PDU_IS_CMD(pdu) && /* command PDU */
...@@ -68,7 +68,7 @@ int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station, ...@@ -68,7 +68,7 @@ int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station,
int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct llc_station *station, int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct llc_station *station,
struct llc_station_state_ev *ev) struct llc_station_state_ev *ev)
{ {
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU && return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_RSP(pdu) && /* response PDU */ !LLC_PDU_IS_RSP(pdu) && /* response PDU */
...@@ -81,7 +81,7 @@ int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct llc_station *station, ...@@ -81,7 +81,7 @@ int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct llc_station *station,
int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct llc_station *station, int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct llc_station *station,
struct llc_station_state_ev *ev) struct llc_station_state_ev *ev)
{ {
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU && return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_RSP(pdu) && /* response PDU */ !LLC_PDU_IS_RSP(pdu) && /* response PDU */
...@@ -94,7 +94,7 @@ int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct llc_station *station, ...@@ -94,7 +94,7 @@ int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct llc_station *station,
int llc_stat_ev_rx_null_dsap_test_c(struct llc_station *station, int llc_stat_ev_rx_null_dsap_test_c(struct llc_station *station,
struct llc_station_state_ev *ev) struct llc_station_state_ev *ev)
{ {
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU && return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_CMD(pdu) && /* command PDU */ !LLC_PDU_IS_CMD(pdu) && /* command PDU */
......
...@@ -41,12 +41,6 @@ static int llc_conn_rsp_handler(struct llc_prim_if_block *prim); ...@@ -41,12 +41,6 @@ static int llc_conn_rsp_handler(struct llc_prim_if_block *prim);
static int llc_rst_rsp_handler(struct llc_prim_if_block *prim); static int llc_rst_rsp_handler(struct llc_prim_if_block *prim);
static int llc_no_rsp_handler(struct llc_prim_if_block *prim); static int llc_no_rsp_handler(struct llc_prim_if_block *prim);
extern void llc_register_sap(unsigned char sap,
int (*rcvfunc)(struct sk_buff *skb,
struct net_device *dev,
struct packet_type *pt));
extern void llc_unregister_sap(unsigned char sap);
/* table of request handler functions */ /* table of request handler functions */
static llc_prim_call_t llc_req_prim[LLC_NBR_PRIMITIVES] = { static llc_prim_call_t llc_req_prim[LLC_NBR_PRIMITIVES] = {
[LLC_DATAUNIT_PRIM] = llc_unitdata_req_handler, [LLC_DATAUNIT_PRIM] = llc_unitdata_req_handler,
...@@ -105,7 +99,6 @@ struct llc_sap *llc_sap_open(llc_prim_call_t nw_indicate, ...@@ -105,7 +99,6 @@ struct llc_sap *llc_sap_open(llc_prim_call_t nw_indicate,
sap->parent_station = llc_station_get(); sap->parent_station = llc_station_get();
/* initialized SAP; add it to list of SAPs this station manages */ /* initialized SAP; add it to list of SAPs this station manages */
llc_sap_save(sap); llc_sap_save(sap);
llc_register_sap(lsap, mac_indicate);
out: out:
return sap; return sap;
err: err:
...@@ -122,7 +115,6 @@ struct llc_sap *llc_sap_open(llc_prim_call_t nw_indicate, ...@@ -122,7 +115,6 @@ struct llc_sap *llc_sap_open(llc_prim_call_t nw_indicate,
*/ */
void llc_sap_close(struct llc_sap *sap) void llc_sap_close(struct llc_sap *sap)
{ {
llc_unregister_sap(sap->laddr.lsap);
llc_free_sap(sap); llc_free_sap(sap);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
} }
...@@ -141,7 +133,7 @@ static int llc_sap_req(struct llc_prim_if_block *prim) ...@@ -141,7 +133,7 @@ static int llc_sap_req(struct llc_prim_if_block *prim)
int rc = 1; int rc = 1;
if (prim->prim > 8 || prim->prim == 6) { if (prim->prim > 8 || prim->prim == 6) {
printk(KERN_ERR __FUNCTION__ ": invalid primitive %d\n", printk(KERN_ERR "%s: invalid primitive %d\n", __FUNCTION__,
prim->prim); prim->prim);
goto out; goto out;
} }
...@@ -338,7 +330,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim) ...@@ -338,7 +330,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim)
memcpy(laddr.mac, sdev->dev_addr, sizeof(laddr.mac)); memcpy(laddr.mac, sdev->dev_addr, sizeof(laddr.mac));
laddr.lsap = prim->data->conn.saddr.lsap; laddr.lsap = prim->data->conn.saddr.lsap;
memcpy(daddr.mac, ddev->dev_addr, sizeof(daddr.mac)); memcpy(daddr.mac, prim->data->conn.daddr.mac, sizeof(daddr.mac));
daddr.lsap = prim->data->conn.daddr.lsap; daddr.lsap = prim->data->conn.daddr.lsap;
sk = llc_find_sock(sap, &daddr, &laddr); sk = llc_find_sock(sap, &daddr, &laddr);
if (sk) { if (sk) {
......
...@@ -46,7 +46,7 @@ int mac_send_pdu(struct sk_buff *skb) ...@@ -46,7 +46,7 @@ int mac_send_pdu(struct sk_buff *skb)
int pri = GFP_ATOMIC, rc = -1; int pri = GFP_ATOMIC, rc = -1;
if (!skb->dev) { if (!skb->dev) {
printk(KERN_ERR __FUNCTION__ ": skb->dev == NULL!"); printk(KERN_ERR "%s: skb->dev == NULL!", __FUNCTION__);
goto out; goto out;
} }
if (skb->sk) if (skb->sk)
...@@ -83,27 +83,30 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev, ...@@ -83,27 +83,30 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
* receives, do not try to analyse it. * receives, do not try to analyse it.
*/ */
if (skb->pkt_type == PACKET_OTHERHOST) { if (skb->pkt_type == PACKET_OTHERHOST) {
printk(KERN_INFO __FUNCTION__ ": PACKET_OTHERHOST\n"); printk(KERN_INFO "%s: PACKET_OTHERHOST\n", __FUNCTION__);
goto drop; goto drop;
} }
skb = skb_share_check(skb, GFP_ATOMIC); skb = skb_share_check(skb, GFP_ATOMIC);
if (!skb) if (!skb)
goto out; goto out;
fix_up_incoming_skb(skb); fix_up_incoming_skb(skb);
pdu = (struct llc_pdu_sn *)skb->nh.raw; pdu = llc_pdu_sn_hdr(skb);
if (!pdu->dsap) { /* NULL DSAP, refer to station */ if (!pdu->dsap) { /* NULL DSAP, refer to station */
llc_pdu_router(NULL, NULL, skb, 0); if (llc_pdu_router(NULL, NULL, skb, 0))
goto drop;
goto out; goto out;
} }
sap = llc_sap_find(pdu->dsap); sap = llc_sap_find(pdu->dsap);
if (!sap) /* unknown SAP */ if (!sap) /* unknown SAP */
goto drop; goto drop;
llc_decode_pdu_type(skb, &dest); llc_decode_pdu_type(skb, &dest);
if (dest == LLC_DEST_SAP) /* type 1 services */ if (dest == LLC_DEST_SAP) { /* type 1 services */
llc_pdu_router(sap, NULL, skb, LLC_TYPE_1); if (llc_pdu_router(sap, NULL, skb, LLC_TYPE_1))
else if (dest == LLC_DEST_CONN) { goto drop;
} else if (dest == LLC_DEST_CONN) {
struct llc_addr saddr, daddr; struct llc_addr saddr, daddr;
struct sock *sk; struct sock *sk;
int rc;
llc_pdu_decode_sa(skb, saddr.mac); llc_pdu_decode_sa(skb, saddr.mac);
llc_pdu_decode_ssap(skb, &saddr.lsap); llc_pdu_decode_ssap(skb, &saddr.lsap);
...@@ -134,14 +137,17 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev, ...@@ -134,14 +137,17 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
* in the llc_req_prim (llc_data_req_handler, etc) and * in the llc_req_prim (llc_data_req_handler, etc) and
* add the request to the backlog, well see... * add the request to the backlog, well see...
*/ */
llc_pdu_router(llc_sk(sk)->sap, sk, skb, LLC_TYPE_2); rc = llc_pdu_router(llc_sk(sk)->sap, sk, skb,
bh_unlock_sock(sk); LLC_TYPE_2);
} else { } else {
skb->cb[0] = LLC_PACKET; skb->cb[0] = LLC_PACKET;
sk_add_backlog(sk, skb); sk_add_backlog(sk, skb);
bh_unlock_sock(sk); rc = 0;
} }
bh_unlock_sock(sk);
sock_put(sk); sock_put(sk);
if (rc)
goto drop;
} else /* unknown or not supported pdu */ } else /* unknown or not supported pdu */
goto drop; goto drop;
out: out:
...@@ -196,7 +202,7 @@ static void fix_up_incoming_skb(struct sk_buff *skb) ...@@ -196,7 +202,7 @@ static void fix_up_incoming_skb(struct sk_buff *skb)
int llc_pdu_router(struct llc_sap *sap, struct sock* sk, int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
struct sk_buff *skb, u8 type) struct sk_buff *skb, u8 type)
{ {
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw; struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
int rc = 0; int rc = 0;
if (!pdu->dsap) { if (!pdu->dsap) {
...@@ -208,7 +214,8 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk, ...@@ -208,7 +214,8 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
stat_ev->data.pdu.skb = skb; stat_ev->data.pdu.skb = skb;
stat_ev->data.pdu.reason = 0; stat_ev->data.pdu.reason = 0;
llc_station_send_ev(station, stat_ev); llc_station_send_ev(station, stat_ev);
} } else
rc = -ENOMEM;
} else if (type == LLC_TYPE_1) { } else if (type == LLC_TYPE_1) {
struct llc_sap_state_ev *sap_ev = llc_sap_alloc_ev(sap); struct llc_sap_state_ev *sap_ev = llc_sap_alloc_ev(sap);
...@@ -217,7 +224,8 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk, ...@@ -217,7 +224,8 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
sap_ev->data.pdu.skb = skb; sap_ev->data.pdu.skb = skb;
sap_ev->data.pdu.reason = 0; sap_ev->data.pdu.reason = 0;
llc_sap_send_ev(sap, sap_ev); llc_sap_send_ev(sap, sap_ev);
} } else
rc = -ENOMEM;
} else if (type == LLC_TYPE_2) { } else if (type == LLC_TYPE_2) {
struct llc_conn_state_ev *conn_ev = llc_conn_alloc_ev(sk); struct llc_conn_state_ev *conn_ev = llc_conn_alloc_ev(sk);
struct llc_opt *llc = llc_sk(sk); struct llc_opt *llc = llc_sk(sk);
...@@ -229,8 +237,10 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk, ...@@ -229,8 +237,10 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
conn_ev->data.pdu.skb = skb; conn_ev->data.pdu.skb = skb;
conn_ev->data.pdu.reason = 0; conn_ev->data.pdu.reason = 0;
rc = llc_conn_send_ev(sk, conn_ev); rc = llc_conn_send_ev(sk, conn_ev);
} } else
} rc = -ENOMEM;
} else
rc = -EINVAL;
return rc; return rc;
} }
......
...@@ -50,15 +50,7 @@ static struct llc_station_state_trans * ...@@ -50,15 +50,7 @@ static struct llc_station_state_trans *
struct llc_station_state_ev *ev); struct llc_station_state_ev *ev);
static int llc_rtn_all_conns(struct llc_sap *sap); static int llc_rtn_all_conns(struct llc_sap *sap);
extern void llc_register_sap(unsigned char sap,
int (*rcvfunc)(struct sk_buff *skb,
struct net_device *dev,
struct packet_type *pt));
extern void llc_unregister_sap(unsigned char sap);
static struct llc_station llc_main_station; /* only one of its kind */ static struct llc_station llc_main_station; /* only one of its kind */
struct llc_prim_if_block llc_ind_prim, llc_cfm_prim;
static union llc_u_prim_data llc_ind_data_prim, llc_cfm_data_prim;
/** /**
* llc_sap_alloc - allocates and initializes sap. * llc_sap_alloc - allocates and initializes sap.
...@@ -76,6 +68,8 @@ struct llc_sap *llc_sap_alloc(void) ...@@ -76,6 +68,8 @@ struct llc_sap *llc_sap_alloc(void)
spin_lock_init(&sap->sk_list.lock); spin_lock_init(&sap->sk_list.lock);
INIT_LIST_HEAD(&sap->sk_list.list); INIT_LIST_HEAD(&sap->sk_list.list);
skb_queue_head_init(&sap->mac_pdu_q); skb_queue_head_init(&sap->mac_pdu_q);
sap->llc_ind_prim.data = &sap->llc_ind_data_prim;
sap->llc_cfm_prim.data = &sap->llc_cfm_data_prim;
} }
return sap; return sap;
} }
...@@ -238,7 +232,7 @@ void __llc_sock_free(struct sock *sk, u8 free) ...@@ -238,7 +232,7 @@ void __llc_sock_free(struct sock *sk, u8 free)
/* stop all (possibly) running timers */ /* stop all (possibly) running timers */
llc_conn_ac_stop_all_timers(sk, NULL); llc_conn_ac_stop_all_timers(sk, NULL);
/* handle return of frames on lists */ /* handle return of frames on lists */
printk(KERN_INFO __FUNCTION__ ": unackq=%d, txq=%d\n", printk(KERN_INFO "%s: unackq=%d, txq=%d\n", __FUNCTION__,
skb_queue_len(&llc->pdu_unack_q), skb_queue_len(&llc->pdu_unack_q),
skb_queue_len(&sk->write_queue)); skb_queue_len(&sk->write_queue));
skb_queue_purge(&sk->write_queue); skb_queue_purge(&sk->write_queue);
...@@ -580,6 +574,18 @@ static int llc_proc_get_info(char *bf, char **start, off_t offset, int length) ...@@ -580,6 +574,18 @@ static int llc_proc_get_info(char *bf, char **start, off_t offset, int length)
return len; return len;
} }
static struct packet_type llc_packet_type = {
.type = __constant_htons(ETH_P_802_2),
.func = mac_indicate,
.data = (void *)1,
};
static struct packet_type llc_tr_packet_type = {
.type = __constant_htons(ETH_P_TR_802_2),
.func = mac_indicate,
.data = (void *)1,
};
static char llc_banner[] __initdata = static char llc_banner[] __initdata =
KERN_INFO "LLC 2.0 by Procom, 1997, Arnaldo C. Melo, 2001\n" KERN_INFO "LLC 2.0 by Procom, 1997, Arnaldo C. Melo, 2001\n"
KERN_INFO "NET4.0 IEEE 802.2 extended support\n"; KERN_INFO "NET4.0 IEEE 802.2 extended support\n";
...@@ -612,12 +618,10 @@ static int __init llc_init(void) ...@@ -612,12 +618,10 @@ static int __init llc_init(void)
ev->type = LLC_STATION_EV_TYPE_SIMPLE; ev->type = LLC_STATION_EV_TYPE_SIMPLE;
ev->data.a.ev = LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK; ev->data.a.ev = LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK;
rc = llc_station_next_state(&llc_main_station, ev); rc = llc_station_next_state(&llc_main_station, ev);
llc_ind_prim.data = &llc_ind_data_prim;
llc_cfm_prim.data = &llc_cfm_data_prim;
proc_net_create("802.2", 0, llc_proc_get_info); proc_net_create("802.2", 0, llc_proc_get_info);
/* initialize the station component */
llc_register_sap(0, mac_indicate);
llc_ui_init(); llc_ui_init();
dev_add_pack(&llc_packet_type);
dev_add_pack(&llc_tr_packet_type);
out: out:
return rc; return rc;
err: err:
...@@ -629,7 +633,8 @@ static int __init llc_init(void) ...@@ -629,7 +633,8 @@ static int __init llc_init(void)
static void __exit llc_exit(void) static void __exit llc_exit(void)
{ {
llc_ui_exit(); llc_ui_exit();
llc_unregister_sap(0); dev_remove_pack(&llc_packet_type);
dev_remove_pack(&llc_tr_packet_type);
proc_net_remove("802.2"); proc_net_remove("802.2");
} }
......
This diff is collapsed.
...@@ -28,7 +28,7 @@ int llc_sap_ev_activation_req(struct llc_sap *sap, struct llc_sap_state_ev *ev) ...@@ -28,7 +28,7 @@ int llc_sap_ev_activation_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_ui(struct llc_sap *sap, struct llc_sap_state_ev *ev) int llc_sap_ev_rx_ui(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{ {
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) && return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
...@@ -52,7 +52,7 @@ int llc_sap_ev_xid_req(struct llc_sap *sap, struct llc_sap_state_ev *ev) ...@@ -52,7 +52,7 @@ int llc_sap_ev_xid_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev) int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{ {
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) && return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
...@@ -61,7 +61,7 @@ int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev) ...@@ -61,7 +61,7 @@ int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct llc_sap_state_ev *ev) int llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{ {
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) && return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
...@@ -77,7 +77,7 @@ int llc_sap_ev_test_req(struct llc_sap *sap, struct llc_sap_state_ev *ev) ...@@ -77,7 +77,7 @@ int llc_sap_ev_test_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev) int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{ {
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) && return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
...@@ -86,7 +86,7 @@ int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev) ...@@ -86,7 +86,7 @@ int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_test_r(struct llc_sap *sap, struct llc_sap_state_ev *ev) int llc_sap_ev_rx_test_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{ {
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw; struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) && return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) && !LLC_PDU_TYPE_IS_U(pdu) &&
......
...@@ -89,15 +89,10 @@ struct llc_sap_state_ev *llc_sap_alloc_ev(struct llc_sap *sap) ...@@ -89,15 +89,10 @@ struct llc_sap_state_ev *llc_sap_alloc_ev(struct llc_sap *sap)
*/ */
void llc_sap_send_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev) void llc_sap_send_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{ {
struct llc_prim_if_block *prim;
u8 flag;
llc_sap_next_state(sap, ev); llc_sap_next_state(sap, ev);
flag = ev->ind_cfm_flag; if (ev->ind_cfm_flag == LLC_IND) {
prim = ev->prim;
if (flag == LLC_IND) {
skb_get(ev->data.pdu.skb); skb_get(ev->data.pdu.skb);
sap->ind(prim); sap->ind(ev->prim);
} }
llc_sap_free_ev(sap, ev); llc_sap_free_ev(sap, ev);
} }
...@@ -112,8 +107,8 @@ void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb, ...@@ -112,8 +107,8 @@ void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb,
struct llc_sap_state_ev *ev) struct llc_sap_state_ev *ev)
{ {
struct llc_pdu_un *pdu; struct llc_pdu_un *pdu;
struct llc_prim_if_block *prim = &llc_ind_prim; struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = llc_ind_prim.data; union llc_u_prim_data *prim_data = prim->data;
u8 lfb; u8 lfb;
llc_pdu_decode_sa(skb, prim_data->udata.saddr.mac); llc_pdu_decode_sa(skb, prim_data->udata.saddr.mac);
...@@ -122,7 +117,7 @@ void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb, ...@@ -122,7 +117,7 @@ void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb,
llc_pdu_decode_ssap(skb, &prim_data->udata.saddr.lsap); llc_pdu_decode_ssap(skb, &prim_data->udata.saddr.lsap);
prim_data->udata.pri = 0; prim_data->udata.pri = 0;
prim_data->udata.skb = skb; prim_data->udata.skb = skb;
pdu = (struct llc_pdu_un *)skb->nh.raw; pdu = llc_pdu_un_hdr(skb);
switch (LLC_U_PDU_RSP(pdu)) { switch (LLC_U_PDU_RSP(pdu)) {
case LLC_1_PDU_CMD_TEST: case LLC_1_PDU_CMD_TEST:
prim->prim = LLC_TEST_PRIM; prim->prim = LLC_TEST_PRIM;
...@@ -169,13 +164,8 @@ void llc_sap_send_pdu(struct llc_sap *sap, struct sk_buff *skb) ...@@ -169,13 +164,8 @@ void llc_sap_send_pdu(struct llc_sap *sap, struct sk_buff *skb)
*/ */
static void llc_sap_free_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev) static void llc_sap_free_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{ {
if (ev->type == LLC_SAP_EV_TYPE_PDU) { if (ev->type == LLC_SAP_EV_TYPE_PDU)
struct llc_pdu_un *pdu =
(struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
if (LLC_U_PDU_CMD(pdu) != LLC_1_PDU_CMD_UI)
kfree_skb(ev->data.pdu.skb); kfree_skb(ev->data.pdu.skb);
}
kfree(ev); kfree(ev);
} }
......
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/init.h> #include <linux/init.h>
#define dprintk(format, a...) printk(KERN_INFO __FUNCTION__ ": " format, ##a)
/* remember: uninitialized global data is zeroed because its in .bss */ /* remember: uninitialized global data is zeroed because its in .bss */
static u16 llc_ui_sap_last_autoport = LLC_SAP_DYN_START; static u16 llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
static u16 llc_ui_sap_link_no_max[256]; static u16 llc_ui_sap_link_no_max[256];
...@@ -527,8 +525,6 @@ static int llc_ui_release(struct socket *sock) ...@@ -527,8 +525,6 @@ static int llc_ui_release(struct socket *sock)
llc_ui_remove_socket(sk); llc_ui_remove_socket(sk);
if (llc_ui->sap && !llc_ui_find_sap(llc_ui->sap->laddr.lsap)) if (llc_ui->sap && !llc_ui_find_sap(llc_ui->sap->laddr.lsap))
llc_sap_close(llc_ui->sap); llc_sap_close(llc_ui->sap);
dprintk("rxq=%d, txq=%d\n", skb_queue_len(&sk->receive_queue),
skb_queue_len(&sk->write_queue));
sock_orphan(sk); sock_orphan(sk);
sock->sk = NULL; sock->sk = NULL;
if (!atomic_read(&sk->wmem_alloc) && if (!atomic_read(&sk->wmem_alloc) &&
...@@ -1416,10 +1412,8 @@ static void llc_ui_ind_conn(struct llc_prim_if_block *prim) ...@@ -1416,10 +1412,8 @@ static void llc_ui_ind_conn(struct llc_prim_if_block *prim)
llc_sk(prim_data->sk)->laddr.lsap = prim->sap->laddr.lsap; llc_sk(prim_data->sk)->laddr.lsap = prim->sap->laddr.lsap;
sk = llc_ui_find_sk_by_addr(&llc_sk(prim_data->sk)->laddr, sk = llc_ui_find_sk_by_addr(&llc_sk(prim_data->sk)->laddr,
&prim_data->saddr, prim_data->dev); &prim_data->saddr, prim_data->dev);
if (!sk) { if (!sk)
dprintk("llc_ui_find_sk_by_addr failed\n");
goto out; goto out;
}
if (sk->type != SOCK_STREAM || sk->state != TCP_LISTEN) if (sk->type != SOCK_STREAM || sk->state != TCP_LISTEN)
goto out_put; goto out_put;
if (prim->data->conn.status) if (prim->data->conn.status)
...@@ -1469,10 +1463,8 @@ static void llc_ui_ind_data(struct llc_prim_if_block *prim) ...@@ -1469,10 +1463,8 @@ static void llc_ui_ind_data(struct llc_prim_if_block *prim)
memcpy(llc_ui->sllc_smac, llc_sk(prim_data->sk)->daddr.mac, memcpy(llc_ui->sllc_smac, llc_sk(prim_data->sk)->daddr.mac,
IFHWADDRLEN); IFHWADDRLEN);
/* queue skb to the user. */ /* queue skb to the user. */
if (sock_queue_rcv_skb(sk, skb)) { if (sock_queue_rcv_skb(sk, skb))
dprintk("sock_queue_rcv_skb failed!\n");
kfree_skb(skb); kfree_skb(skb);
}
out_put: out_put:
sock_put(sk); sock_put(sk);
out:; out:;
...@@ -1547,13 +1539,11 @@ static void llc_ui_conf_conn(struct llc_prim_if_block *prim) ...@@ -1547,13 +1539,11 @@ static void llc_ui_conf_conn(struct llc_prim_if_block *prim)
{ {
struct llc_prim_conn *prim_data = &prim->data->conn; struct llc_prim_conn *prim_data = &prim->data->conn;
struct llc_opt *llc_core = llc_sk(prim_data->sk); struct llc_opt *llc_core = llc_sk(prim_data->sk);
struct llc_ui_opt *llc_ui = llc_ui_sk(prim_data->sk);
struct sock* sk = llc_core->handler; struct sock* sk = llc_core->handler;
struct llc_ui_opt *llc_ui = llc_ui_sk(sk);
if (!sk) { if (!sk)
dprintk("llc_core->handler == NULL!\n");
goto out; goto out;
}
sock_hold(sk); sock_hold(sk);
if (sk->type != SOCK_STREAM || sk->state != TCP_SYN_SENT) if (sk->type != SOCK_STREAM || sk->state != TCP_SYN_SENT)
goto out_put; goto out_put;
...@@ -1562,8 +1552,6 @@ static void llc_ui_conf_conn(struct llc_prim_if_block *prim) ...@@ -1562,8 +1552,6 @@ static void llc_ui_conf_conn(struct llc_prim_if_block *prim)
sk->state = TCP_ESTABLISHED; sk->state = TCP_ESTABLISHED;
llc_ui->core_sk = prim_data->sk; llc_ui->core_sk = prim_data->sk;
} else { } else {
dprintk("prim->data->conn.status = %d\n",
prim->data->conn.status);
sk->socket->state = SS_UNCONNECTED; sk->socket->state = SS_UNCONNECTED;
sk->state = TCP_CLOSE; sk->state = TCP_CLOSE;
llc_ui->core_sk = NULL; llc_ui->core_sk = NULL;
...@@ -1633,7 +1621,7 @@ static int llc_ui_confirm(struct llc_prim_if_block *prim) ...@@ -1633,7 +1621,7 @@ static int llc_ui_confirm(struct llc_prim_if_block *prim)
llc_ui_conf_disc(prim); break; llc_ui_conf_disc(prim); break;
case LLC_RESET_PRIM: break; case LLC_RESET_PRIM: break;
default: default:
printk(KERN_ERR __FUNCTION__ ": unknown prim %d\n", printk(KERN_ERR "%s: unknown prim %d\n", __FUNCTION__,
prim->prim); prim->prim);
break; break;
} }
......
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