2 * An implementation of the Acorn Econet and AUN protocols.
3 * Philip Blundell <philb@gnu.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
14 #include <linux/config.h>
15 #include <linux/module.h>
17 #include <asm/uaccess.h>
18 #include <asm/system.h>
19 #include <asm/bitops.h>
20 #include <linux/types.h>
21 #include <linux/kernel.h>
22 #include <linux/sched.h>
23 #include <linux/string.h>
25 #include <linux/socket.h>
26 #include <linux/sockios.h>
28 #include <linux/errno.h>
29 #include <linux/interrupt.h>
30 #include <linux/if_ether.h>
31 #include <linux/netdevice.h>
32 #include <linux/inetdevice.h>
33 #include <linux/route.h>
34 #include <linux/inet.h>
35 #include <linux/etherdevice.h>
36 #include <linux/if_arp.h>
37 #include <linux/wireless.h>
38 #include <linux/skbuff.h>
40 #include <net/inet_common.h>
41 #include <linux/stat.h>
42 #include <linux/init.h>
43 #include <linux/if_ec.h>
46 #include <asm/spinlock.h>
48 static struct proto_ops econet_ops
;
49 static struct sock
*econet_sklist
;
51 static spinlock_t aun_queue_lock
;
53 #ifdef CONFIG_ECONET_AUNUDP
54 static struct socket
*udpsock
;
55 #define AUN_PORT 0x8000
59 unsigned char code
; /* AUN magic protocol byte */
66 static unsigned long aun_seq
= 0;
68 /* Queue of packets waiting to be transmitted. */
69 static struct sk_buff_head aun_queue
;
70 static struct timer_list ab_cleanup_timer
;
72 #endif /* CONFIG_ECONET_AUNUDP */
74 /* Per-packet information */
77 struct sockaddr_ec sec
;
78 unsigned long cookie
; /* Supplied by user. */
79 #ifdef CONFIG_ECONET_AUNUDP
81 unsigned long seq
; /* Sequencing */
82 unsigned long timeout
; /* Timeout */
83 unsigned long start
; /* jiffies */
85 #ifdef CONFIG_ECONET_NATIVE
86 void (*sent
)(struct sk_buff
*, int result
);
92 struct device
*dev
; /* Real device structure */
93 unsigned char station
, net
; /* Econet protocol address */
94 struct ec_device
*prev
, *next
; /* Linked list */
97 static struct ec_device
*edevlist
= NULL
;
99 static spinlock_t edevlist_lock
;
102 * Faster version of edev_get - call with IRQs off
105 static __inline__
struct ec_device
*__edev_get(struct device
*dev
)
107 struct ec_device
*edev
;
108 for (edev
= edevlist
; edev
; edev
= edev
->next
)
110 if (edev
->dev
== dev
)
117 * Find an Econet device given its `dev' pointer. This is IRQ safe.
120 static struct ec_device
*edev_get(struct device
*dev
)
122 struct ec_device
*edev
;
124 spin_lock_irqsave(&edevlist_lock
, flags
);
125 edev
= __edev_get(dev
);
126 spin_unlock_irqrestore(&edevlist_lock
, flags
);
131 * Pull a packet from our receive queue and hand it to the user.
132 * If necessary we block.
135 static int econet_recvmsg(struct socket
*sock
, struct msghdr
*msg
, int len
,
136 int flags
, struct scm_cookie
*scm
)
138 struct sock
*sk
= sock
->sk
;
142 msg
->msg_namelen
= sizeof(struct sockaddr_ec
);
145 * Call the generic datagram receiver. This handles all sorts
146 * of horrible races and re-entrancy so we can forget about it
147 * in the protocol layers.
149 * Now it will return ENETDOWN, if device have just gone down,
150 * but then it will block.
153 skb
=skb_recv_datagram(sk
,flags
,flags
&MSG_DONTWAIT
,&err
);
156 * An error occurred so return it. Because skb_recv_datagram()
157 * handles the blocking we don't see and worry about blocking
165 * You lose any data beyond the buffer you gave. If it worries a
166 * user program they can ask the device for its MTU anyway.
173 msg
->msg_flags
|=MSG_TRUNC
;
176 /* We can't use skb_copy_datagram here */
177 err
= memcpy_toiovec(msg
->msg_iov
, skb
->data
, copied
);
180 sk
->stamp
=skb
->stamp
;
183 memcpy(msg
->msg_name
, skb
->cb
, msg
->msg_namelen
);
186 * Free or return the buffer as appropriate. Again this
187 * hides all the races and re-entrancy issues from us.
192 skb_free_datagram(sk
, skb
);
198 * Bind an Econet socket.
201 static int econet_bind(struct socket
*sock
, struct sockaddr
*uaddr
, int addr_len
)
203 struct sockaddr_ec
*sec
= (struct sockaddr_ec
*)uaddr
;
204 struct sock
*sk
=sock
->sk
;
210 if (addr_len
< sizeof(struct sockaddr_ec
))
212 if (sec
->sec_family
!= AF_ECONET
)
215 sk
->protinfo
.af_econet
->cb
= sec
->cb
;
216 sk
->protinfo
.af_econet
->port
= sec
->port
;
217 sk
->protinfo
.af_econet
->station
= sec
->addr
.station
;
218 sk
->protinfo
.af_econet
->net
= sec
->addr
.net
;
224 * Queue a transmit result for the user to be told about.
227 static void tx_result(struct sock
*sk
, unsigned long cookie
, int result
)
229 struct sk_buff
*skb
= alloc_skb(0, GFP_ATOMIC
);
231 struct sockaddr_ec
*sec
;
235 printk(KERN_DEBUG
"ec: memory squeeze, transmit result dropped.\n");
239 eb
= (struct ec_cb
*)&skb
->cb
;
240 sec
= (struct sockaddr_ec
*)&eb
->sec
;
241 memset(sec
, 0, sizeof(struct sockaddr_ec
));
242 sec
->cookie
= cookie
;
243 sec
->type
= ECTYPE_TRANSMIT_STATUS
| result
;
244 sec
->sec_family
= AF_ECONET
;
246 if (sock_queue_rcv_skb(sk
, skb
) < 0)
250 #ifdef CONFIG_ECONET_NATIVE
252 * Called by the Econet hardware driver when a packet transmit
253 * has completed. Tell the user.
256 static void ec_tx_done(struct sk_buff
*skb
, int result
)
258 struct ec_cb
*eb
= (struct ec_cb
*)&skb
->cb
;
259 tx_result(skb
->sk
, eb
->cookie
, result
);
264 * Send a packet. We have to work out which device it's going out on
265 * and hence whether to use real Econet or the UDP emulation.
268 static int econet_sendmsg(struct socket
*sock
, struct msghdr
*msg
, int len
,
269 struct scm_cookie
*scm
)
271 struct sock
*sk
= sock
->sk
;
272 struct sockaddr_ec
*saddr
=(struct sockaddr_ec
*)msg
->msg_name
;
275 struct ec_device
*edev
;
277 unsigned char port
, cb
;
280 #ifdef CONFIG_ECONET_NATIVE
281 unsigned short proto
= 0;
283 #ifdef CONFIG_ECONET_AUNUDP
284 struct msghdr udpmsg
;
285 struct iovec iov
[msg
->msg_iovlen
+1];
287 struct sockaddr_in udpdest
;
288 __kernel_size_t size
;
297 if (msg
->msg_flags
&~MSG_DONTWAIT
)
301 * Get and verify the address.
305 addr
.station
= sk
->protinfo
.af_econet
->station
;
306 addr
.net
= sk
->protinfo
.af_econet
->net
;
307 port
= sk
->protinfo
.af_econet
->port
;
308 cb
= sk
->protinfo
.af_econet
->cb
;
310 if (msg
->msg_namelen
< sizeof(struct sockaddr_ec
))
312 addr
.station
= saddr
->addr
.station
;
313 addr
.net
= saddr
->addr
.net
;
318 /* Look for a device with the right network number. */
319 for (edev
= edevlist
; edev
&& (edev
->net
!= addr
.net
);
322 /* Bridge? What's that? */
328 if (dev
->type
== ARPHRD_ECONET
)
330 /* Real hardware Econet. We're not worthy etc. */
331 #ifdef CONFIG_ECONET_NATIVE
334 skb
= sock_alloc_send_skb(sk
, len
+dev
->hard_header_len
+15, 0,
335 msg
->msg_flags
& MSG_DONTWAIT
, &err
);
339 skb_reserve(skb
, (dev
->hard_header_len
+15)&~15);
340 skb
->nh
.raw
= skb
->data
;
342 eb
= (struct ec_cb
*)&skb
->cb
;
344 eb
->cookie
= saddr
->cookie
;
346 eb
->sent
= ec_tx_done
;
348 if (dev
->hard_header
) {
351 res
= dev
->hard_header(skb
, dev
, ntohs(proto
), &addr
, NULL
, len
);
352 if (sock
->type
!= SOCK_DGRAM
) {
353 skb
->tail
= skb
->data
;
359 /* Copy the data. Returns -EFAULT on error */
360 err
= memcpy_fromiovec(skb_put(skb
,len
), msg
->msg_iov
, len
);
361 skb
->protocol
= proto
;
363 skb
->priority
= sk
->priority
;
368 if (!(dev
->flags
& IFF_UP
))
389 #ifdef CONFIG_ECONET_AUNUDP
390 /* AUN virtual Econet. */
393 return -ENETDOWN
; /* No socket - can't send */
395 /* Make up a UDP datagram and hand it off to some higher intellect. */
397 memset(&udpdest
, 0, sizeof(udpdest
));
398 udpdest
.sin_family
= AF_INET
;
399 udpdest
.sin_port
= htons(AUN_PORT
);
401 /* At the moment we use the stupid Acorn scheme of Econet address
402 y.x maps to IP a.b.c.x. This should be replaced with something
403 more flexible and more aware of subnet masks. */
405 struct in_device
*idev
= (struct in_device
*)dev
->ip_ptr
;
406 unsigned long network
= ntohl(idev
->ifa_list
->ifa_address
) &
407 0xffffff00; /* !!! */
408 udpdest
.sin_addr
.s_addr
= htonl(network
| addr
.station
);
413 ah
.code
= 2; /* magic */
416 /* tack our header on the front of the iovec */
417 size
= sizeof(struct aunhdr
);
418 iov
[0].iov_base
= (void *)&ah
;
419 iov
[0].iov_len
= size
;
420 for (i
= 0; i
< msg
->msg_iovlen
; i
++) {
421 void *base
= msg
->msg_iov
[i
].iov_base
;
422 size_t len
= msg
->msg_iov
[i
].iov_len
;
423 /* Check it now since we switch to KERNEL_DS later. */
424 if ((err
= verify_area(VERIFY_READ
, base
, len
)) < 0)
426 iov
[i
+1].iov_base
= base
;
427 iov
[i
+1].iov_len
= len
;
431 /* Get a skbuff (no data, just holds our cb information) */
432 if ((skb
= sock_alloc_send_skb(sk
, 0, 0,
433 msg
->msg_flags
& MSG_DONTWAIT
, &err
)) == NULL
)
436 eb
= (struct ec_cb
*)&skb
->cb
;
438 eb
->cookie
= saddr
->cookie
;
439 eb
->timeout
= (5*HZ
);
442 eb
->seq
= (aun_seq
++);
445 skb_queue_tail(&aun_queue
, skb
);
447 udpmsg
.msg_name
= (void *)&udpdest
;
448 udpmsg
.msg_namelen
= sizeof(udpdest
);
449 udpmsg
.msg_iov
= &iov
[0];
450 udpmsg
.msg_iovlen
= msg
->msg_iovlen
+ 1;
451 udpmsg
.msg_control
= NULL
;
452 udpmsg
.msg_controllen
= 0;
455 oldfs
= get_fs(); set_fs(KERNEL_DS
); /* More privs :-) */
456 err
= sock_sendmsg(udpsock
, &udpmsg
, size
);
465 * Look up the address of a socket.
468 static int econet_getname(struct socket
*sock
, struct sockaddr
*uaddr
,
469 int *uaddr_len
, int peer
)
471 struct sock
*sk
= sock
->sk
;
472 struct sockaddr_ec
*sec
= (struct sockaddr_ec
*)uaddr
;
477 sec
->sec_family
= AF_ECONET
;
478 sec
->port
= sk
->protinfo
.af_econet
->port
;
479 sec
->addr
.station
= sk
->protinfo
.af_econet
->station
;
480 sec
->addr
.net
= sk
->protinfo
.af_econet
->net
;
482 *uaddr_len
= sizeof(*sec
);
486 static void econet_destroy_timer(unsigned long data
)
488 struct sock
*sk
=(struct sock
*)data
;
490 if (!atomic_read(&sk
->wmem_alloc
) && !atomic_read(&sk
->rmem_alloc
)) {
496 sk
->timer
.expires
=jiffies
+10*HZ
;
497 add_timer(&sk
->timer
);
498 printk(KERN_DEBUG
"econet socket destroy delayed\n");
502 * Close an econet socket.
505 static int econet_release(struct socket
*sock
, struct socket
*peersock
)
508 struct sock
*sk
= sock
->sk
;
513 sklist_remove_socket(&econet_sklist
, sk
);
516 * Now the socket is dead. No more input will appear.
519 sk
->state_change(sk
); /* It is useless. Just for sanity. */
527 while ((skb
=skb_dequeue(&sk
->receive_queue
))!=NULL
)
530 if (atomic_read(&sk
->rmem_alloc
) || atomic_read(&sk
->wmem_alloc
)) {
531 sk
->timer
.data
=(unsigned long)sk
;
532 sk
->timer
.expires
=jiffies
+HZ
;
533 sk
->timer
.function
=econet_destroy_timer
;
534 add_timer(&sk
->timer
);
544 * Create an Econet socket
547 static int econet_create(struct socket
*sock
, int protocol
)
552 /* Econet only provides datagram services. */
553 if (sock
->type
!= SOCK_DGRAM
)
554 return -ESOCKTNOSUPPORT
;
556 sock
->state
= SS_UNCONNECTED
;
560 sk
= sk_alloc(PF_ECONET
, GFP_KERNEL
, 1);
565 sock
->ops
= &econet_ops
;
566 sock_init_data(sock
,sk
);
568 sk
->protinfo
.af_econet
= kmalloc(sizeof(struct econet_opt
), GFP_KERNEL
);
569 if (sk
->protinfo
.af_econet
== NULL
)
571 memset(sk
->protinfo
.af_econet
, 0, sizeof(struct econet_opt
));
573 sk
->family
= PF_ECONET
;
576 sklist_insert_socket(&econet_sklist
, sk
);
587 * Handle Econet specific ioctls
590 static int ec_dev_ioctl(struct socket
*sock
, unsigned int cmd
, void *arg
)
593 struct ec_device
*edev
;
596 struct sockaddr_ec
*sec
;
599 * Fetch the caller's info block into kernel space
602 if (copy_from_user(&ifr
, arg
, sizeof(struct ifreq
)))
605 if ((dev
= dev_get(ifr
.ifr_name
)) == NULL
)
608 sec
= (struct sockaddr_ec
*)&ifr
.ifr_addr
;
613 spin_lock_irqsave(&edevlist_lock
, flags
);
614 edev
= __edev_get(dev
);
617 /* Magic up a new one. */
618 edev
= kmalloc(GFP_KERNEL
, sizeof(struct ec_device
));
620 printk("af_ec: memory squeeze.\n");
621 spin_unlock_irqrestore(&edevlist_lock
, flags
);
624 memset(edev
, 0, sizeof(struct ec_device
));
626 edev
->next
= edevlist
;
629 edev
->station
= sec
->addr
.station
;
630 edev
->net
= sec
->addr
.net
;
631 spin_unlock_irqrestore(&edevlist_lock
, flags
);
635 spin_lock_irqsave(&edevlist_lock
, flags
);
636 edev
= __edev_get(dev
);
639 spin_unlock_irqrestore(&edevlist_lock
, flags
);
642 memset(sec
, 0, sizeof(struct sockaddr_ec
));
643 sec
->addr
.station
= edev
->station
;
644 sec
->addr
.net
= edev
->net
;
645 sec
->sec_family
= AF_ECONET
;
646 spin_unlock_irqrestore(&edevlist_lock
, flags
);
647 if (copy_to_user(arg
, &ifr
, sizeof(struct ifreq
)))
656 * Handle generic ioctls
659 static int econet_ioctl(struct socket
*sock
, unsigned int cmd
, unsigned long arg
)
661 struct sock
*sk
= sock
->sk
;
669 err
= get_user(pid
, (int *) arg
);
672 if (current
->pid
!= pid
&& current
->pgrp
!= -pid
&& !suser())
678 return put_user(sk
->proc
, (int *)arg
);
680 if(sk
->stamp
.tv_sec
==0)
683 if (!copy_to_user((void *)arg
, &sk
->stamp
, sizeof(struct timeval
)))
705 case SIOCSIFHWBROADCAST
:
706 return(dev_ioctl(cmd
,(void *) arg
));
710 return ec_dev_ioctl(sock
, cmd
, (void *)arg
);
714 return(dev_ioctl(cmd
,(void *) arg
));
720 static struct net_proto_family econet_family_ops
= {
725 static struct proto_ops econet_ops
= {
747 * Find the listening socket, if any, for the given data.
750 static struct sock
*ec_listening_socket(unsigned char port
, unsigned char
751 station
, unsigned char net
)
753 struct sock
*sk
= econet_sklist
;
757 struct econet_opt
*opt
= sk
->protinfo
.af_econet
;
758 if ((opt
->port
== port
|| opt
->port
== 0) &&
759 (opt
->station
== station
|| opt
->station
== 0) &&
760 (opt
->net
== net
|| opt
->net
== 0))
769 #ifdef CONFIG_ECONET_AUNUDP
772 * Send an AUN protocol response.
775 static void aun_send_response(__u32 addr
, unsigned long seq
, int code
, int cb
)
777 struct sockaddr_in sin
;
780 struct msghdr udpmsg
;
784 memset(&sin
, 0, sizeof(sin
));
785 sin
.sin_family
= AF_INET
;
786 sin
.sin_port
= htons(AUN_PORT
);
787 sin
.sin_addr
.s_addr
= addr
;
795 iov
.iov_base
= (void *)&ah
;
796 iov
.iov_len
= sizeof(ah
);
798 udpmsg
.msg_name
= (void *)&sin
;
799 udpmsg
.msg_namelen
= sizeof(sin
);
800 udpmsg
.msg_iov
= &iov
;
801 udpmsg
.msg_iovlen
= 1;
802 udpmsg
.msg_control
= NULL
;
803 udpmsg
.msg_controllen
= 0;
806 oldfs
= get_fs(); set_fs(KERNEL_DS
);
807 err
= sock_sendmsg(udpsock
, &udpmsg
, sizeof(ah
));
812 * Handle incoming AUN packets. Work out if anybody wants them,
813 * and send positive or negative acknowledgements as appropriate.
816 static void aun_incoming(struct sk_buff
*skb
, struct aunhdr
*ah
, size_t len
)
818 struct ec_device
*edev
= edev_get(skb
->dev
);
819 struct iphdr
*ip
= skb
->nh
.iph
;
820 unsigned char stn
= ntohl(ip
->saddr
) & 0xff;
822 struct sk_buff
*newskb
;
824 struct sockaddr_ec
*sec
;
827 return; /* Device not configured for AUN */
829 if ((sk
= ec_listening_socket(ah
->port
, stn
, edev
->net
)) == NULL
)
830 goto bad
; /* Nobody wants it */
832 newskb
= alloc_skb((len
- sizeof(struct aunhdr
) + 15) & ~15,
836 printk(KERN_DEBUG
"AUN: memory squeeze, dropping packet.\n");
837 /* Send nack and hope sender tries again */
841 eb
= (struct ec_cb
*)&newskb
->cb
;
842 sec
= (struct sockaddr_ec
*)&eb
->sec
;
843 memset(sec
, 0, sizeof(struct sockaddr_ec
));
844 sec
->sec_family
= AF_ECONET
;
845 sec
->type
= ECTYPE_PACKET_RECEIVED
;
846 sec
->port
= ah
->port
;
848 sec
->addr
.net
= edev
->net
;
849 sec
->addr
.station
= stn
;
851 memcpy(skb_put(newskb
, len
- sizeof(struct aunhdr
)), (void *)(ah
+1),
852 len
- sizeof(struct aunhdr
));
854 if (sock_queue_rcv_skb(sk
, newskb
) < 0)
856 /* Socket is bankrupt. */
861 aun_send_response(ip
->saddr
, ah
->handle
, 3, 0);
865 aun_send_response(ip
->saddr
, ah
->handle
, 4, 0);
869 * Handle incoming AUN transmit acknowledgements. If the sequence
870 * number matches something in our backlog then kill it and tell
871 * the user. If the remote took too long to reply then we may have
872 * dropped the packet already.
875 static void aun_tx_ack(unsigned long seq
, int result
)
881 spin_lock_irqsave(&aun_queue_lock
, flags
);
882 skb
= skb_peek(&aun_queue
);
883 while (skb
&& skb
!= (struct sk_buff
*)&aun_queue
)
885 struct sk_buff
*newskb
= skb
->next
;
886 eb
= (struct ec_cb
*)&skb
->cb
;
892 spin_unlock_irqrestore(&aun_queue_lock
, flags
);
893 printk(KERN_DEBUG
"AUN: unknown sequence %ld\n", seq
);
897 tx_result(skb
->sk
, eb
->cookie
, result
);
899 spin_unlock_irqrestore(&aun_queue_lock
, flags
);
903 * Deal with received AUN frames - sort out what type of thing it is
904 * and hand it to the right function.
907 static void aun_data_available(struct sock
*sk
, int slen
)
916 while ((skb
= skb_recv_datagram(sk
, 0, 1, &err
)) == NULL
) {
917 if (err
== -EAGAIN
) {
918 printk(KERN_ERR
"AUN: no data available?!");
921 printk(KERN_DEBUG
"AUN: recvfrom() error %d\n", -err
);
924 data
= skb
->h
.raw
+ sizeof(struct udphdr
);
925 ah
= (struct aunhdr
*)data
;
926 len
= skb
->len
- sizeof(struct udphdr
);
932 aun_incoming(skb
, ah
, len
);
935 aun_tx_ack(ah
->handle
, ECTYPE_TRANSMIT_OK
);
938 aun_tx_ack(ah
->handle
, ECTYPE_TRANSMIT_NOT_LISTENING
);
941 /* This isn't quite right yet. */
943 aun_send_response(ip
->saddr
, ah
->handle
, 6, ah
->cb
);
947 printk(KERN_DEBUG
"unknown AUN packet (type %d)\n", data
[0]);
950 skb_free_datagram(sk
, skb
);
954 * Called by the timer to manage the AUN transmit queue. If a packet
955 * was sent to a dead or nonexistent host then we will never get an
956 * acknowledgement back. After a few seconds we need to spot this and
961 static void ab_cleanup(unsigned long h
)
966 spin_lock_irqsave(&aun_queue_lock
, flags
);
967 skb
= skb_peek(&aun_queue
);
968 while (skb
&& skb
!= (struct sk_buff
*)&aun_queue
)
970 struct sk_buff
*newskb
= skb
->next
;
971 struct ec_cb
*eb
= (struct ec_cb
*)&skb
->cb
;
972 if ((jiffies
- eb
->start
) > eb
->timeout
)
974 tx_result(skb
->sk
, eb
->cookie
,
975 ECTYPE_TRANSMIT_NOT_PRESENT
);
980 spin_unlock_irqrestore(&aun_queue_lock
, flags
);
982 mod_timer(&ab_cleanup_timer
, jiffies
+ (HZ
*2));
985 __initfunc(static int aun_udp_initialise(void))
988 struct sockaddr_in sin
;
990 skb_queue_head_init(&aun_queue
);
991 spin_lock_init(&aun_queue_lock
);
992 init_timer(&ab_cleanup_timer
);
993 ab_cleanup_timer
.expires
= jiffies
+ (HZ
*2);
994 ab_cleanup_timer
.function
= ab_cleanup
;
995 add_timer(&ab_cleanup_timer
);
997 memset(&sin
, 0, sizeof(sin
));
998 sin
.sin_port
= htons(AUN_PORT
);
1000 /* We can count ourselves lucky Acorn machines are too dim to
1002 if ((error
= sock_create(PF_INET
, SOCK_DGRAM
, 0, &udpsock
)) < 0)
1004 printk("AUN: socket error %d\n", -error
);
1008 udpsock
->sk
->reuse
= 1;
1009 udpsock
->sk
->allocation
= GFP_ATOMIC
; /* we're going to call it
1012 error
= udpsock
->ops
->bind(udpsock
, (struct sockaddr
*)&sin
,
1016 printk("AUN: bind error %d\n", -error
);
1020 udpsock
->sk
->data_ready
= aun_data_available
;
1025 sock_release(udpsock
);
1031 static int econet_notifier(struct notifier_block
*this, unsigned long msg
, void *data
)
1033 struct device
*dev
= (struct device
*)data
;
1034 struct ec_device
*edev
;
1035 unsigned long flags
;
1038 case NETDEV_UNREGISTER
:
1039 /* A device has gone down - kill any data we hold for it. */
1040 spin_lock_irqsave(&edevlist_lock
, flags
);
1041 for (edev
= edevlist
; edev
; edev
= edev
->next
)
1043 if (edev
->dev
== dev
)
1046 edev
->prev
->next
= edev
->next
;
1048 edevlist
= edev
->next
;
1050 edev
->next
->prev
= edev
->prev
;
1055 spin_unlock_irqrestore(&edevlist_lock
, flags
);
1062 struct notifier_block econet_netdev_notifier
={
1069 void cleanup_module(void)
1071 #ifdef CONFIG_ECONET_AUNUDP
1072 del_timer(&ab_cleanup_timer
);
1074 sock_release(udpsock
);
1076 unregister_netdevice_notifier(&econet_netdev_notifier
);
1077 sock_unregister(econet_family_ops
.family
);
1081 int init_module(void)
1083 __initfunc(void econet_proto_init(struct net_proto
*pro
))
1086 spin_lock_init(&edevlist_lock
);
1087 spin_lock_init(&aun_queue_lock
);
1088 /* Stop warnings from happening on UP systems. */
1089 (void)edevlist_lock
;
1090 (void)aun_queue_lock
;
1091 sock_register(&econet_family_ops
);
1092 #ifdef CONFIG_ECONET_AUNUDP
1093 aun_udp_initialise();
1095 register_netdevice_notifier(&econet_netdev_notifier
);