patch-2.1.18 linux/net/appletalk/ddp.c
Next file: linux/net/ax25/af_ax25.c
Previous file: linux/net/802/psnap.c
Back to the patch index
Back to the overall index
- Lines: 1336
- Date:
Fri Dec 27 12:04:49 1996
- Orig file:
v2.1.17/linux/net/appletalk/ddp.c
- Orig date:
Sun Dec 22 16:37:42 1996
diff -u --recursive --new-file v2.1.17/linux/net/appletalk/ddp.c linux/net/appletalk/ddp.c
@@ -5,8 +5,8 @@
* Alan Cox <Alan.Cox@linux.org>
* <iialan@www.linux.org.uk>
*
- * With more than a little assistance from
- *
+ * With more than a little assistance from
+ *
* Wesley Craig <netatalk@umich.edu>
*
* Fixes:
@@ -33,7 +33,7 @@
* TODO
* ASYNC I/O
*/
-
+
#include <linux/config.h>
#include <linux/module.h>
#include <asm/uaccess.h>
@@ -95,15 +95,15 @@
* handler using this technique. They can be added although we do not
* use this facility.
*/
-
+
static void atalk_remove_socket(struct sock *sk)
{
unsigned long flags;
struct sock *s;
-
+
save_flags(flags);
cli();
-
+
s=atalk_socket_list;
if(s==sk)
{
@@ -138,22 +138,22 @@
{
struct sock *s;
- for( s = atalk_socket_list; s != NULL; s = s->next )
+ for( s = atalk_socket_list; s != NULL; s = s->next )
{
- if ( to->sat_port != s->protinfo.af_at.src_port )
+ if ( to->sat_port != s->protinfo.af_at.src_port )
{
continue;
}
if ( to->sat_addr.s_net == 0 &&
to->sat_addr.s_node == ATADDR_BCAST &&
- s->protinfo.af_at.src_net == atif->address.s_net )
+ s->protinfo.af_at.src_net == atif->address.s_net )
{
break;
}
if ( to->sat_addr.s_net == s->protinfo.af_at.src_net &&
- (to->sat_addr.s_node == s->protinfo.af_at.src_node
+ (to->sat_addr.s_node == s->protinfo.af_at.src_node
||to->sat_addr.s_node == ATADDR_BCAST ))
{
break;
@@ -167,22 +167,22 @@
/*
* Find a socket in the list.
*/
-
+
static struct sock *atalk_find_socket(struct sockaddr_at *sat)
{
struct sock *s;
- for ( s = atalk_socket_list; s != NULL; s = s->next )
+ for ( s = atalk_socket_list; s != NULL; s = s->next )
{
- if ( s->protinfo.af_at.src_net != sat->sat_addr.s_net )
+ if ( s->protinfo.af_at.src_net != sat->sat_addr.s_net )
{
continue;
}
- if ( s->protinfo.af_at.src_node != sat->sat_addr.s_node )
+ if ( s->protinfo.af_at.src_node != sat->sat_addr.s_node )
{
continue;
}
- if ( s->protinfo.af_at.src_port != sat->sat_port )
+ if ( s->protinfo.af_at.src_port != sat->sat_port )
{
continue;
}
@@ -203,7 +203,7 @@
/*
* Handler for deferred kills.
*/
-
+
static void atalk_destroy_timer(unsigned long data)
{
atalk_destroy_socket((struct sock *)data);
@@ -213,12 +213,12 @@
{
struct sk_buff *skb;
atalk_remove_socket(sk);
-
+
while((skb=skb_dequeue(&sk->receive_queue))!=NULL)
{
kfree_skb(skb,FREE_READ);
}
-
+
if(sk->wmem_alloc == 0 && sk->rmem_alloc == 0 && sk->dead)
{
sk_free(sk);
@@ -239,9 +239,9 @@
/*
- * Called from proc fs
+ * Called from proc fs
*/
-
+
int atalk_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
{
struct sock *s;
@@ -267,10 +267,10 @@
s->protinfo.af_at.dest_port);
len += sprintf (buffer+len,"%08X:%08X ", s->wmem_alloc, s->rmem_alloc);
len += sprintf (buffer+len,"%02X %d\n", s->state, SOCK_INODE(s->socket)->i_uid);
-
+
/* Are we still dumping unwanted data then discard the record */
pos=begin+len;
-
+
if(pos<offset)
{
len=0; /* Keep dumping into the buffer start */
@@ -279,13 +279,13 @@
if(pos>offset+length) /* We have dumped enough */
break;
}
-
+
/* The data in question runs from begin to begin+len */
*start=buffer+(offset-begin); /* Start of wanted data */
len-=(offset-begin); /* Remove unwanted header data from length */
if(len>length)
len=length; /* Remove unwanted tail data from length */
-
+
return len;
}
@@ -303,21 +303,21 @@
/*
* Appletalk interface control
*/
-
+
/*
- * Drop a device. Doesn't drop any of its routes - that is the
- * the callers problem. Called when we down the interface or
+ * Drop a device. Doesn't drop any of its routes - that is the
+ * the callers problem. Called when we down the interface or
* delete the address.
*/
-
+
static void atif_drop_device(struct device *dev)
{
struct atalk_iface **iface = &atalk_iface_list;
struct atalk_iface *tmp;
- while ((tmp = *iface) != NULL)
+ while ((tmp = *iface) != NULL)
{
- if (tmp->dev == dev)
+ if (tmp->dev == dev)
{
*iface = tmp->next;
kfree_s(tmp, sizeof(struct atalk_iface));
@@ -331,7 +331,7 @@
{
struct atalk_iface *iface=(struct atalk_iface *)
kmalloc(sizeof(*iface), GFP_KERNEL);
- unsigned long flags;
+ unsigned long flags;
if(iface==NULL)
return NULL;
iface->dev=dev;
@@ -348,7 +348,7 @@
/*
* Perform phase 2 AARP probing on our tentative address.
*/
-
+
static int atif_probe_device(struct atalk_iface *atif)
{
int ct;
@@ -357,19 +357,19 @@
int probe_node=atif->address.s_node;
int netct;
int nodect;
-
+
struct ifreq atreq;
struct sockaddr_at *sa;
int err;
/*
* THIS IS A HACK: Farallon cards want to do their own picking of
- * addresses. This needs tidying up post 1.4, but we need it in
+ * addresses. This needs tidying up post 1.4, but we need it in
* now for the 1.4 release as is.
*
*/
if((atif->dev->type == ARPHRD_LOCALTLK || atif->dev->type == ARPHRD_PPP)
- && atif->dev->do_ioctl)
+ && atif->dev->do_ioctl)
{
/* fake up the request and pass it down */
sa = (struct sockaddr_at*)&atreq.ifr_addr;
@@ -389,11 +389,11 @@
* properly. We can then also dump the localtalk test.
*/
return err;
- }
+ }
/*
* Offset the network we start probing with.
*/
-
+
if(probe_net==ATADDR_ANYNET)
{
if(!netrange)
@@ -401,15 +401,15 @@
else
probe_net=ntohs(atif->nets.nr_firstnet) + (jiffies%netrange);
}
-
+
if(probe_node == ATADDR_ANYNODE)
probe_node = jiffies&0xFF;
-
-
+
+
/*
* Scan the networks.
*/
-
+
for(netct=0;netct<=netrange;netct++)
{
/*
@@ -474,7 +474,7 @@
/*
* Give a device find its atif control structure
*/
-
+
struct atalk_iface *atalk_find_dev(struct device *dev)
{
struct atalk_iface *iface;
@@ -488,15 +488,15 @@
* Find a match for 'any network' - ie any of our interfaces with that
* node number will do just nicely.
*/
-
+
static struct atalk_iface *atalk_find_anynet(int node, struct device *dev)
{
struct atalk_iface *iface;
- for(iface=atalk_iface_list;iface!=NULL;iface=iface->next)
+ for(iface=atalk_iface_list;iface!=NULL;iface=iface->next)
{
if ( iface->dev != dev || ( iface->status & ATIF_PROBE ))
continue;
- if ( node == ATADDR_BCAST || iface->address.s_node == node )
+ if ( node == ATADDR_BCAST || iface->address.s_node == node )
return iface;
}
return NULL;
@@ -505,13 +505,13 @@
/*
* Find a match for a specific network:node pair
*/
-
+
static struct atalk_iface *atalk_find_interface(int net, int node)
{
struct atalk_iface *iface;
for(iface=atalk_iface_list;iface!=NULL;iface=iface->next)
{
- if((node==ATADDR_BCAST || iface->address.s_node==node)
+ if((node==ATADDR_BCAST || iface->address.s_node==node)
&& iface->address.s_net==net && !(iface->status&ATIF_PROBE))
return iface;
}
@@ -524,7 +524,7 @@
* the socket (later on...). We know about host routes and the fact
* that a route must be direct to broadcast.
*/
-
+
static struct atalk_route *atrtr_find(struct at_addr *target)
{
struct atalk_route *r;
@@ -543,12 +543,12 @@
return NULL;
}
-
+
/*
* Given an appletalk network find the device to use. This can be
* a simple lookup. Funny stuff like routers can wait 8)
*/
-
+
static struct device *atrtr_get_dev(struct at_addr *sa)
{
struct atalk_route *atr=atrtr_find(sa);
@@ -561,7 +561,7 @@
/*
* Set up a default router.
*/
-
+
static void atrtr_set_default(struct device *dev)
{
atrtr_default.dev=dev;
@@ -575,7 +575,7 @@
* entry in the list. While it uses netranges we always set them to one
* entry to work like netatalk.
*/
-
+
static int atrtr_create(struct rtentry *r, struct device *devhint)
{
struct sockaddr_at *ta=(struct sockaddr_at *)&r->rt_dst;
@@ -583,22 +583,22 @@
struct atalk_route *rt;
struct atalk_iface *iface, *riface;
unsigned long flags;
-
+
save_flags(flags);
-
+
/*
* Fixme: Raise/Lower a routing change semaphore for these
* operations.
*/
-
+
/*
* Validate the request
- */
+ */
if(ta->sat_family!=AF_APPLETALK)
return -EINVAL;
if(devhint == NULL && ga->sat_family != AF_APPLETALK)
return -EINVAL;
-
+
/*
* Now walk the routing table and make our decisions
*/
@@ -608,7 +608,7 @@
if(r->rt_flags != rt->flags)
continue;
- if(ta->sat_addr.s_net == rt->target.s_net)
+ if(ta->sat_addr.s_net == rt->target.s_net)
{
if(!(rt->flags&RTF_HOST))
break;
@@ -617,9 +617,9 @@
}
}
- if ( devhint == NULL )
+ if ( devhint == NULL )
{
- for ( riface = NULL, iface = atalk_iface_list; iface; iface = iface->next )
+ for ( riface = NULL, iface = atalk_iface_list; iface; iface = iface->next )
{
if ( riface == NULL && ntohs( ga->sat_addr.s_net ) >= ntohs( iface->nets.nr_firstnet ) &&
ntohs( ga->sat_addr.s_net ) <= ntohs( iface->nets.nr_lastnet ))
@@ -647,11 +647,11 @@
/*
* Fill in the entry.
*/
- rt->target=ta->sat_addr;
+ rt->target=ta->sat_addr;
rt->dev=devhint;
rt->flags=r->rt_flags;
rt->gateway=ga->sat_addr;
-
+
restore_flags(flags);
return 0;
}
@@ -660,17 +660,17 @@
/*
* Delete a route. Find it and discard it.
*/
-
+
static int atrtr_delete( struct at_addr *addr )
{
struct atalk_route **r = &atalk_router_list;
struct atalk_route *tmp;
- while ((tmp = *r) != NULL)
+ while ((tmp = *r) != NULL)
{
if (tmp->target.s_net == addr->s_net &&
(!(tmp->flags&RTF_GATEWAY) ||
- tmp->target.s_node == addr->s_node ))
+ tmp->target.s_node == addr->s_node ))
{
*r = tmp->next;
kfree_s(tmp, sizeof(struct atalk_route));
@@ -685,15 +685,15 @@
* Called when a device is downed. Just throw away any routes
* via it.
*/
-
+
void atrtr_device_down(struct device *dev)
{
struct atalk_route **r = &atalk_router_list;
struct atalk_route *tmp;
- while ((tmp = *r) != NULL)
+ while ((tmp = *r) != NULL)
{
- if (tmp->dev == dev)
+ if (tmp->dev == dev)
{
*r = tmp->next;
kfree_s(tmp, sizeof(struct atalk_route));
@@ -728,7 +728,7 @@
/*
* Device configuration ioctl calls.
*/
-
+
int atif_ioctl(int cmd, void *arg)
{
struct ifreq atreq;
@@ -741,17 +741,17 @@
int ct;
int limit;
struct rtentry rtdef;
-
+
err = copy_from_user(&atreq,arg,sizeof(atreq));
if (err)
- return -EFAULT;
+ return -EFAULT;
if((dev=dev_get(atreq.ifr_name))==NULL)
return -ENODEV;
-
+
sa=(struct sockaddr_at*)&atreq.ifr_addr;
atif=atalk_find_dev(dev);
-
+
switch(cmd)
{
case SIOCSIFADDR:
@@ -779,7 +779,7 @@
*/
if(atif->status&ATIF_PROBE)
return -EBUSY;
-
+
atif->address.s_net=sa->sat_addr.s_net;
atif->address.s_node=sa->sat_addr.s_node;
atrtr_device_down(dev); /* Flush old routes */
@@ -791,10 +791,10 @@
atif->nets= *nr;
/*
- * Check if the chosen address is used. If so we
- * error and atalkd will try another.
+ * Check if the chosen address is used. If so we
+ * error and atalkd will try another.
*/
-
+
if(!(dev->flags&IFF_LOOPBACK) && atif_probe_device(atif)<0)
{
atif_drop_device(dev);
@@ -805,7 +805,7 @@
* Hey it worked - add the direct
* routes.
*/
-
+
sa=(struct sockaddr_at *)&rtdef.rt_gateway;
sa->sat_family=AF_APPLETALK;
sa->sat_addr.s_net=atif->address.s_net;
@@ -819,13 +819,13 @@
/*
* Routerless initial state.
*/
- if(nr->nr_firstnet==htons(0) && nr->nr_lastnet==htons(0xFFFE))
+ if(nr->nr_firstnet==htons(0) && nr->nr_lastnet==htons(0xFFFE))
{
sa->sat_addr.s_net=atif->address.s_net;
atrtr_create(&rtdef, dev);
atrtr_set_default(dev);
- }
- else
+ }
+ else
{
limit=ntohs(nr->nr_lastnet);
if(limit-ntohs(nr->nr_firstnet) > 256)
@@ -867,15 +867,15 @@
/*
* Routing ioctl() calls
*/
-
+
static int atrtr_ioctl(unsigned int cmd, void *arg)
{
int err;
struct rtentry rt;
-
+
err = copy_from_user(&rt,arg,sizeof(rt));
if (err)
- return -EFAULT;
+ return -EFAULT;
switch(cmd)
{
@@ -972,15 +972,15 @@
* Checksum: This is 'optional'. It's quite likely also a good
* candidate for assembler hackery 8)
*/
-
+
unsigned short atalk_checksum(struct ddpehdr *ddp, int len)
{
unsigned long sum=0; /* Assume unsigned long is >16 bits */
unsigned char *data=(unsigned char *)ddp;
-
+
len-=4; /* skip header 4 bytes */
- data+=4;
-
+ data+=4;
+
/* This ought to be unwrapped neatly. I'll trust gcc for now */
while(len--)
{
@@ -997,12 +997,12 @@
return htons((unsigned short)sum);
return 0xFFFF; /* Use 0xFFFF for 0. 0 itself means none */
}
-
+
/*
* Generic fcntl calls are already dealt with. If we don't need funny ones
* this is the all you need. Async I/O is also separate.
*/
-
+
static int atalk_fcntl(struct socket *sock, unsigned int cmd, unsigned long arg)
{
/* struct sock *sk=sock->sk;*/
@@ -1014,24 +1014,24 @@
}
/*
- * Set 'magic' options for appletalk. If we don't have any this is fine
+ * Set 'magic' options for appletalk. If we don't have any this is fine
* as it is.
*/
-
+
static int atalk_setsockopt(struct socket *sock, int level, int optname, char *optval, int optlen)
{
struct sock *sk;
int err,opt;
-
+
sk=sock->sk;
-
+
if(optval==NULL)
return(-EINVAL);
err = get_user(opt, (int *)optval);
if (err)
return err;
-
+
switch(level)
{
case SOL_ATALK:
@@ -1041,7 +1041,7 @@
return -EOPNOTSUPP;
}
break;
-
+
default:
return -EOPNOTSUPP;
}
@@ -1051,14 +1051,14 @@
/*
* Get any magic options. Comment above applies.
*/
-
+
static int atalk_getsockopt(struct socket *sock, int level, int optname,
char *optval, int *optlen)
{
struct sock *sk;
int val=0;
int err;
-
+
sk=sock->sk;
switch(level)
@@ -1084,7 +1084,7 @@
/*
* Only for connection oriented sockets - ignore
*/
-
+
static int atalk_listen(struct socket *sock, int backlog)
{
return -EOPNOTSUPP;
@@ -1093,7 +1093,7 @@
/*
* These are standard.
*/
-
+
static void def_callback1(struct sock *sk)
{
if(!sk->dead)
@@ -1113,7 +1113,7 @@
* Create a socket. Initialise the socket, blank the addresses
* set the state.
*/
-
+
static int atalk_create(struct socket *sock, int protocol)
{
struct sock *sk;
@@ -1148,15 +1148,15 @@
sk->state=TCP_CLOSE;
sk->socket=sock;
sk->type=sock->type;
-
+
sk->mtu=DDP_MAXSZ;
-
+
if(sock!=NULL)
{
sk->sleep=&sock->wait;
sock->sk=sk;
}
-
+
sk->state_change=def_callback1;
sk->data_ready=def_callback2;
sk->write_space=def_callback1;
@@ -1169,7 +1169,7 @@
/*
* Copy a socket. No work needed.
*/
-
+
static int atalk_dup(struct socket *newsock,struct socket *oldsock)
{
return(atalk_create(newsock,SOCK_DGRAM));
@@ -1178,7 +1178,7 @@
/*
* Free a socket. No work needed
*/
-
+
static int atalk_release(struct socket *sock, struct socket *peer)
{
struct sock *sk=sock->sk;
@@ -1191,12 +1191,12 @@
atalk_destroy_socket(sk);
return(0);
}
-
+
/*
* Pick a source address if one is not given. Just return
* an error if not supportable.
*/
-
+
static int atalk_pick_port(struct sockaddr_at *sat)
{
for ( sat->sat_port = ATPORT_RESERVED; sat->sat_port < ATPORT_LAST; sat->sat_port++ )
@@ -1206,7 +1206,7 @@
}
return -EBUSY;
}
-
+
static int atalk_autobind(struct sock *sk)
{
struct at_addr *ap = atalk_find_primary();
@@ -1229,17 +1229,17 @@
/*
* Set the address 'our end' of the connection.
*/
-
+
static int atalk_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sock *sk;
struct sockaddr_at *addr=(struct sockaddr_at *)uaddr;
-
+
sk=sock->sk;
-
+
if(sk->zapped==0)
return(-EINVAL);
-
+
if(addr_len!=sizeof(struct sockaddr_at))
return -EINVAL;
@@ -1255,7 +1255,7 @@
sk->protinfo.af_at.src_node=addr->sat_addr.s_node=ap->s_node;
}
else
- {
+ {
if ( atalk_find_interface( addr->sat_addr.s_net, addr->sat_addr.s_node ) == NULL )
return -EADDRNOTAVAIL;
sk->protinfo.af_at.src_net=addr->sat_addr.s_net;
@@ -1273,7 +1273,7 @@
sk->protinfo.af_at.src_port=addr->sat_port;
if(atalk_find_socket(addr)!=NULL)
- return -EADDRINUSE;
+ return -EADDRINUSE;
atalk_insert_socket(sk);
sk->zapped=0;
@@ -1283,35 +1283,35 @@
/*
* Set the address we talk to.
*/
-
+
static int atalk_connect(struct socket *sock, struct sockaddr *uaddr,
int addr_len, int flags)
{
struct sock *sk=sock->sk;
struct sockaddr_at *addr;
-
- sk->state = TCP_CLOSE;
+
+ sk->state = TCP_CLOSE;
sock->state = SS_UNCONNECTED;
if(addr_len!=sizeof(*addr))
return(-EINVAL);
addr=(struct sockaddr_at *)uaddr;
-
+
if(addr->sat_family!=AF_APPLETALK)
return -EAFNOSUPPORT;
#if 0 /* Netatalk doesn't check this - fix netatalk first!*/
if(addr->sat_addr.s_node==ATADDR_BCAST && !sk->broadcast)
return -EACCES;
-#endif
+#endif
if(sk->zapped)
{
if(atalk_autobind(sk)<0)
return -EBUSY;
- }
-
+ }
+
if(atrtr_get_dev(&addr->sat_addr)==NULL)
return -ENETUNREACH;
-
+
sk->protinfo.af_at.dest_port=addr->sat_port;
sk->protinfo.af_at.dest_net=addr->sat_addr.s_net;
sk->protinfo.af_at.dest_node=addr->sat_addr.s_node;
@@ -1323,7 +1323,7 @@
/*
* Not relevant
*/
-
+
static int atalk_socketpair(struct socket *sock1, struct socket *sock2)
{
return(-EOPNOTSUPP);
@@ -1332,10 +1332,10 @@
/*
* Not relevant
*/
-
+
static int atalk_accept(struct socket *sock, struct socket *newsock, int flags)
{
- if(newsock->sk) {
+ if(newsock->sk) {
sk_free(newsock->sk);
MOD_DEC_USE_COUNT;
}
@@ -1346,22 +1346,22 @@
* Find the name of an appletalk socket. Just copy the right
* fields into the sockaddr.
*/
-
+
static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
int *uaddr_len, int peer)
{
struct sockaddr_at sat;
struct sock *sk;
-
+
sk=sock->sk;
if(sk->zapped)
{
if(atalk_autobind(sk)<0)
return -ENOBUFS;
- }
-
+ }
+
*uaddr_len = sizeof(struct sockaddr_at);
-
+
if(peer)
{
if(sk->state!=TCP_ESTABLISHED)
@@ -1383,11 +1383,11 @@
/*
* Receive a packet (in skb) from device dev. This has come from the SNAP decoder, and on entry
- * skb->h.raw is the DDP header, skb->len is the DDP length. The physical headers have been
+ * skb->h.raw is the DDP header, skb->len is the DDP length. The physical headers have been
* extracted. PPP should probably pass frames marked as for this layer
* [ie ARPHRD_ETHERTALK]
*/
-
+
static int atalk_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
{
struct sock *sock;
@@ -1395,15 +1395,15 @@
struct atalk_iface *atif;
struct sockaddr_at tosat;
int origlen;
-
+
/* Size check */
if(skb->len<sizeof(*ddp))
{
kfree_skb(skb,FREE_READ);
return(0);
}
-
-
+
+
/*
* Fix up the length field [Ok this is horrible but otherwise
* I end up with unions of bit fields and messy bit field order
@@ -1419,9 +1419,9 @@
/*
* Trim buffer in case of stray trailing data
*/
-
+
origlen = skb->len;
-
+
skb_trim(skb,min(skb->len,ddp->deh_len));
/*
@@ -1429,7 +1429,7 @@
* (Otherwise we'll detonate most spectacularly
* in the middle of recvmsg()).
*/
-
+
if(skb->len<sizeof(*ddp))
{
kfree_skb(skb,FREE_READ);
@@ -1438,7 +1438,7 @@
/*
* Any checksums. Note we don't do htons() on this == is assumed to be
- * valid for net byte orders all over the networking code...
+ * valid for net byte orders all over the networking code...
*/
if(ddp->deh_sum && atalk_checksum(ddp, ddp->deh_len)!= ddp->deh_sum)
@@ -1449,15 +1449,15 @@
}
#ifdef CONFIG_FIREWALL
-
+
if(call_in_firewall(AF_APPLETALK, skb->dev, ddp, NULL)!=FW_ACCEPT)
{
kfree_skb(skb, FREE_READ);
return 0;
}
-
-#endif
-
+
+#endif
+
/* Check the packet is aimed at us */
if(ddp->deh_dnet == 0) /* Net 0 is 'this network' */
@@ -1466,24 +1466,24 @@
atif=atalk_find_interface(ddp->deh_dnet,ddp->deh_dnode);
/* Not ours */
- if(atif==NULL)
+ if(atif==NULL)
{
struct atalk_route *rt;
struct at_addr ta;
/* Don't route multicast, etc., packets, or packets
sent to "this network" */
- if (skb->pkt_type != PACKET_HOST || ddp->deh_dnet == 0)
+ if (skb->pkt_type != PACKET_HOST || ddp->deh_dnet == 0)
{
kfree_skb(skb, FREE_READ);
return(0);
}
-
-#ifdef CONFIG_FIREWALL
+
+#ifdef CONFIG_FIREWALL
/*
* Check firewall allows this routing
*/
-
+
if(call_fw_firewall(AF_APPLETALK, skb->dev, ddp, NULL)!=FW_ACCEPT)
{
kfree_skb(skb, FREE_READ);
@@ -1506,7 +1506,7 @@
* Route goes through another gateway, so
* set the target to the gateway instead.
*/
-
+
if(rt->flags&RTF_GATEWAY)
{
ta.s_net = rt->gateway.s_net;
@@ -1514,14 +1514,14 @@
}
/* Fix up skb->len field */
- skb_trim(skb,min(origlen, rt->dev->hard_header_len +
+ skb_trim(skb,min(origlen, rt->dev->hard_header_len +
ddp_dl->header_length + ddp->deh_len));
*((__u16 *)ddp)=ntohs(*((__u16 *)ddp)); /* Mend the byte order */
/*
* Send the buffer onwards
*/
-
+
skb=skb_unshare(skb, GFP_ATOMIC, FREE_READ);
if(skb)
{
@@ -1539,18 +1539,18 @@
tosat.sat_port = ddp->deh_dport;
sock=atalk_search_socket( &tosat, atif );
-
+
if(sock==NULL) /* But not one of our sockets */
{
kfree_skb(skb,FREE_READ);
return(0);
}
-
+
/*
* Queue packet (standard)
*/
-
+
skb->sk = sock;
if(sock_queue_rcv_skb(sock,skb)<0)
@@ -1567,7 +1567,7 @@
* header and append a long one.
*/
-
+
static int ltalk_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
{
struct ddpehdr *ddp;
@@ -1575,49 +1575,49 @@
/*
* Expand any short form frames.
*/
-
+
if(skb->mac.raw[2]==1)
{
/*
* Find our address.
*/
-
+
ap=atalk_find_dev_addr(dev);
if(ap==NULL || skb->len<sizeof(struct ddpshdr))
{
kfree_skb(skb, FREE_READ);
return 0;
}
-
+
/*
* The push leaves us with a ddephdr not an shdr, and
* handily the port bytes in the right place preset.
*/
-
+
skb_push(skb, sizeof(*ddp)-4);
ddp=(struct ddpehdr *)skb->data;
-
+
/*
* Now fill in the long header.
*/
-
+
/*
* These two first. The mac overlays the new source/dest
* network information so we MUST copy these before
* we write the network numbers !
*/
-
+
ddp->deh_dnode=skb->mac.raw[0]; /* From physical header */
ddp->deh_snode=skb->mac.raw[1]; /* From physical header */
-
+
ddp->deh_dnet=ap->s_net; /* Network number */
- ddp->deh_snet=ap->s_net;
+ ddp->deh_snet=ap->s_net;
ddp->deh_sum=0; /* No checksum */
/*
* Not sure about this bit...
*/
ddp->deh_len=skb->len;
- ddp->deh_hops=15; /* Non routable, so force a drop
+ ddp->deh_hops=15; /* Non routable, so force a drop
if we slip up later */
*((__u16 *)ddp)=htons(*((__u16 *)ddp)); /* Mend the byte order */
}
@@ -1639,13 +1639,13 @@
int loopback=0;
int err;
int flags = msg->msg_flags;
-
+
if(flags&~MSG_DONTWAIT)
return -EINVAL;
if(len>587)
return -EMSGSIZE;
-
+
if(usat)
{
if(sk->zapped)
@@ -1671,19 +1671,19 @@
usat->sat_addr.s_node=sk->protinfo.af_at.dest_node;
usat->sat_addr.s_net=sk->protinfo.af_at.dest_net;
}
-
+
/* Build a packet */
-
+
if(sk->debug)
printk("SK %p: Got address.\n",sk);
-
+
size=sizeof(struct ddpehdr)+len+ddp_dl->header_length; /* For headers */
if(usat->sat_addr.s_net!=0 || usat->sat_addr.s_node == ATADDR_ANYNODE)
{
rt=atrtr_find(&usat->sat_addr);
if(rt==NULL)
- return -ENETUNREACH;
+ return -ENETUNREACH;
dev=rt->dev;
}
else
@@ -1699,7 +1699,7 @@
if(sk->debug)
printk("SK %p: Size needed %d, device %s\n", sk, size, dev->name);
-
+
size += dev->hard_header_len;
skb = sock_alloc_send_skb(sk, size, 0, flags&MSG_DONTWAIT, &err);
@@ -1712,10 +1712,10 @@
skb_reserve(skb,dev->hard_header_len);
skb->dev=dev;
-
+
if(sk->debug)
printk("SK %p: Begin build.\n", sk);
-
+
ddp=(struct ddpehdr *)skb_put(skb,sizeof(struct ddpehdr));
ddp->deh_pad=0;
ddp->deh_hops=0;
@@ -1736,34 +1736,34 @@
if(sk->debug)
printk("SK %p: Copy user data (%d bytes).\n", sk, len);
-
+
err = memcpy_fromiovec(skb_put(skb,len),msg->msg_iov,len);
if (err)
{
kfree_skb(skb, FREE_WRITE);
return -EFAULT;
}
-
+
if(sk->no_check==1)
ddp->deh_sum=0;
else
ddp->deh_sum=atalk_checksum(ddp, len+sizeof(*ddp));
-
+
#ifdef CONFIG_FIREWALL
if(call_out_firewall(AF_APPLETALK, skb->dev, ddp, NULL)!=FW_ACCEPT)
{
kfree_skb(skb, FREE_WRITE);
return -EPERM;
- }
-
+ }
+
#endif
-
+
/*
* Loopback broadcast packets to non gateway targets (ie routes
* to group we are in)
*/
-
+
if(ddp->deh_dnode==ATADDR_BCAST)
{
if((!(rt->flags&RTF_GATEWAY))&&(!(dev->flags&IFF_LOOPBACK)))
@@ -1781,7 +1781,7 @@
}
}
- if((dev->flags&IFF_LOOPBACK) || loopback)
+ if((dev->flags&IFF_LOOPBACK) || loopback)
{
if(sk->debug)
printk("SK %p: Loop back.\n", sk);
@@ -1794,7 +1794,7 @@
skb_pull(skb,ddp_dl->header_length);
atalk_rcv(skb,dev,NULL);
}
- else
+ else
{
if(sk->debug)
printk("SK %p: send out.\n", sk);
@@ -1803,7 +1803,7 @@
gsat.sat_addr = rt->gateway;
usat = &gsat;
}
-
+
if(aarp_send_ddp(dev,skb,&usat->sat_addr, NULL)==-1)
kfree_skb(skb, FREE_WRITE);
/* else queued/sent above in the aarp queue */
@@ -1814,7 +1814,7 @@
}
-static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size,
+static int atalk_recvmsg(struct socket *sock, struct msghdr *msg, int size,
int flags, struct scm_cookie *scm)
{
struct sock *sk=sock->sk;
@@ -1850,8 +1850,8 @@
msg->msg_flags|=MSG_TRUNC;
}
er = skb_copy_datagram_iovec(skb,sizeof(*ddp),msg->msg_iov,copied);
- if (er)
- goto out;
+ if (er)
+ goto out;
}
if(sat)
{
@@ -1864,7 +1864,7 @@
out:
skb_free_datagram(sk, skb);
return er ? er : (copied);
-}
+}
static int atalk_shutdown(struct socket *sk,int how)
@@ -1880,7 +1880,7 @@
{
long amount=0;
struct sock *sk=sock->sk;
-
+
switch(cmd)
{
/*
@@ -1917,7 +1917,7 @@
return(atrtr_ioctl(cmd,(void *)arg));
/*
* Interface
- */
+ */
case SIOCGIFADDR:
case SIOCSIFADDR:
case SIOCGIFBRDADDR:
@@ -1960,7 +1960,7 @@
static struct proto_ops atalk_dgram_ops = {
AF_APPLETALK,
-
+
atalk_dup,
atalk_release,
atalk_bind,
@@ -2033,13 +2033,13 @@
(void) sock_register(&atalk_family_ops);
if ((ddp_dl = register_snap_client(ddp_snap_id, atalk_rcv)) == NULL)
printk(KERN_CRIT "Unable to register DDP with SNAP.\n");
-
- ltalk_packet_type.type=htons(ETH_P_LOCALTALK);
+
+ ltalk_packet_type.type=htons(ETH_P_LOCALTALK);
dev_add_pack(<alk_packet_type);
-
+
ppptalk_packet_type.type=htons(ETH_P_PPPTALK);
dev_add_pack(&ppptalk_packet_type);
-
+
register_netdevice_notifier(&ddp_notifier);
aarp_proto_init();
@@ -2047,17 +2047,17 @@
proc_net_register(&proc_appletalk);
proc_net_register(&proc_atalk_route);
proc_net_register(&proc_atalk_iface);
-#endif
+#endif
printk(KERN_INFO "Appletalk 0.18 for Linux NET3.037\n");
}
#ifdef MODULE
+EXPORT_NO_SYMBOLS;
int init_module(void)
{
atalk_proto_init(NULL);
- register_symtab(0);
return 0;
}
@@ -2065,7 +2065,7 @@
* FIX THIS: If there are any routes/devices configured
* for appletalk we must not be unloaded.
*/
-
+
/* Remove all route entries. Interrupts must be off. */
extern inline void free_route_list(void)
{
@@ -2105,7 +2105,7 @@
proc_net_unregister(PROC_NET_ATALK);
proc_net_unregister(PROC_NET_AT_ROUTE);
proc_net_unregister(PROC_NET_ATIF);
-#endif
+#endif
unregister_netdevice_notifier(&ddp_notifier);
dev_remove_pack(<alk_packet_type);
dev_remove_pack(&ppptalk_packet_type);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov