]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/x25/af_x25.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
[linux-2.6-omap-h63xx.git] / net / x25 / af_x25.c
index 03725c05175294732418b62107db627059179a50..52a2726d327fe68f6c7ea003894902b204f25e99 100644 (file)
@@ -35,7 +35,6 @@
  *                                     response
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/capability.h>
 #include <linux/errno.h>
@@ -525,6 +524,13 @@ static int x25_create(struct socket *sock, int protocol)
        x25->facilities.pacsize_out = X25_DEFAULT_PACKET_SIZE;
        x25->facilities.throughput  = X25_DEFAULT_THROUGHPUT;
        x25->facilities.reverse     = X25_DEFAULT_REVERSE;
+       x25->dte_facilities.calling_len = 0;
+       x25->dte_facilities.called_len = 0;
+       memset(x25->dte_facilities.called_ae, '\0',
+                       sizeof(x25->dte_facilities.called_ae));
+       memset(x25->dte_facilities.calling_ae, '\0',
+                       sizeof(x25->dte_facilities.calling_ae));
+
        rc = 0;
 out:
        return rc;
@@ -561,6 +567,7 @@ static struct sock *x25_make_new(struct sock *osk)
        x25->t2         = ox25->t2;
        x25->facilities = ox25->facilities;
        x25->qbitincl   = ox25->qbitincl;
+       x25->dte_facilities = ox25->dte_facilities;
        x25->cudmatchlength = ox25->cudmatchlength;
        x25->accptapprv = ox25->accptapprv;
 
@@ -840,6 +847,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
        struct x25_sock *makex25;
        struct x25_address source_addr, dest_addr;
        struct x25_facilities facilities;
+       struct x25_dte_facilities dte_facilities;
        int len, rc;
 
        /*
@@ -876,7 +884,8 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
        /*
         *      Try to reach a compromise on the requested facilities.
         */
-       if ((len = x25_negotiate_facilities(skb, sk, &facilities)) == -1)
+       len = x25_negotiate_facilities(skb, sk, &facilities, &dte_facilities);
+       if (len == -1)
                goto out_sock_put;
 
        /*
@@ -907,9 +916,12 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
        makex25->source_addr   = source_addr;
        makex25->neighbour     = nb;
        makex25->facilities    = facilities;
+       makex25->dte_facilities= dte_facilities;
        makex25->vc_facil_mask = x25_sk(sk)->vc_facil_mask;
        /* ensure no reverse facil on accept */
        makex25->vc_facil_mask &= ~X25_MASK_REVERSE;
+       /* ensure no calling address extension on accept */
+       makex25->vc_facil_mask &= ~X25_MASK_CALLING_AE;
        makex25->cudmatchlength = x25_sk(sk)->cudmatchlength;
 
        /* Normally all calls are accepted immediatly */
@@ -1316,6 +1328,36 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
                        break;
                }
 
+               case SIOCX25GDTEFACILITIES: {
+                       rc = copy_to_user(argp, &x25->dte_facilities,
+                                               sizeof(x25->dte_facilities));
+                       if (rc)
+                               rc = -EFAULT;
+                       break;
+               }
+
+               case SIOCX25SDTEFACILITIES: {
+                       struct x25_dte_facilities dtefacs;
+                       rc = -EFAULT;
+                       if (copy_from_user(&dtefacs, argp, sizeof(dtefacs)))
+                               break;
+                       rc = -EINVAL;
+                       if (sk->sk_state != TCP_LISTEN &&
+                                       sk->sk_state != TCP_CLOSE)
+                               break;
+                       if (dtefacs.calling_len > X25_MAX_AE_LEN)
+                               break;
+                       if (dtefacs.calling_ae == NULL)
+                               break;
+                       if (dtefacs.called_len > X25_MAX_AE_LEN)
+                               break;
+                       if (dtefacs.called_ae == NULL)
+                               break;
+                       x25->dte_facilities = dtefacs;
+                       rc = 0;
+                       break;
+               }
+
                case SIOCX25GCALLUSERDATA: {
                        struct x25_calluserdata cud = x25->calluserdata;
                        rc = copy_to_user(argp, &cud,
@@ -1492,6 +1534,8 @@ static int compat_x25_ioctl(struct socket *sock, unsigned int cmd,
                break;
        case SIOCX25GFACILITIES:
        case SIOCX25SFACILITIES:
+       case SIOCX25GDTEFACILITIES:
+       case SIOCX25SDTEFACILITIES:
        case SIOCX25GCALLUSERDATA:
        case SIOCX25SCALLUSERDATA:
        case SIOCX25GCAUSEDIAG: