Commit 4ba6122b authored by YOSHIFUJI Hideaki's avatar YOSHIFUJI Hideaki Committed by David S. Miller

[NET] WANROUTER: Fix whitespace errors.

Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ac7bfa62
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
* ============================================================================ * ============================================================================
* Due Credit: * Due Credit:
* Wanpipe socket layer is based on Packet and * Wanpipe socket layer is based on Packet and
* the X25 socket layers. The above sockets were * the X25 socket layers. The above sockets were
* used for the specific use of Sangoma Technologies * used for the specific use of Sangoma Technologies
* API programs. * API programs.
* Packet socket Authors: Ross Biro, Fred N. van Kempen and * Packet socket Authors: Ross Biro, Fred N. van Kempen and
* Alan Cox. * Alan Cox.
* X25 socket Author: Jonathan Naylor. * X25 socket Author: Jonathan Naylor.
* ============================================================================ * ============================================================================
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* Feb 29, 2000 Nenad Corbic o Added support for PVC protocols, such as * Feb 29, 2000 Nenad Corbic o Added support for PVC protocols, such as
* CHDLC, Frame Relay and HDLC API. * CHDLC, Frame Relay and HDLC API.
* Jan 17, 2000 Nenad Corbic o Initial version, based on AF_PACKET socket. * Jan 17, 2000 Nenad Corbic o Initial version, based on AF_PACKET socket.
* X25API support only. * X25API support only.
* *
******************************************************************************/ ******************************************************************************/
...@@ -71,33 +71,33 @@ ...@@ -71,33 +71,33 @@
#define DBG_PRINTK(format, a...) printk(format, ## a) #define DBG_PRINTK(format, a...) printk(format, ## a)
#else #else
#define DBG_PRINTK(format, a...) #define DBG_PRINTK(format, a...)
#endif #endif
/* SECURE SOCKET IMPLEMENTATION /* SECURE SOCKET IMPLEMENTATION
* *
* TRANSMIT: * TRANSMIT:
* *
* When the user sends a packet via send() system call * When the user sends a packet via send() system call
* the wanpipe_sendmsg() function is executed. * the wanpipe_sendmsg() function is executed.
* *
* Each packet is enqueud into sk->sk_write_queue transmit * Each packet is enqueud into sk->sk_write_queue transmit
* queue. When the packet is enqueued, a delayed transmit * queue. When the packet is enqueued, a delayed transmit
* timer is triggerd which acts as a Bottom Half hander. * timer is triggerd which acts as a Bottom Half hander.
* *
* wanpipe_delay_transmit() function (BH), dequeues packets * wanpipe_delay_transmit() function (BH), dequeues packets
* from the sk->sk_write_queue transmit queue and sends it * from the sk->sk_write_queue transmit queue and sends it
* to the deriver via dev->hard_start_xmit(skb, dev) function. * to the deriver via dev->hard_start_xmit(skb, dev) function.
* Note, this function is actual a function pointer of if_send() * Note, this function is actual a function pointer of if_send()
* routine in the wanpipe driver. * routine in the wanpipe driver.
* *
* X25API GUARANTEED DELIVERY: * X25API GUARANTEED DELIVERY:
* *
* In order to provide 100% guaranteed packet delivery, * In order to provide 100% guaranteed packet delivery,
* an atomic 'packet_sent' counter is implemented. Counter * an atomic 'packet_sent' counter is implemented. Counter
* is incremented for each packet enqueued * is incremented for each packet enqueued
* into sk->sk_write_queue. Counter is decremented each * into sk->sk_write_queue. Counter is decremented each
* time wanpipe_delayed_transmit() function successfuly * time wanpipe_delayed_transmit() function successfuly
* passes the packet to the driver. Before each send(), a poll * passes the packet to the driver. Before each send(), a poll
* routine checks the sock resources The maximum value of * routine checks the sock resources The maximum value of
* packet sent counter is 1, thus if one packet is queued, the * packet sent counter is 1, thus if one packet is queued, the
...@@ -110,11 +110,11 @@ ...@@ -110,11 +110,11 @@
* function, wanpipe_rcv() to queue the incoming packets * function, wanpipe_rcv() to queue the incoming packets
* into an AF_WANPIPE socket queue. Based on wanpipe_rcv() * into an AF_WANPIPE socket queue. Based on wanpipe_rcv()
* return code, the driver knows whether the packet was * return code, the driver knows whether the packet was
* successfully queued. If the socket queue is full, * successfully queued. If the socket queue is full,
* protocol flow control is used by the driver, if any, * protocol flow control is used by the driver, if any,
* to slow down the traffic until the sock queue is free. * to slow down the traffic until the sock queue is free.
* *
* Every time a packet arrives into a socket queue the * Every time a packet arrives into a socket queue the
* socket wakes up processes which are waiting to receive * socket wakes up processes which are waiting to receive
* data. * data.
* *
...@@ -122,12 +122,12 @@ ...@@ -122,12 +122,12 @@
* bit which signals the socket to kick the wanpipe driver * bit which signals the socket to kick the wanpipe driver
* bottom half hander when the socket queue is partialy * bottom half hander when the socket queue is partialy
* empty. wanpipe_recvmsg() function performs this action. * empty. wanpipe_recvmsg() function performs this action.
* *
* In case of x25api, packets will never be dropped, since * In case of x25api, packets will never be dropped, since
* flow control is available. * flow control is available.
* *
* In case of streaming protocols like CHDLC, packets will * In case of streaming protocols like CHDLC, packets will
* be dropped but the statistics will be generated. * be dropped but the statistics will be generated.
*/ */
...@@ -170,11 +170,11 @@ struct wanpipe_opt ...@@ -170,11 +170,11 @@ struct wanpipe_opt
struct net_device *dev; /* Bounded device */ struct net_device *dev; /* Bounded device */
unsigned short lcn; /* Binded LCN */ unsigned short lcn; /* Binded LCN */
unsigned char svc; /* 0=pvc, 1=svc */ unsigned char svc; /* 0=pvc, 1=svc */
unsigned char timer; /* flag for delayed transmit*/ unsigned char timer; /* flag for delayed transmit*/
struct timer_list tx_timer; struct timer_list tx_timer;
unsigned poll_cnt; unsigned poll_cnt;
unsigned char force; /* Used to force sock release */ unsigned char force; /* Used to force sock release */
atomic_t packet_sent; atomic_t packet_sent;
}; };
#endif #endif
...@@ -215,8 +215,8 @@ static int check_driver_busy (struct sock *); ...@@ -215,8 +215,8 @@ static int check_driver_busy (struct sock *);
* *
* Wanpipe socket bottom half handler. This function * Wanpipe socket bottom half handler. This function
* is called by the WANPIPE device drivers to queue a * is called by the WANPIPE device drivers to queue a
* incoming packet into the socket receive queue. * incoming packet into the socket receive queue.
* Once the packet is queued, all processes waiting to * Once the packet is queued, all processes waiting to
* read are woken up. * read are woken up.
* *
* During socket bind, this function is bounded into * During socket bind, this function is bounded into
...@@ -245,13 +245,13 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -245,13 +245,13 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev,
if (dev->hard_header_parse) if (dev->hard_header_parse)
sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr); sll->sll_halen = dev->hard_header_parse(skb, sll->sll_addr);
/* /*
* WAN_PACKET_DATA : Data which should be passed up the receive queue. * WAN_PACKET_DATA : Data which should be passed up the receive queue.
* WAN_PACKET_ASYC : Asynchronous data like place call, which should * WAN_PACKET_ASYC : Asynchronous data like place call, which should
* be passed up the listening sock. * be passed up the listening sock.
* WAN_PACKET_ERR : Asynchronous data like clear call or restart * WAN_PACKET_ERR : Asynchronous data like clear call or restart
* which should go into an error queue. * which should go into an error queue.
*/ */
switch (skb->pkt_type){ switch (skb->pkt_type){
case WAN_PACKET_DATA: case WAN_PACKET_DATA:
...@@ -261,10 +261,10 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -261,10 +261,10 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev,
break; break;
case WAN_PACKET_CMD: case WAN_PACKET_CMD:
sk->sk_state = chan->state; sk->sk_state = chan->state;
/* Bug fix: update Mar6. /* Bug fix: update Mar6.
* Do not set the sock lcn number here, since * Do not set the sock lcn number here, since
* cmd is not guaranteed to be executed on the * cmd is not guaranteed to be executed on the
* board, thus Lcn could be wrong */ * board, thus Lcn could be wrong */
sk->sk_data_ready(sk, skb->len); sk->sk_data_ready(sk, skb->len);
kfree_skb(skb); kfree_skb(skb);
break; break;
...@@ -276,7 +276,7 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -276,7 +276,7 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev,
break; break;
default: default:
printk(KERN_INFO "wansock: BH Illegal Packet Type Dropping\n"); printk(KERN_INFO "wansock: BH Illegal Packet Type Dropping\n");
kfree_skb(skb); kfree_skb(skb);
break; break;
} }
...@@ -297,20 +297,20 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -297,20 +297,20 @@ static int wanpipe_rcv(struct sk_buff *skb, struct net_device *dev,
* *
* Wanpipe LISTEN socket bottom half handler. This function * Wanpipe LISTEN socket bottom half handler. This function
* is called by the WANPIPE device drivers to queue an * is called by the WANPIPE device drivers to queue an
* incoming call into the socket listening queue. * incoming call into the socket listening queue.
* Once the packet is queued, the waiting accept() process * Once the packet is queued, the waiting accept() process
* is woken up. * is woken up.
* *
* During socket bind, this function is bounded into * During socket bind, this function is bounded into
* WANPIPE driver private. * WANPIPE driver private.
* *
* IMPORTANT NOTE: * IMPORTANT NOTE:
* The accept call() is waiting for an skb packet * The accept call() is waiting for an skb packet
* which contains a pointer to a device structure. * which contains a pointer to a device structure.
* *
* When we do a bind to a device structre, we * When we do a bind to a device structre, we
* bind a newly created socket into "chan->sk". Thus, * bind a newly created socket into "chan->sk". Thus,
* when accept receives the skb packet, it will know * when accept receives the skb packet, it will know
* from which dev it came form, and in turn it will know * from which dev it came form, and in turn it will know
* the address of the new sock. * the address of the new sock.
* *
...@@ -322,31 +322,31 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk) ...@@ -322,31 +322,31 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk)
wanpipe_opt *wp = wp_sk(sk), *newwp; wanpipe_opt *wp = wp_sk(sk), *newwp;
struct wan_sockaddr_ll *sll = (struct wan_sockaddr_ll*)skb->cb; struct wan_sockaddr_ll *sll = (struct wan_sockaddr_ll*)skb->cb;
struct sock *newsk; struct sock *newsk;
struct net_device *dev; struct net_device *dev;
sdla_t *card; sdla_t *card;
mbox_cmd_t *mbox_ptr; mbox_cmd_t *mbox_ptr;
wanpipe_common_t *chan; wanpipe_common_t *chan;
/* Find a free device, if none found, all svc's are busy /* Find a free device, if none found, all svc's are busy
*/ */
card = (sdla_t*)wp->card; card = (sdla_t*)wp->card;
if (!card){ if (!card){
printk(KERN_INFO "wansock: LISTEN ERROR, No Card\n"); printk(KERN_INFO "wansock: LISTEN ERROR, No Card\n");
return -ENODEV; return -ENODEV;
} }
dev = wanpipe_find_free_dev(card); dev = wanpipe_find_free_dev(card);
if (!dev){ if (!dev){
printk(KERN_INFO "wansock: LISTEN ERROR, No Free Device\n"); printk(KERN_INFO "wansock: LISTEN ERROR, No Free Device\n");
return -ENODEV; return -ENODEV;
} }
chan=dev->priv; chan=dev->priv;
chan->state = WANSOCK_CONNECTING; chan->state = WANSOCK_CONNECTING;
/* Allocate a new sock, which accept will bind /* Allocate a new sock, which accept will bind
* and pass up to the user * and pass up to the user
*/ */
if ((newsk = wanpipe_make_new(sk)) == NULL){ if ((newsk = wanpipe_make_new(sk)) == NULL){
release_device(dev); release_device(dev);
...@@ -354,33 +354,33 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk) ...@@ -354,33 +354,33 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk)
} }
/* Initialize the new sock structure /* Initialize the new sock structure
*/ */
newsk->sk_bound_dev_if = dev->ifindex; newsk->sk_bound_dev_if = dev->ifindex;
newwp = wp_sk(newsk); newwp = wp_sk(newsk);
newwp->card = wp->card; newwp->card = wp->card;
/* Insert the sock into the main wanpipe /* Insert the sock into the main wanpipe
* sock list. * sock list.
*/ */
atomic_inc(&wanpipe_socks_nr); atomic_inc(&wanpipe_socks_nr);
/* Allocate and fill in the new Mail Box. Then /* Allocate and fill in the new Mail Box. Then
* bind the mail box to the sock. It will be * bind the mail box to the sock. It will be
* used by the ioctl call to read call information * used by the ioctl call to read call information
* and to execute commands. * and to execute commands.
*/ */
if ((mbox_ptr = kzalloc(sizeof(mbox_cmd_t), GFP_ATOMIC)) == NULL) { if ((mbox_ptr = kzalloc(sizeof(mbox_cmd_t), GFP_ATOMIC)) == NULL) {
wanpipe_kill_sock_irq (newsk); wanpipe_kill_sock_irq (newsk);
release_device(dev); release_device(dev);
return -ENOMEM; return -ENOMEM;
} }
memcpy(mbox_ptr,skb->data,skb->len); memcpy(mbox_ptr,skb->data,skb->len);
/* Register the lcn on which incoming call came /* Register the lcn on which incoming call came
* from. Thus, if we have to clear it, we know * from. Thus, if we have to clear it, we know
* which lcn to clear * which lcn to clear
*/ */
newwp->lcn = mbox_ptr->cmd.lcn; newwp->lcn = mbox_ptr->cmd.lcn;
newwp->mbox = (void *)mbox_ptr; newwp->mbox = (void *)mbox_ptr;
...@@ -416,20 +416,20 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk) ...@@ -416,20 +416,20 @@ static int wanpipe_listen_rcv (struct sk_buff *skb, struct sock *sk)
/* We must do this manually, since the sock_queue_rcv_skb() /* We must do this manually, since the sock_queue_rcv_skb()
* function sets the skb->dev to NULL. However, we use * function sets the skb->dev to NULL. However, we use
* the dev field in the accept function.*/ * the dev field in the accept function.*/
if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
(unsigned)sk->sk_rcvbuf) { (unsigned)sk->sk_rcvbuf) {
wanpipe_unlink_driver(newsk); wanpipe_unlink_driver(newsk);
wanpipe_kill_sock_irq (newsk); wanpipe_kill_sock_irq (newsk);
--sk->sk_ack_backlog; --sk->sk_ack_backlog;
return -ENOMEM; return -ENOMEM;
} }
skb_set_owner_r(skb, sk); skb_set_owner_r(skb, sk);
skb_queue_tail(&sk->sk_receive_queue, skb); skb_queue_tail(&sk->sk_receive_queue, skb);
sk->sk_data_ready(sk, skb->len); sk->sk_data_ready(sk, skb->len);
return 0; return 0;
} }
...@@ -474,7 +474,7 @@ static struct sock *wanpipe_make_new(struct sock *osk) ...@@ -474,7 +474,7 @@ static struct sock *wanpipe_make_new(struct sock *osk)
return sk; return sk;
} }
/* /*
* FIXME: wanpipe_opt has to include a sock in its definition and stop using * FIXME: wanpipe_opt has to include a sock in its definition and stop using
* sk_protinfo, but this code is not even compilable now, so lets leave it for * sk_protinfo, but this code is not even compilable now, so lets leave it for
* later. * later.
...@@ -489,12 +489,12 @@ static struct proto wanpipe_proto = { ...@@ -489,12 +489,12 @@ static struct proto wanpipe_proto = {
* wanpipe_make_new * wanpipe_make_new
* *
* Allocate memory for the a new sock, and sock * Allocate memory for the a new sock, and sock
* private data. * private data.
* *
* Increment the module use count. * Increment the module use count.
* *
* This function is used by wanpipe_create() and * This function is used by wanpipe_create() and
* wanpipe_make_new() functions. * wanpipe_make_new() functions.
* *
*===========================================================*/ *===========================================================*/
...@@ -514,7 +514,7 @@ static struct sock *wanpipe_alloc_socket(void) ...@@ -514,7 +514,7 @@ static struct sock *wanpipe_alloc_socket(void)
wp_sk(sk) = wan_opt; wp_sk(sk) = wan_opt;
/* Use timer to send data to the driver. This will act /* Use timer to send data to the driver. This will act
* as a BH handler for sendmsg functions */ * as a BH handler for sendmsg functions */
init_timer(&wan_opt->tx_timer); init_timer(&wan_opt->tx_timer);
wan_opt->tx_timer.data = (unsigned long)sk; wan_opt->tx_timer.data = (unsigned long)sk;
wan_opt->tx_timer.function = wanpipe_delayed_transmit; wan_opt->tx_timer.function = wanpipe_delayed_transmit;
...@@ -528,14 +528,14 @@ static struct sock *wanpipe_alloc_socket(void) ...@@ -528,14 +528,14 @@ static struct sock *wanpipe_alloc_socket(void)
* wanpipe_sendmsg * wanpipe_sendmsg
* *
* This function implements a sendto() system call, * This function implements a sendto() system call,
* for AF_WANPIPE socket family. * for AF_WANPIPE socket family.
* During socket bind() sk->sk_bound_dev_if is initialized * During socket bind() sk->sk_bound_dev_if is initialized
* to a correct network device. This number is used * to a correct network device. This number is used
* to find a network device to which the packet should * to find a network device to which the packet should
* be passed to. * be passed to.
* *
* Each packet is queued into sk->sk_write_queue and * Each packet is queued into sk->sk_write_queue and
* delayed transmit bottom half handler is marked for * delayed transmit bottom half handler is marked for
* execution. * execution.
* *
* A socket must be in WANSOCK_CONNECTED state before * A socket must be in WANSOCK_CONNECTED state before
...@@ -554,18 +554,18 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -554,18 +554,18 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
unsigned char *addr; unsigned char *addr;
int ifindex, err, reserve = 0; int ifindex, err, reserve = 0;
if (!sock_flag(sk, SOCK_ZAPPED)) if (!sock_flag(sk, SOCK_ZAPPED))
return -ENETDOWN; return -ENETDOWN;
if (sk->sk_state != WANSOCK_CONNECTED) if (sk->sk_state != WANSOCK_CONNECTED)
return -ENOTCONN; return -ENOTCONN;
if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT))
return(-EINVAL); return(-EINVAL);
/* it was <=, now one can send /* it was <=, now one can send
* zero length packets */ * zero length packets */
if (len < sizeof(x25api_hdr_t)) if (len < sizeof(x25api_hdr_t))
return -EINVAL; return -EINVAL;
...@@ -577,7 +577,7 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -577,7 +577,7 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
addr = NULL; addr = NULL;
}else{ }else{
if (msg->msg_namelen < sizeof(struct wan_sockaddr_ll)){ if (msg->msg_namelen < sizeof(struct wan_sockaddr_ll)){
return -EINVAL; return -EINVAL;
} }
...@@ -592,12 +592,12 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -592,12 +592,12 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
return -ENXIO; return -ENXIO;
} }
dev_put(dev); dev_put(dev);
if (sock->type == SOCK_RAW) if (sock->type == SOCK_RAW)
reserve = dev->hard_header_len; reserve = dev->hard_header_len;
if (len > dev->mtu+reserve){ if (len > dev->mtu+reserve){
return -EMSGSIZE; return -EMSGSIZE;
} }
skb = sock_alloc_send_skb(sk, len + LL_RESERVED_SPACE(dev), skb = sock_alloc_send_skb(sk, len + LL_RESERVED_SPACE(dev),
...@@ -606,7 +606,7 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -606,7 +606,7 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
if (skb==NULL){ if (skb==NULL){
goto out_unlock; goto out_unlock;
} }
skb_reserve(skb, LL_RESERVED_SPACE(dev)); skb_reserve(skb, LL_RESERVED_SPACE(dev));
skb->nh.raw = skb->data; skb->nh.raw = skb->data;
...@@ -645,7 +645,7 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -645,7 +645,7 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
if (!(test_and_set_bit(0, &wp->timer))) if (!(test_and_set_bit(0, &wp->timer)))
mod_timer(&wp->tx_timer, jiffies + 1); mod_timer(&wp->tx_timer, jiffies + 1);
return(len); return(len);
out_free: out_free:
...@@ -658,12 +658,12 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -658,12 +658,12 @@ static int wanpipe_sendmsg(struct kiocb *iocb, struct socket *sock,
* wanpipe_delayed_tarnsmit * wanpipe_delayed_tarnsmit
* *
* Transmit bottom half handler. It dequeues packets * Transmit bottom half handler. It dequeues packets
* from sk->sk_write_queue and passes them to the * from sk->sk_write_queue and passes them to the
* driver. If the driver is busy, the packet is * driver. If the driver is busy, the packet is
* re-enqueued. * re-enqueued.
* *
* Packet Sent counter is decremented on successful * Packet Sent counter is decremented on successful
* transmission. * transmission.
*===========================================================*/ *===========================================================*/
...@@ -680,17 +680,17 @@ static void wanpipe_delayed_transmit (unsigned long data) ...@@ -680,17 +680,17 @@ static void wanpipe_delayed_transmit (unsigned long data)
DBG_PRINTK(KERN_INFO "wansock: Transmit delay, no dev or card\n"); DBG_PRINTK(KERN_INFO "wansock: Transmit delay, no dev or card\n");
return; return;
} }
if (sk->sk_state != WANSOCK_CONNECTED || !sock_flag(sk, SOCK_ZAPPED)) { if (sk->sk_state != WANSOCK_CONNECTED || !sock_flag(sk, SOCK_ZAPPED)) {
clear_bit(0, &wp->timer); clear_bit(0, &wp->timer);
DBG_PRINTK(KERN_INFO "wansock: Tx Timer, State not CONNECTED\n"); DBG_PRINTK(KERN_INFO "wansock: Tx Timer, State not CONNECTED\n");
return; return;
} }
/* If driver is executing command, we must offload /* If driver is executing command, we must offload
* the board by not sending data. Otherwise a * the board by not sending data. Otherwise a
* pending command will never get a free buffer * pending command will never get a free buffer
* to execute */ * to execute */
if (atomic_read(&card->u.x.command_busy)){ if (atomic_read(&card->u.x.command_busy)){
wp->tx_timer.expires = jiffies + SLOW_BACKOFF; wp->tx_timer.expires = jiffies + SLOW_BACKOFF;
add_timer(&wp->tx_timer); add_timer(&wp->tx_timer);
...@@ -698,30 +698,30 @@ static void wanpipe_delayed_transmit (unsigned long data) ...@@ -698,30 +698,30 @@ static void wanpipe_delayed_transmit (unsigned long data)
return; return;
} }
if (test_and_set_bit(0,&wanpipe_tx_critical)){ if (test_and_set_bit(0,&wanpipe_tx_critical)){
printk(KERN_INFO "WanSock: Tx timer critical %s\n",dev->name); printk(KERN_INFO "WanSock: Tx timer critical %s\n",dev->name);
wp->tx_timer.expires = jiffies + SLOW_BACKOFF; wp->tx_timer.expires = jiffies + SLOW_BACKOFF;
add_timer(&wp->tx_timer); add_timer(&wp->tx_timer);
return; return;
} }
/* Check for a packet in the fifo and send */ /* Check for a packet in the fifo and send */
if ((skb = skb_dequeue(&sk->sk_write_queue)) != NULL){ if ((skb = skb_dequeue(&sk->sk_write_queue)) != NULL){
if (dev->hard_start_xmit(skb, dev) != 0){ if (dev->hard_start_xmit(skb, dev) != 0){
/* Driver failed to transmit, re-enqueue /* Driver failed to transmit, re-enqueue
* the packet and retry again later */ * the packet and retry again later */
skb_queue_head(&sk->sk_write_queue,skb); skb_queue_head(&sk->sk_write_queue,skb);
clear_bit(0,&wanpipe_tx_critical); clear_bit(0,&wanpipe_tx_critical);
return; return;
}else{ }else{
/* Packet Sent successful. Check for more packets /* Packet Sent successful. Check for more packets
* if more packets, re-trigger the transmit routine * if more packets, re-trigger the transmit routine
* other wise exit * other wise exit
*/ */
atomic_dec(&wp->packet_sent); atomic_dec(&wp->packet_sent);
if (skb_peek(&sk->sk_write_queue) == NULL) { if (skb_peek(&sk->sk_write_queue) == NULL) {
...@@ -741,18 +741,18 @@ static void wanpipe_delayed_transmit (unsigned long data) ...@@ -741,18 +741,18 @@ static void wanpipe_delayed_transmit (unsigned long data)
} }
/*============================================================ /*============================================================
* execute_command * execute_command
* *
* Execute x25api commands. The atomic variable * Execute x25api commands. The atomic variable
* chan->command is used to indicate to the driver that * chan->command is used to indicate to the driver that
* command is pending for execution. The acutal command * command is pending for execution. The acutal command
* structure is placed into a sock mbox structure * structure is placed into a sock mbox structure
* (wp_sk(sk)->mbox). * (wp_sk(sk)->mbox).
* *
* The sock private structure, mbox is * The sock private structure, mbox is
* used as shared memory between sock and the driver. * used as shared memory between sock and the driver.
* Driver uses the sock mbox to execute the command * Driver uses the sock mbox to execute the command
* and return the result. * and return the result.
* *
* For all command except PLACE CALL, the function * For all command except PLACE CALL, the function
* waits for the result. PLACE CALL can be ether * waits for the result. PLACE CALL can be ether
...@@ -768,7 +768,7 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int fla ...@@ -768,7 +768,7 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int fla
wanpipe_common_t *chan=NULL; wanpipe_common_t *chan=NULL;
int err=0; int err=0;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
dev = dev_get_by_index(sk->sk_bound_dev_if); dev = dev_get_by_index(sk->sk_bound_dev_if);
if (dev == NULL){ if (dev == NULL){
printk(KERN_INFO "wansock: Exec failed no dev %i\n", printk(KERN_INFO "wansock: Exec failed no dev %i\n",
...@@ -793,7 +793,7 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int fla ...@@ -793,7 +793,7 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int fla
return -EINVAL; return -EINVAL;
} }
((mbox_cmd_t*)wp->mbox)->cmd.command = cmd; ((mbox_cmd_t*)wp->mbox)->cmd.command = cmd;
((mbox_cmd_t*)wp->mbox)->cmd.lcn = wp->lcn; ((mbox_cmd_t*)wp->mbox)->cmd.lcn = wp->lcn;
((mbox_cmd_t*)wp->mbox)->cmd.result = 0x7F; ((mbox_cmd_t*)wp->mbox)->cmd.result = 0x7F;
...@@ -820,12 +820,12 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int fla ...@@ -820,12 +820,12 @@ static int execute_command(struct sock *sk, unsigned char cmd, unsigned int fla
} }
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(sk->sk_sleep,&wait); remove_wait_queue(sk->sk_sleep,&wait);
return err; return err;
} }
/*============================================================ /*============================================================
* wanpipe_destroy_timer * wanpipe_destroy_timer
* *
* Used by wanpipe_release, to delay release of * Used by wanpipe_release, to delay release of
* the socket. * the socket.
...@@ -846,7 +846,7 @@ static void wanpipe_destroy_timer(unsigned long data) ...@@ -846,7 +846,7 @@ static void wanpipe_destroy_timer(unsigned long data)
kfree(wp); kfree(wp);
wp_sk(sk) = NULL; wp_sk(sk) = NULL;
if (atomic_read(&sk->sk_refcnt) != 1) { if (atomic_read(&sk->sk_refcnt) != 1) {
atomic_set(&sk->sk_refcnt, 1); atomic_set(&sk->sk_refcnt, 1);
DBG_PRINTK(KERN_INFO "wansock: Error, wrong reference count: %i ! :delay.\n", DBG_PRINTK(KERN_INFO "wansock: Error, wrong reference count: %i ! :delay.\n",
...@@ -865,9 +865,9 @@ static void wanpipe_destroy_timer(unsigned long data) ...@@ -865,9 +865,9 @@ static void wanpipe_destroy_timer(unsigned long data)
/*============================================================ /*============================================================
* wanpipe_unlink_driver * wanpipe_unlink_driver
* *
* When the socket is released, this function is * When the socket is released, this function is
* used to remove links that bind the sock and the * used to remove links that bind the sock and the
* driver together. * driver together.
*===========================================================*/ *===========================================================*/
static void wanpipe_unlink_driver (struct sock *sk) static void wanpipe_unlink_driver (struct sock *sk)
{ {
...@@ -882,7 +882,7 @@ static void wanpipe_unlink_driver (struct sock *sk) ...@@ -882,7 +882,7 @@ static void wanpipe_unlink_driver (struct sock *sk)
if (!dev){ if (!dev){
printk(KERN_INFO "wansock: No dev on release\n"); printk(KERN_INFO "wansock: No dev on release\n");
return; return;
} }
dev_put(dev); dev_put(dev);
if ((chan = dev->priv) == NULL){ if ((chan = dev->priv) == NULL){
...@@ -897,7 +897,7 @@ static void wanpipe_unlink_driver (struct sock *sk) ...@@ -897,7 +897,7 @@ static void wanpipe_unlink_driver (struct sock *sk)
chan->tx_timer=NULL; chan->tx_timer=NULL;
clear_bit(0,&chan->common_critical); clear_bit(0,&chan->common_critical);
release_device(dev); release_device(dev);
return; return;
} }
...@@ -931,7 +931,7 @@ static void wanpipe_link_driver(struct net_device *dev, struct sock *sk) ...@@ -931,7 +931,7 @@ static void wanpipe_link_driver(struct net_device *dev, struct sock *sk)
/*============================================================ /*============================================================
* release_device * release_device
* *
* During sock release, clear a critical bit, which * During sock release, clear a critical bit, which
* marks the device a being taken. * marks the device a being taken.
*===========================================================*/ *===========================================================*/
...@@ -945,8 +945,8 @@ static void release_device(struct net_device *dev) ...@@ -945,8 +945,8 @@ static void release_device(struct net_device *dev)
/*============================================================ /*============================================================
* wanpipe_release * wanpipe_release
* *
* Close a PACKET socket. This is fairly simple. We * Close a PACKET socket. This is fairly simple. We
* immediately go to 'closed' state and remove our * immediately go to 'closed' state and remove our
* protocol entry in the device list. * protocol entry in the device list.
*===========================================================*/ *===========================================================*/
...@@ -954,7 +954,7 @@ static int wanpipe_release(struct socket *sock) ...@@ -954,7 +954,7 @@ static int wanpipe_release(struct socket *sock)
{ {
wanpipe_opt *wp; wanpipe_opt *wp;
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
if (!sk) if (!sk)
return 0; return 0;
...@@ -962,9 +962,9 @@ static int wanpipe_release(struct socket *sock) ...@@ -962,9 +962,9 @@ static int wanpipe_release(struct socket *sock)
check_write_queue(sk); check_write_queue(sk);
/* Kill the tx timer, if we don't kill it now, the timer /* Kill the tx timer, if we don't kill it now, the timer
* will run after we kill the sock. Timer code will * will run after we kill the sock. Timer code will
* try to access the sock which has been killed and cause * try to access the sock which has been killed and cause
* kernel panic */ * kernel panic */
del_timer(&wp->tx_timer); del_timer(&wp->tx_timer);
...@@ -982,7 +982,7 @@ static int wanpipe_release(struct socket *sock) ...@@ -982,7 +982,7 @@ static int wanpipe_release(struct socket *sock)
DBG_PRINTK(KERN_INFO "wansock: Sending Clear Indication %i\n", DBG_PRINTK(KERN_INFO "wansock: Sending Clear Indication %i\n",
sk->sk_state); sk->sk_state);
dev_put(dev); dev_put(dev);
} }
} }
set_bit(1,&wanpipe_tx_critical); set_bit(1,&wanpipe_tx_critical);
...@@ -992,10 +992,10 @@ static int wanpipe_release(struct socket *sock) ...@@ -992,10 +992,10 @@ static int wanpipe_release(struct socket *sock)
clear_bit(1,&wanpipe_tx_critical); clear_bit(1,&wanpipe_tx_critical);
release_driver(sk); release_driver(sk);
/* /*
* Now the socket is dead. No more input will appear. * Now the socket is dead. No more input will appear.
*/ */
...@@ -1040,9 +1040,9 @@ static int wanpipe_release(struct socket *sock) ...@@ -1040,9 +1040,9 @@ static int wanpipe_release(struct socket *sock)
/*============================================================ /*============================================================
* check_write_queue * check_write_queue
* *
* During sock shutdown, if the sock state is * During sock shutdown, if the sock state is
* WANSOCK_CONNECTED and there is transmit data * WANSOCK_CONNECTED and there is transmit data
* pending. Wait until data is released * pending. Wait until data is released
* before proceeding. * before proceeding.
*===========================================================*/ *===========================================================*/
...@@ -1062,7 +1062,7 @@ static void check_write_queue(struct sock *sk) ...@@ -1062,7 +1062,7 @@ static void check_write_queue(struct sock *sk)
/*============================================================ /*============================================================
* release_driver * release_driver
* *
* This function is called during sock shutdown, to * This function is called during sock shutdown, to
* release any resources and links that bind the sock * release any resources and links that bind the sock
* to the driver. It also changes the state of the * to the driver. It also changes the state of the
* sock to WANSOCK_DISCONNECTED * sock to WANSOCK_DISCONNECTED
...@@ -1105,7 +1105,7 @@ static void release_driver(struct sock *sk) ...@@ -1105,7 +1105,7 @@ static void release_driver(struct sock *sk)
* start_cleanup_timer * start_cleanup_timer
* *
* If new incoming call's are pending but the socket * If new incoming call's are pending but the socket
* is being released, start the timer which will * is being released, start the timer which will
* envoke the kill routines for pending socks. * envoke the kill routines for pending socks.
*===========================================================*/ *===========================================================*/
...@@ -1125,7 +1125,7 @@ static void start_cleanup_timer (struct sock *sk) ...@@ -1125,7 +1125,7 @@ static void start_cleanup_timer (struct sock *sk)
* *
* This is a function which performs actual killing * This is a function which performs actual killing
* of the sock. It releases socket resources, * of the sock. It releases socket resources,
* and unlinks the sock from the driver. * and unlinks the sock from the driver.
*===========================================================*/ *===========================================================*/
static void wanpipe_kill_sock_timer (unsigned long data) static void wanpipe_kill_sock_timer (unsigned long data)
...@@ -1139,13 +1139,13 @@ static void wanpipe_kill_sock_timer (unsigned long data) ...@@ -1139,13 +1139,13 @@ static void wanpipe_kill_sock_timer (unsigned long data)
/* This function can be called from interrupt. We must use /* This function can be called from interrupt. We must use
* appropriate locks */ * appropriate locks */
if (test_bit(1,&wanpipe_tx_critical)){ if (test_bit(1,&wanpipe_tx_critical)){
sk->sk_timer.expires = jiffies + 10; sk->sk_timer.expires = jiffies + 10;
add_timer(&sk->sk_timer); add_timer(&sk->sk_timer);
return; return;
} }
write_lock(&wanpipe_sklist_lock); write_lock(&wanpipe_sklist_lock);
sk_del_node_init(sk); sk_del_node_init(sk);
write_unlock(&wanpipe_sklist_lock); write_unlock(&wanpipe_sklist_lock);
...@@ -1159,7 +1159,7 @@ static void wanpipe_kill_sock_timer (unsigned long data) ...@@ -1159,7 +1159,7 @@ static void wanpipe_kill_sock_timer (unsigned long data)
chan=dev->priv; chan=dev->priv;
atomic_set(&chan->disconnect,1); atomic_set(&chan->disconnect,1);
dev_put(dev); dev_put(dev);
} }
} }
release_driver(sk); release_driver(sk);
...@@ -1170,7 +1170,7 @@ static void wanpipe_kill_sock_timer (unsigned long data) ...@@ -1170,7 +1170,7 @@ static void wanpipe_kill_sock_timer (unsigned long data)
skb_queue_purge(&sk->sk_receive_queue); skb_queue_purge(&sk->sk_receive_queue);
skb_queue_purge(&sk->sk_write_queue); skb_queue_purge(&sk->sk_write_queue);
skb_queue_purge(&sk->sk_error_queue); skb_queue_purge(&sk->sk_error_queue);
if (atomic_read(&sk->sk_rmem_alloc) || if (atomic_read(&sk->sk_rmem_alloc) ||
atomic_read(&sk->sk_wmem_alloc)) { atomic_read(&sk->sk_wmem_alloc)) {
del_timer(&sk->sk_timer); del_timer(&sk->sk_timer);
...@@ -1205,7 +1205,7 @@ static void wanpipe_kill_sock_accept (struct sock *sk) ...@@ -1205,7 +1205,7 @@ static void wanpipe_kill_sock_accept (struct sock *sk)
/* This function can be called from interrupt. We must use /* This function can be called from interrupt. We must use
* appropriate locks */ * appropriate locks */
write_lock(&wanpipe_sklist_lock); write_lock(&wanpipe_sklist_lock);
sk_del_node_init(sk); sk_del_node_init(sk);
write_unlock(&wanpipe_sklist_lock); write_unlock(&wanpipe_sklist_lock);
...@@ -1282,10 +1282,10 @@ static int wanpipe_do_bind(struct sock *sk, struct net_device *dev, ...@@ -1282,10 +1282,10 @@ static int wanpipe_do_bind(struct sock *sk, struct net_device *dev,
chan=dev->priv; chan=dev->priv;
sk->sk_state = chan->state; sk->sk_state = chan->state;
if (wp->num == htons(X25_PROT) && if (wp->num == htons(X25_PROT) &&
sk->sk_state != WANSOCK_DISCONNECTED && sk->sk_state != WANSOCK_DISCONNECTED &&
sk->sk_state != WANSOCK_CONNECTING) { sk->sk_state != WANSOCK_CONNECTING) {
DBG_PRINTK(KERN_INFO DBG_PRINTK(KERN_INFO
"wansock: Binding to Device not DISCONNECTED %i\n", "wansock: Binding to Device not DISCONNECTED %i\n",
sk->sk_state); sk->sk_state);
release_device(dev); release_device(dev);
...@@ -1338,7 +1338,7 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le ...@@ -1338,7 +1338,7 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
/* /*
* Check legality * Check legality
*/ */
if (addr_len < sizeof(struct wan_sockaddr_ll)){ if (addr_len < sizeof(struct wan_sockaddr_ll)){
printk(KERN_INFO "wansock: Address length error\n"); printk(KERN_INFO "wansock: Address length error\n");
return -EINVAL; return -EINVAL;
...@@ -1358,12 +1358,12 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le ...@@ -1358,12 +1358,12 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
if (!strcmp(sll->sll_device,"svc_listen")){ if (!strcmp(sll->sll_device,"svc_listen")){
/* Bind a sock to a card structure for listening /* Bind a sock to a card structure for listening
*/ */
int err=0; int err=0;
/* This is x25 specific area if protocol doesn't /* This is x25 specific area if protocol doesn't
* match, return error */ * match, return error */
if (sll->sll_protocol != htons(X25_PROT)) if (sll->sll_protocol != htons(X25_PROT))
return -EINVAL; return -EINVAL;
...@@ -1376,14 +1376,14 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le ...@@ -1376,14 +1376,14 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
sk->sk_state = WANSOCK_BIND_LISTEN; sk->sk_state = WANSOCK_BIND_LISTEN;
return 0; return 0;
}else if (!strcmp(sll->sll_device,"svc_connect")){ }else if (!strcmp(sll->sll_device,"svc_connect")){
/* This is x25 specific area if protocol doesn't /* This is x25 specific area if protocol doesn't
* match, return error */ * match, return error */
if (sll->sll_protocol != htons(X25_PROT)) if (sll->sll_protocol != htons(X25_PROT))
return -EINVAL; return -EINVAL;
/* Find a free device /* Find a free device
*/ */
dev = wanpipe_find_free_dev(card); dev = wanpipe_find_free_dev(card);
if (dev == NULL){ if (dev == NULL){
...@@ -1392,9 +1392,9 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le ...@@ -1392,9 +1392,9 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
return -EINVAL; return -EINVAL;
} }
}else{ }else{
/* Bind a socket to a interface name /* Bind a socket to a interface name
* This is used by PVC mostly * This is used by PVC mostly
*/ */
strlcpy(name,sll->sll_device,sizeof(name)); strlcpy(name,sll->sll_device,sizeof(name));
dev = dev_get_by_name(name); dev = dev_get_by_name(name);
if (dev == NULL){ if (dev == NULL){
...@@ -1419,8 +1419,8 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le ...@@ -1419,8 +1419,8 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
/*============================================================ /*============================================================
* get_atomic_device * get_atomic_device
* *
* Sets a bit atomically which indicates that * Sets a bit atomically which indicates that
* the interface is taken. This avoids race conditions. * the interface is taken. This avoids race conditions.
*===========================================================*/ *===========================================================*/
...@@ -1436,7 +1436,7 @@ static inline int get_atomic_device(struct net_device *dev) ...@@ -1436,7 +1436,7 @@ static inline int get_atomic_device(struct net_device *dev)
/*============================================================ /*============================================================
* check_dev * check_dev
* *
* Check that device name belongs to a particular card. * Check that device name belongs to a particular card.
*===========================================================*/ *===========================================================*/
...@@ -1446,8 +1446,8 @@ static int check_dev(struct net_device *dev, sdla_t *card) ...@@ -1446,8 +1446,8 @@ static int check_dev(struct net_device *dev, sdla_t *card)
for (tmp_dev = card->wandev.dev; tmp_dev; for (tmp_dev = card->wandev.dev; tmp_dev;
tmp_dev = *((struct net_device **)tmp_dev->priv)) { tmp_dev = *((struct net_device **)tmp_dev->priv)) {
if (tmp_dev->ifindex == dev->ifindex){ if (tmp_dev->ifindex == dev->ifindex){
return 0; return 0;
} }
} }
return 1; return 1;
...@@ -1455,7 +1455,7 @@ static int check_dev(struct net_device *dev, sdla_t *card) ...@@ -1455,7 +1455,7 @@ static int check_dev(struct net_device *dev, sdla_t *card)
/*============================================================ /*============================================================
* wanpipe_find_free_dev * wanpipe_find_free_dev
* *
* Find a free network interface. If found set atomic * Find a free network interface. If found set atomic
* bit indicating that the interface is taken. * bit indicating that the interface is taken.
* X25API Specific. * X25API Specific.
...@@ -1468,12 +1468,12 @@ struct net_device *wanpipe_find_free_dev(sdla_t *card) ...@@ -1468,12 +1468,12 @@ struct net_device *wanpipe_find_free_dev(sdla_t *card)
if (test_and_set_bit(0,&find_free_critical)){ if (test_and_set_bit(0,&find_free_critical)){
printk(KERN_INFO "CRITICAL in Find Free\n"); printk(KERN_INFO "CRITICAL in Find Free\n");
} }
for (dev = card->wandev.dev; dev; for (dev = card->wandev.dev; dev;
dev = *((struct net_device **)dev->priv)) { dev = *((struct net_device **)dev->priv)) {
chan = dev->priv; chan = dev->priv;
if (!chan) if (!chan)
continue; continue;
if (chan->usedby == API && chan->svc){ if (chan->usedby == API && chan->svc){
if (!get_atomic_device (dev)){ if (!get_atomic_device (dev)){
...@@ -1492,16 +1492,16 @@ struct net_device *wanpipe_find_free_dev(sdla_t *card) ...@@ -1492,16 +1492,16 @@ struct net_device *wanpipe_find_free_dev(sdla_t *card)
/*============================================================ /*============================================================
* wanpipe_create * wanpipe_create
* *
* SOCKET() System call. It allocates a sock structure * SOCKET() System call. It allocates a sock structure
* and adds the socket to the wanpipe_sk_list. * and adds the socket to the wanpipe_sk_list.
* Crates AF_WANPIPE socket. * Crates AF_WANPIPE socket.
*===========================================================*/ *===========================================================*/
static int wanpipe_create(struct socket *sock, int protocol) static int wanpipe_create(struct socket *sock, int protocol)
{ {
struct sock *sk; struct sock *sk;
//FIXME: This checks for root user, SECURITY ? //FIXME: This checks for root user, SECURITY ?
//if (!capable(CAP_NET_RAW)) //if (!capable(CAP_NET_RAW))
// return -EPERM; // return -EPERM;
...@@ -1526,7 +1526,7 @@ static int wanpipe_create(struct socket *sock, int protocol) ...@@ -1526,7 +1526,7 @@ static int wanpipe_create(struct socket *sock, int protocol)
sk->sk_bound_dev_if = 0; sk->sk_bound_dev_if = 0;
atomic_inc(&wanpipe_socks_nr); atomic_inc(&wanpipe_socks_nr);
/* We must disable interrupts because the ISR /* We must disable interrupts because the ISR
* can also change the list */ * can also change the list */
set_bit(1,&wanpipe_tx_critical); set_bit(1,&wanpipe_tx_critical);
...@@ -1541,8 +1541,8 @@ static int wanpipe_create(struct socket *sock, int protocol) ...@@ -1541,8 +1541,8 @@ static int wanpipe_create(struct socket *sock, int protocol)
/*============================================================ /*============================================================
* wanpipe_recvmsg * wanpipe_recvmsg
* *
* Pull a packet from our receive queue and hand it * Pull a packet from our receive queue and hand it
* to the user. If necessary we block. * to the user. If necessary we block.
*===========================================================*/ *===========================================================*/
...@@ -1570,13 +1570,13 @@ static int wanpipe_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1570,13 +1570,13 @@ static int wanpipe_recvmsg(struct kiocb *iocb, struct socket *sock,
* but then it will block. * but then it will block.
*/ */
if (flags & MSG_OOB){ if (flags & MSG_OOB){
skb = skb_dequeue(&sk->sk_error_queue); skb = skb_dequeue(&sk->sk_error_queue);
}else{ }else{
skb=skb_recv_datagram(sk,flags,1,&err); skb=skb_recv_datagram(sk,flags,1,&err);
} }
/* /*
* An error occurred so return it. Because skb_recv_datagram() * An error occurred so return it. Because skb_recv_datagram()
* handles the blocking we don't see and worry about blocking * handles the blocking we don't see and worry about blocking
* retries. * retries.
*/ */
...@@ -1602,9 +1602,9 @@ static int wanpipe_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1602,9 +1602,9 @@ static int wanpipe_recvmsg(struct kiocb *iocb, struct socket *sock,
err = memcpy_toiovec(msg->msg_iov, skb->data, copied); err = memcpy_toiovec(msg->msg_iov, skb->data, copied);
if (err) if (err)
goto out_free; goto out_free;
sock_recv_timestamp(msg, sk, skb); sock_recv_timestamp(msg, sk, skb);
if (msg->msg_name) if (msg->msg_name)
memcpy(msg->msg_name, skb->cb, msg->msg_namelen); memcpy(msg->msg_name, skb->cb, msg->msg_namelen);
...@@ -1623,13 +1623,13 @@ static int wanpipe_recvmsg(struct kiocb *iocb, struct socket *sock, ...@@ -1623,13 +1623,13 @@ static int wanpipe_recvmsg(struct kiocb *iocb, struct socket *sock,
/*============================================================ /*============================================================
* wanpipe_wakeup_driver * wanpipe_wakeup_driver
* *
* If socket receive buffer is full and driver cannot * If socket receive buffer is full and driver cannot
* pass data up the sock, it sets a packet_block flag. * pass data up the sock, it sets a packet_block flag.
* This function check that flag and if sock receive * This function check that flag and if sock receive
* queue has room it kicks the driver BH handler. * queue has room it kicks the driver BH handler.
* *
* This way, driver doesn't have to poll the sock * This way, driver doesn't have to poll the sock
* receive queue. * receive queue.
*===========================================================*/ *===========================================================*/
...@@ -1646,8 +1646,8 @@ static void wanpipe_wakeup_driver(struct sock *sk) ...@@ -1646,8 +1646,8 @@ static void wanpipe_wakeup_driver(struct sock *sk)
if ((chan = dev->priv) == NULL) if ((chan = dev->priv) == NULL)
return; return;
if (atomic_read(&chan->receive_block)){ if (atomic_read(&chan->receive_block)){
if (atomic_read(&sk->sk_rmem_alloc) < if (atomic_read(&sk->sk_rmem_alloc) <
((unsigned)sk->sk_rcvbuf * 0.9)) { ((unsigned)sk->sk_rcvbuf * 0.9)) {
printk(KERN_INFO "wansock: Queuing task for wanpipe\n"); printk(KERN_INFO "wansock: Queuing task for wanpipe\n");
...@@ -1655,13 +1655,13 @@ static void wanpipe_wakeup_driver(struct sock *sk) ...@@ -1655,13 +1655,13 @@ static void wanpipe_wakeup_driver(struct sock *sk)
wanpipe_queue_tq(&chan->wanpipe_task); wanpipe_queue_tq(&chan->wanpipe_task);
wanpipe_mark_bh(); wanpipe_mark_bh();
} }
} }
} }
/*============================================================ /*============================================================
* wanpipe_getname * wanpipe_getname
* *
* I don't know what to do with this yet. * I don't know what to do with this yet.
* User can use this function to get sock address * User can use this function to get sock address
* information. Not very useful for Sangoma's purposes. * information. Not very useful for Sangoma's purposes.
*===========================================================*/ *===========================================================*/
...@@ -1687,17 +1687,17 @@ static int wanpipe_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -1687,17 +1687,17 @@ static int wanpipe_getname(struct socket *sock, struct sockaddr *uaddr,
sll->sll_halen = 0; sll->sll_halen = 0;
} }
*uaddr_len = sizeof(*sll); *uaddr_len = sizeof(*sll);
dev_put(dev); dev_put(dev);
return 0; return 0;
} }
/*============================================================ /*============================================================
* wanpipe_notifier * wanpipe_notifier
* *
* If driver turns off network interface, this function * If driver turns off network interface, this function
* will be envoked. Currently I treate it as a * will be envoked. Currently I treate it as a
* call disconnect. More thought should go into this * call disconnect. More thought should go into this
* function. * function.
* *
...@@ -1718,7 +1718,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void ...@@ -1718,7 +1718,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void
continue; continue;
if (dev == NULL) if (dev == NULL)
continue; continue;
switch (msg) { switch (msg) {
case NETDEV_DOWN: case NETDEV_DOWN:
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
...@@ -1732,7 +1732,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void ...@@ -1732,7 +1732,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void
if (msg == NETDEV_UNREGISTER) { if (msg == NETDEV_UNREGISTER) {
printk(KERN_INFO "wansock: Unregistering Device: %s\n", printk(KERN_INFO "wansock: Unregistering Device: %s\n",
dev->name); dev->name);
wanpipe_unlink_driver(sk); wanpipe_unlink_driver(sk);
sk->sk_bound_dev_if = 0; sk->sk_bound_dev_if = 0;
} }
...@@ -1753,7 +1753,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void ...@@ -1753,7 +1753,7 @@ static int wanpipe_notifier(struct notifier_block *this, unsigned long msg, void
/*============================================================ /*============================================================
* wanpipe_ioctl * wanpipe_ioctl
* *
* Execute a user commands, and set socket options. * Execute a user commands, and set socket options.
* *
* FIXME: More thought should go into this function. * FIXME: More thought should go into this function.
...@@ -1765,7 +1765,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar ...@@ -1765,7 +1765,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
int err; int err;
switch(cmd) switch(cmd)
{ {
case SIOCGSTAMP: case SIOCGSTAMP:
return sock_get_timestamp(sk, (struct timeval __user *)arg); return sock_get_timestamp(sk, (struct timeval __user *)arg);
...@@ -1778,7 +1778,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar ...@@ -1778,7 +1778,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
if (sk->sk_state == WANSOCK_CONNECTED) if (sk->sk_state == WANSOCK_CONNECTED)
return 0; return 0;
return 1; return 1;
...@@ -1804,7 +1804,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar ...@@ -1804,7 +1804,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
case SIOC_WANPIPE_DEBUG: case SIOC_WANPIPE_DEBUG:
return wanpipe_debug(sk,(void*)arg); return wanpipe_debug(sk,(void*)arg);
case SIOC_WANPIPE_SET_NONBLOCK: case SIOC_WANPIPE_SET_NONBLOCK:
if (sk->sk_state != WANSOCK_DISCONNECTED) if (sk->sk_state != WANSOCK_DISCONNECTED)
...@@ -1812,7 +1812,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar ...@@ -1812,7 +1812,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
sock->file->f_flags |= O_NONBLOCK; sock->file->f_flags |= O_NONBLOCK;
return 0; return 0;
#ifdef CONFIG_INET #ifdef CONFIG_INET
case SIOCADDRT: case SIOCADDRT:
case SIOCDELRT: case SIOCDELRT:
...@@ -1842,7 +1842,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar ...@@ -1842,7 +1842,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
/*============================================================ /*============================================================
* wanpipe_debug * wanpipe_debug
* *
* This function will pass up information about all * This function will pass up information about all
* active sockets. * active sockets.
* *
...@@ -1893,49 +1893,49 @@ static int wanpipe_debug (struct sock *origsk, void *arg) ...@@ -1893,49 +1893,49 @@ static int wanpipe_debug (struct sock *origsk, void *arg)
if (sk->sk_bound_dev_if) { if (sk->sk_bound_dev_if) {
dev = dev_get_by_index(sk->sk_bound_dev_if); dev = dev_get_by_index(sk->sk_bound_dev_if);
if (!dev) if (!dev)
continue; continue;
chan=dev->priv; chan=dev->priv;
dev_put(dev); dev_put(dev);
if ((err=put_user(chan->state, &dbg_data->debug[cnt].d_state))) if ((err=put_user(chan->state, &dbg_data->debug[cnt].d_state)))
return err; return err;
if ((err=put_user(chan->svc, &dbg_data->debug[cnt].svc))) if ((err=put_user(chan->svc, &dbg_data->debug[cnt].svc)))
return err; return err;
if ((err=put_user(atomic_read(&chan->command), if ((err=put_user(atomic_read(&chan->command),
&dbg_data->debug[cnt].command))) &dbg_data->debug[cnt].command)))
return err; return err;
if (wp){ if (wp){
sdla_t *card = (sdla_t*)wp->card; sdla_t *card = (sdla_t*)wp->card;
if (card){ if (card){
if ((err=put_user(atomic_read(&card->u.x.command_busy), if ((err=put_user(atomic_read(&card->u.x.command_busy),
&dbg_data->debug[cnt].cmd_busy))) &dbg_data->debug[cnt].cmd_busy)))
return err; return err;
} }
if ((err=put_user(wp->lcn, if ((err=put_user(wp->lcn,
&dbg_data->debug[cnt].lcn))) &dbg_data->debug[cnt].lcn)))
return err; return err;
if (wp->mbox) { if (wp->mbox) {
if ((err=put_user(1, &dbg_data->debug[cnt].mbox))) if ((err=put_user(1, &dbg_data->debug[cnt].mbox)))
return err; return err;
} }
} }
if ((err=put_user(atomic_read(&chan->receive_block), if ((err=put_user(atomic_read(&chan->receive_block),
&dbg_data->debug[cnt].rblock))) &dbg_data->debug[cnt].rblock)))
return err; return err;
if (copy_to_user(dbg_data->debug[cnt].name, dev->name, strlen(dev->name))) if (copy_to_user(dbg_data->debug[cnt].name, dev->name, strlen(dev->name)))
return -EFAULT; return -EFAULT;
} }
if (++cnt == MAX_NUM_DEBUG) if (++cnt == MAX_NUM_DEBUG)
break; break;
} }
...@@ -1944,7 +1944,7 @@ static int wanpipe_debug (struct sock *origsk, void *arg) ...@@ -1944,7 +1944,7 @@ static int wanpipe_debug (struct sock *origsk, void *arg)
/*============================================================ /*============================================================
* get_ioctl_cmd * get_ioctl_cmd
* *
* Pass up the contents of socket MBOX to the user. * Pass up the contents of socket MBOX to the user.
*===========================================================*/ *===========================================================*/
...@@ -1974,7 +1974,7 @@ static int get_ioctl_cmd (struct sock *sk, void *arg) ...@@ -1974,7 +1974,7 @@ static int get_ioctl_cmd (struct sock *sk, void *arg)
if ((err=put_user(mbox_ptr->cmd.result, &usr_data->hdr.result))) if ((err=put_user(mbox_ptr->cmd.result, &usr_data->hdr.result)))
return err; return err;
if ((err=put_user(mbox_ptr->cmd.lcn, &usr_data->hdr.lcn))) if ((err=put_user(mbox_ptr->cmd.lcn, &usr_data->hdr.lcn)))
return err; return err;
if (mbox_ptr->cmd.length > 0){ if (mbox_ptr->cmd.length > 0){
if (mbox_ptr->cmd.length > X25_MAX_DATA) if (mbox_ptr->cmd.length > X25_MAX_DATA)
...@@ -1986,13 +1986,13 @@ static int get_ioctl_cmd (struct sock *sk, void *arg) ...@@ -1986,13 +1986,13 @@ static int get_ioctl_cmd (struct sock *sk, void *arg)
} }
} }
return 0; return 0;
} }
/*============================================================ /*============================================================
* set_ioctl_cmd * set_ioctl_cmd
* *
* Before command can be execute, socket MBOX must * Before command can be execute, socket MBOX must
* be created, and initialized with user data. * be created, and initialized with user data.
*===========================================================*/ *===========================================================*/
static int set_ioctl_cmd (struct sock *sk, void *arg) static int set_ioctl_cmd (struct sock *sk, void *arg)
...@@ -2008,7 +2008,7 @@ static int set_ioctl_cmd (struct sock *sk, void *arg) ...@@ -2008,7 +2008,7 @@ static int set_ioctl_cmd (struct sock *sk, void *arg)
return -ENODEV; return -ENODEV;
dev_put(dev); dev_put(dev);
if ((mbox_ptr = kzalloc(sizeof(mbox_cmd_t), GFP_ATOMIC)) == NULL) if ((mbox_ptr = kzalloc(sizeof(mbox_cmd_t), GFP_ATOMIC)) == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -2092,12 +2092,12 @@ unsigned int wanpipe_poll(struct file * file, struct socket *sock, poll_table *w ...@@ -2092,12 +2092,12 @@ unsigned int wanpipe_poll(struct file * file, struct socket *sock, poll_table *w
return mask; return mask;
} }
/* This check blocks the user process if there is /* This check blocks the user process if there is
* a packet already queued in the socket write queue. * a packet already queued in the socket write queue.
* This option is only for X25API protocol, for other * This option is only for X25API protocol, for other
* protocol like chdlc enable streaming mode, * protocol like chdlc enable streaming mode,
* where multiple packets can be pending in the socket * where multiple packets can be pending in the socket
* transmit queue */ * transmit queue */
if (wp_sk(sk)->num == htons(X25_PROT)) { if (wp_sk(sk)->num == htons(X25_PROT)) {
if (atomic_read(&wp_sk(sk)->packet_sent)) if (atomic_read(&wp_sk(sk)->packet_sent))
...@@ -2110,7 +2110,7 @@ unsigned int wanpipe_poll(struct file * file, struct socket *sock, poll_table *w ...@@ -2110,7 +2110,7 @@ unsigned int wanpipe_poll(struct file * file, struct socket *sock, poll_table *w
}else{ }else{
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
} }
return mask; return mask;
} }
...@@ -2125,8 +2125,8 @@ static int wanpipe_listen(struct socket *sock, int backlog) ...@@ -2125,8 +2125,8 @@ static int wanpipe_listen(struct socket *sock, int backlog)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
/* This is x25 specific area if protocol doesn't /* This is x25 specific area if protocol doesn't
* match, return error */ * match, return error */
if (wp_sk(sk)->num != htons(X25_PROT)) if (wp_sk(sk)->num != htons(X25_PROT))
return -EINVAL; return -EINVAL;
...@@ -2163,7 +2163,7 @@ static int wanpipe_link_card (struct sock *sk) ...@@ -2163,7 +2163,7 @@ static int wanpipe_link_card (struct sock *sk)
card->sk=sk; card->sk=sk;
card->func=wanpipe_listen_rcv; card->func=wanpipe_listen_rcv;
sock_set_flag(sk, SOCK_ZAPPED); sock_set_flag(sk, SOCK_ZAPPED);
return 0; return 0;
} }
...@@ -2176,7 +2176,7 @@ static int wanpipe_link_card (struct sock *sk) ...@@ -2176,7 +2176,7 @@ static int wanpipe_link_card (struct sock *sk)
static void wanpipe_unlink_card (struct sock *sk) static void wanpipe_unlink_card (struct sock *sk)
{ {
sdla_t *card = (sdla_t*)wp_sk(sk)->card; sdla_t *card = (sdla_t*)wp_sk(sk)->card;
if (card){ if (card){
card->sk=NULL; card->sk=NULL;
...@@ -2202,9 +2202,9 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags) ...@@ -2202,9 +2202,9 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
printk(KERN_INFO "NO MBOX PTR !!!!!\n"); printk(KERN_INFO "NO MBOX PTR !!!!!\n");
return -EINVAL; return -EINVAL;
} }
/* This is x25 specific area if protocol doesn't /* This is x25 specific area if protocol doesn't
* match, return error */ * match, return error */
if (wp->num != htons(X25_PROT)) if (wp->num != htons(X25_PROT))
return -EINVAL; return -EINVAL;
...@@ -2217,17 +2217,17 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags) ...@@ -2217,17 +2217,17 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
err = -EHOSTDOWN; err = -EHOSTDOWN;
break; break;
} }
err = execute_command(sk,X25_ACCEPT_CALL,0); err = execute_command(sk,X25_ACCEPT_CALL,0);
if (err < 0) if (err < 0)
break; break;
/* Update. Mar6 2000. /* Update. Mar6 2000.
* Do not set the sock lcn number here, since * Do not set the sock lcn number here, since
* it is done in wanpipe_listen_rcv(). * it is done in wanpipe_listen_rcv().
*/ */
if (sk->sk_state == WANSOCK_CONNECTED) { if (sk->sk_state == WANSOCK_CONNECTED) {
wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn; wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn;
DBG_PRINTK(KERN_INFO "\nwansock: Accept OK %i\n", DBG_PRINTK(KERN_INFO "\nwansock: Accept OK %i\n",
wp->lcn); wp->lcn);
err = 0; err = 0;
...@@ -2249,15 +2249,15 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags) ...@@ -2249,15 +2249,15 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
/* Check if data buffers are pending for transmission, /* Check if data buffers are pending for transmission,
* if so, check whether user wants to wait until data * if so, check whether user wants to wait until data
* is transmitted, or clear a call and drop packets */ * is transmitted, or clear a call and drop packets */
if (atomic_read(&sk->sk_wmem_alloc) || if (atomic_read(&sk->sk_wmem_alloc) ||
check_driver_busy(sk)) { check_driver_busy(sk)) {
mbox_cmd_t *mbox = wp->mbox; mbox_cmd_t *mbox = wp->mbox;
if (mbox->cmd.qdm & 0x80){ if (mbox->cmd.qdm & 0x80){
mbox->cmd.result = 0x35; mbox->cmd.result = 0x35;
err = -EAGAIN; err = -EAGAIN;
break; break;
} }
} }
...@@ -2286,15 +2286,15 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags) ...@@ -2286,15 +2286,15 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
/* Check if data buffers are pending for transmission, /* Check if data buffers are pending for transmission,
* if so, check whether user wants to wait until data * if so, check whether user wants to wait until data
* is transmitted, or reset a call and drop packets */ * is transmitted, or reset a call and drop packets */
if (atomic_read(&sk->sk_wmem_alloc) || if (atomic_read(&sk->sk_wmem_alloc) ||
check_driver_busy(sk)) { check_driver_busy(sk)) {
mbox_cmd_t *mbox = wp->mbox; mbox_cmd_t *mbox = wp->mbox;
if (mbox->cmd.qdm & 0x80){ if (mbox->cmd.qdm & 0x80){
mbox->cmd.result = 0x35; mbox->cmd.result = 0x35;
err = -EAGAIN; err = -EAGAIN;
break; break;
} }
} }
...@@ -2316,7 +2316,7 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags) ...@@ -2316,7 +2316,7 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
if (sk->sk_state == WANSOCK_CONNECTED) { if (sk->sk_state == WANSOCK_CONNECTED) {
wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn; wp->lcn = ((mbox_cmd_t*)wp->mbox)->cmd.lcn;
DBG_PRINTK(KERN_INFO "\nwansock: PLACE CALL OK %i\n", DBG_PRINTK(KERN_INFO "\nwansock: PLACE CALL OK %i\n",
wp->lcn); wp->lcn);
...@@ -2337,7 +2337,7 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags) ...@@ -2337,7 +2337,7 @@ static int wanpipe_exec_cmd(struct sock *sk, int cmd, unsigned int flags)
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -2364,9 +2364,9 @@ static int check_driver_busy (struct sock *sk) ...@@ -2364,9 +2364,9 @@ static int check_driver_busy (struct sock *sk)
/*====================================================================== /*======================================================================
* wanpipe_accept * wanpipe_accept
* *
* ACCEPT() System call. X25API Specific function. * ACCEPT() System call. X25API Specific function.
* For each incoming call, create a new socket and * For each incoming call, create a new socket and
* return it to the user. * return it to the user.
*=====================================================================*/ *=====================================================================*/
static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags) static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags)
...@@ -2378,10 +2378,10 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags ...@@ -2378,10 +2378,10 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags
int err=0; int err=0;
if (newsock->sk != NULL){ if (newsock->sk != NULL){
wanpipe_kill_sock_accept(newsock->sk); wanpipe_kill_sock_accept(newsock->sk);
newsock->sk=NULL; newsock->sk=NULL;
} }
if ((sk = sock->sk) == NULL) if ((sk = sock->sk) == NULL)
return -EINVAL; return -EINVAL;
...@@ -2410,10 +2410,10 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags ...@@ -2410,10 +2410,10 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags
} }
current->state = TASK_RUNNING; current->state = TASK_RUNNING;
remove_wait_queue(sk->sk_sleep,&wait); remove_wait_queue(sk->sk_sleep,&wait);
if (err != 0) if (err != 0)
return err; return err;
newsk = get_newsk_from_skb(skb); newsk = get_newsk_from_skb(skb);
if (!newsk){ if (!newsk){
return -EINVAL; return -EINVAL;
...@@ -2431,7 +2431,7 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags ...@@ -2431,7 +2431,7 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags
/* Now attach up the new socket */ /* Now attach up the new socket */
sk->sk_ack_backlog--; sk->sk_ack_backlog--;
newsock->sk = newsk; newsock->sk = newsk;
kfree_skb(skb); kfree_skb(skb);
DBG_PRINTK(KERN_INFO "\nwansock: ACCEPT Got LCN %i\n", DBG_PRINTK(KERN_INFO "\nwansock: ACCEPT Got LCN %i\n",
...@@ -2449,16 +2449,16 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags ...@@ -2449,16 +2449,16 @@ static int wanpipe_accept(struct socket *sock, struct socket *newsock, int flags
struct sock * get_newsk_from_skb (struct sk_buff *skb) struct sock * get_newsk_from_skb (struct sk_buff *skb)
{ {
struct net_device *dev = skb->dev; struct net_device *dev = skb->dev;
wanpipe_common_t *chan; wanpipe_common_t *chan;
if (!dev){ if (!dev){
return NULL; return NULL;
} }
if ((chan = dev->priv) == NULL){ if ((chan = dev->priv) == NULL){
return NULL; return NULL;
} }
if (!chan->sk){ if (!chan->sk){
return NULL; return NULL;
} }
...@@ -2470,7 +2470,7 @@ struct sock * get_newsk_from_skb (struct sk_buff *skb) ...@@ -2470,7 +2470,7 @@ struct sock * get_newsk_from_skb (struct sk_buff *skb)
* *
* CONNECT() System Call. X25API specific function * CONNECT() System Call. X25API specific function
* Check the state of the sock, and execute PLACE_CALL command. * Check the state of the sock, and execute PLACE_CALL command.
* Connect can ether block or return without waiting for connection, * Connect can ether block or return without waiting for connection,
* if specified by user. * if specified by user.
*=====================================================================*/ *=====================================================================*/
...@@ -2492,7 +2492,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr ...@@ -2492,7 +2492,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr
return -ECONNREFUSED; return -ECONNREFUSED;
} }
sk->sk_state = WANSOCK_DISCONNECTED; sk->sk_state = WANSOCK_DISCONNECTED;
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
if (addr_len != sizeof(struct wan_sockaddr_ll)) if (addr_len != sizeof(struct wan_sockaddr_ll))
...@@ -2505,7 +2505,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr ...@@ -2505,7 +2505,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr
return -ENETUNREACH; return -ENETUNREACH;
dev_put(dev); dev_put(dev);
if (!sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */ if (!sock_flag(sk, SOCK_ZAPPED)) /* Must bind first - autobinding does not work */
return -EINVAL; return -EINVAL;
...@@ -2534,7 +2534,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr ...@@ -2534,7 +2534,7 @@ static int wanpipe_connect(struct socket *sock, struct sockaddr *uaddr, int addr
if (sk->sk_state != WANSOCK_CONNECTED) { if (sk->sk_state != WANSOCK_CONNECTED) {
sock->state = SS_UNCONNECTED; sock->state = SS_UNCONNECTED;
return -ECONNREFUSED; return -ECONNREFUSED;
} }
sock->state = SS_CONNECTED; sock->state = SS_CONNECTED;
...@@ -2549,10 +2549,10 @@ const struct proto_ops wanpipe_ops = { ...@@ -2549,10 +2549,10 @@ const struct proto_ops wanpipe_ops = {
.connect = wanpipe_connect, .connect = wanpipe_connect,
.socketpair = sock_no_socketpair, .socketpair = sock_no_socketpair,
.accept = wanpipe_accept, .accept = wanpipe_accept,
.getname = wanpipe_getname, .getname = wanpipe_getname,
.poll = wanpipe_poll, .poll = wanpipe_poll,
.ioctl = wanpipe_ioctl, .ioctl = wanpipe_ioctl,
.listen = wanpipe_listen, .listen = wanpipe_listen,
.shutdown = sock_no_shutdown, .shutdown = sock_no_shutdown,
.setsockopt = sock_no_setsockopt, .setsockopt = sock_no_setsockopt,
.getsockopt = sock_no_getsockopt, .getsockopt = sock_no_getsockopt,
......
...@@ -314,10 +314,10 @@ __be16 wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev) ...@@ -314,10 +314,10 @@ __be16 wanrouter_type_trans(struct sk_buff *skb, struct net_device *dev)
cnt += 1; cnt += 1;
break; break;
case NLPID_SNAP: /* SNAP encapsulation */ case NLPID_SNAP: /* SNAP encapsulation */
if (memcmp(&skb->data[cnt + 1], wanrouter_oui_ether, if (memcmp(&skb->data[cnt + 1], wanrouter_oui_ether,
sizeof(wanrouter_oui_ether))){ sizeof(wanrouter_oui_ether))){
printk(KERN_INFO printk(KERN_INFO
"%s: unsupported SNAP OUI %02X-%02X-%02X " "%s: unsupported SNAP OUI %02X-%02X-%02X "
"on interface %s!\n", wanrouter_modname, "on interface %s!\n", wanrouter_modname,
skb->data[cnt+1], skb->data[cnt+2], skb->data[cnt+1], skb->data[cnt+2],
...@@ -450,7 +450,7 @@ static int wanrouter_device_setup(struct wan_device *wandev, ...@@ -450,7 +450,7 @@ static int wanrouter_device_setup(struct wan_device *wandev,
kfree(conf); kfree(conf);
printk(KERN_INFO "%s: ERROR, Invalid MAGIC Number\n", printk(KERN_INFO "%s: ERROR, Invalid MAGIC Number\n",
wandev->name); wandev->name);
return -EINVAL; return -EINVAL;
} }
if (conf->data_size && conf->data) { if (conf->data_size && conf->data) {
...@@ -459,13 +459,13 @@ static int wanrouter_device_setup(struct wan_device *wandev, ...@@ -459,13 +459,13 @@ static int wanrouter_device_setup(struct wan_device *wandev,
"%s: ERROR, Invalid firmware data size %i !\n", "%s: ERROR, Invalid firmware data size %i !\n",
wandev->name, conf->data_size); wandev->name, conf->data_size);
kfree(conf); kfree(conf);
return -EINVAL; return -EINVAL;
} }
data = vmalloc(conf->data_size); data = vmalloc(conf->data_size);
if (!data) { if (!data) {
printk(KERN_INFO printk(KERN_INFO
"%s: ERROR, Faild allocate kernel memory !\n", "%s: ERROR, Faild allocate kernel memory !\n",
wandev->name); wandev->name);
kfree(conf); kfree(conf);
return -ENOBUFS; return -ENOBUFS;
...@@ -686,7 +686,7 @@ static int wanrouter_device_new_if(struct wan_device *wandev, ...@@ -686,7 +686,7 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
static int wanrouter_device_del_if(struct wan_device *wandev, char __user *u_name) static int wanrouter_device_del_if(struct wan_device *wandev, char __user *u_name)
{ {
char name[WAN_IFNAME_SZ + 1]; char name[WAN_IFNAME_SZ + 1];
int err = 0; int err = 0;
if (wandev->state == WAN_UNCONFIGURED) if (wandev->state == WAN_UNCONFIGURED)
return -ENODEV; return -ENODEV;
...@@ -709,8 +709,8 @@ static int wanrouter_device_del_if(struct wan_device *wandev, char __user *u_nam ...@@ -709,8 +709,8 @@ static int wanrouter_device_del_if(struct wan_device *wandev, char __user *u_nam
* interfaces are deleted and the link irrecoverably disconnected. * interfaces are deleted and the link irrecoverably disconnected.
*/ */
if (!wandev->ndev && wandev->shutdown) if (!wandev->ndev && wandev->shutdown)
err = wandev->shutdown(wandev); err = wandev->shutdown(wandev);
return err; return err;
} }
...@@ -804,7 +804,7 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name) ...@@ -804,7 +804,7 @@ static int wanrouter_delete_interface(struct wan_device *wandev, char *name)
static void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags) static void lock_adapter_irq(spinlock_t *lock, unsigned long *smp_flags)
{ {
spin_lock_irqsave(lock, *smp_flags); spin_lock_irqsave(lock, *smp_flags);
} }
......
...@@ -37,10 +37,10 @@ ...@@ -37,10 +37,10 @@
#define PROT_DECODE(prot) ((prot == WANCONFIG_FR) ? " FR" :\ #define PROT_DECODE(prot) ((prot == WANCONFIG_FR) ? " FR" :\
(prot == WANCONFIG_X25) ? " X25" : \ (prot == WANCONFIG_X25) ? " X25" : \
(prot == WANCONFIG_PPP) ? " PPP" : \ (prot == WANCONFIG_PPP) ? " PPP" : \
(prot == WANCONFIG_CHDLC) ? " CHDLC": \ (prot == WANCONFIG_CHDLC) ? " CHDLC": \
(prot == WANCONFIG_MPPP) ? " MPPP" : \ (prot == WANCONFIG_MPPP) ? " MPPP" : \
" Unknown" ) " Unknown" )
/****** Function Prototypes *************************************************/ /****** Function Prototypes *************************************************/
......
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