patch-2.1.96 linux/net/ipx/af_ipx.c
Next file: linux/net/ipx/af_spx.c
Previous file: linux/net/ipx/Makefile
Back to the patch index
Back to the overall index
- Lines: 166
- Date:
Sat Apr 11 17:18:16 1998
- Orig file:
v2.1.95/linux/net/ipx/af_ipx.c
- Orig date:
Tue Mar 17 22:18:16 1998
diff -u --recursive --new-file v2.1.95/linux/net/ipx/af_ipx.c linux/net/ipx/af_ipx.c
@@ -1,5 +1,5 @@
/*
- * Implements an IPX socket layer (badly - but I'm working on it).
+ * Implements an IPX socket layer.
*
* This code is derived from work by
* Ross Biro : Writing the original IP stack
@@ -47,6 +47,7 @@
* Revision 0.36: Internal bump up for 2.1
* Revision 0.37: Began adding POSIXisms.
* Revision 0.38: Asynchronous socket stuff made current.
+ * Revision 0.39: SPX interfaces
*
* Protect the module by a MOD_INC_USE_COUNT/MOD_DEC_USE_COUNT
* pair. Also, now usage count is managed this way
@@ -111,6 +112,8 @@
static struct proto_ops ipx_dgram_ops;
+static struct net_proto_family *spx_family_ops;
+
static ipx_route *ipx_routes = NULL;
static ipx_interface *ipx_interfaces = NULL;
static ipx_interface *ipx_primary_net = NULL;
@@ -163,7 +166,7 @@
* use this facility.
*/
-static void ipx_remove_socket(struct sock *sk)
+void ipx_remove_socket(struct sock *sk)
{
struct sock *s;
ipx_interface *intrfc;
@@ -762,8 +765,8 @@
if (call_fw_firewall(PF_IPX, skb->dev, ipx, NULL, &skb)==FW_ACCEPT)
{
skb2 = skb_clone(skb, GFP_ATOMIC);
- ipxrtr_route_skb(skb2);
- }
+ ipxrtr_route_skb(skb2);
+ }
}
}
/*
@@ -1264,6 +1267,9 @@
*/
__u32 i=length>>1;
+ char hops = packet->ipx_tctrl;
+
+ packet->ipx_tctrl = 0; /* hop count excluded from checksum calc */
/*
* Loop through all complete words except the checksum field
@@ -1279,6 +1285,7 @@
if(packet->ipx_pktsize&htons(1))
sum+=ntohs(0xff00)&*p;
+ packet->ipx_tctrl = hops;
/*
* Do final fixup
*/
@@ -1713,19 +1720,24 @@
static int ipx_create(struct socket *sock, int protocol)
{
struct sock *sk;
- sk=sk_alloc(AF_IPX, GFP_KERNEL, 1);
- if(sk==NULL)
- return(-ENOMEM);
switch(sock->type)
{
case SOCK_DGRAM:
+ sk=sk_alloc(AF_IPX, GFP_KERNEL, 1);
+ if(sk==NULL)
+ return(-ENOMEM);
sock->ops = &ipx_dgram_ops;
break;
- case SOCK_STREAM: /* Allow higher levels to piggyback */
case SOCK_SEQPACKET:
- printk(KERN_CRIT "IPX: _create-ing non_DGRAM socket\n");
+ /*
+ * From this point on SPX sockets are handled
+ * by af_spx.c and the methods replaced.
+ */
+ if(spx_family_ops)
+ return spx_family_ops->create(sock,protocol);
+ /* Fall through if SPX is not loaded */
+ case SOCK_STREAM: /* Allow higher levels to piggyback */
default:
- sk_free(sk);
return(-ESOCKTNOSUPPORT);
}
sock_init_data(sock,sk);
@@ -2249,6 +2261,34 @@
return(0);
}
+/*
+ * SPX interface support
+ */
+
+int ipx_register_spx(struct proto_ops **p, struct net_proto_family *spx)
+{
+ if(spx_family_ops!=NULL)
+ return -EBUSY;
+ cli();
+ MOD_INC_USE_COUNT;
+ *p=&ipx_dgram_ops;
+ spx_family_ops=spx;
+ sti();
+ return 0;
+}
+
+int ipx_unregister_spx(void)
+{
+ spx_family_ops=NULL;
+ MOD_DEC_USE_COUNT;
+ return 0;
+}
+
+
+/*
+ * Socket family declarations
+ */
+
static struct net_proto_family ipx_family_ops = {
AF_IPX,
ipx_create
@@ -2256,7 +2296,6 @@
static struct proto_ops ipx_dgram_ops = {
AF_IPX,
-
sock_no_dup,
ipx_release,
ipx_bind,
@@ -2280,7 +2319,7 @@
static struct packet_type ipx_8023_packet_type =
{
- 0, /* MUTTER ntohs(ETH_P_8023),*/
+ 0, /* MUTTER ntohs(ETH_P_802_3),*/
NULL, /* All devices */
ipx_rcv,
NULL,
@@ -2371,6 +2410,10 @@
/* Export symbols for higher layers */
EXPORT_SYMBOL(ipxrtr_route_skb);
EXPORT_SYMBOL(ipx_if_offset);
+EXPORT_SYMBOL(ipx_remove_socket);
+EXPORT_SYMBOL(ipx_register_spx);
+EXPORT_SYMBOL(ipx_unregister_spx);
+
#ifdef MODULE
/* Note on MOD_{INC,DEC}_USE_COUNT:
@@ -2387,7 +2430,8 @@
*/
__initfunc(static void ipx_proto_finito(void))
-{ ipx_interface *ifc;
+{
+ ipx_interface *ifc;
while (ipx_interfaces) {
ifc = ipx_interfaces;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov