root/net/netrom/af_netrom.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. nr_remove_socket
  2. nr_kill_by_device
  3. nr_device_event
  4. nr_insert_socket
  5. nr_find_listener
  6. nr_find_socket
  7. nr_find_peer
  8. nr_destroy_timer
  9. nr_destroy_socket
  10. nr_fcntl
  11. nr_setsockopt
  12. nr_getsockopt
  13. nr_listen
  14. def_callback1
  15. def_callback2
  16. nr_create
  17. nr_make_new
  18. nr_dup
  19. nr_release
  20. nr_bind
  21. nr_connect
  22. nr_socketpair
  23. nr_accept
  24. nr_getname
  25. nr_rx_frame
  26. nr_sendmsg
  27. nr_recvmsg
  28. nr_shutdown
  29. nr_select
  30. nr_ioctl
  31. nr_get_info
  32. nr_proto_init

   1 /*
   2  *      NET/ROM release 003
   3  *
   4  *      This is ALPHA test software. This code may break your machine, randomly fail to work with new 
   5  *      releases, misbehave and/or generally screw up. It might even work. 
   6  *
   7  *      This code REQUIRES 1.3.0 or higher/ NET3.029
   8  *
   9  *      This module:
  10  *              This module is free software; you can redistribute it and/or
  11  *              modify it under the terms of the GNU General Public License
  12  *              as published by the Free Software Foundation; either version
  13  *              2 of the License, or (at your option) any later version.
  14  *
  15  *      History
  16  *      NET/ROM 001     Jonathan(G4KLX) Cloned from the AX25 code.
  17  *      NET/ROM 002     Darryl(G7LED)   Fixes and address enhancement.
  18  *                      Jonathan(G4KLX) Complete bind re-think.
  19  *                      Alan(GW4PTS)    Trivial tweaks into new format.
  20  *      NET/ROM 003     Jonathan(G4KLX) Added G8BPQ extensions.
  21  *                                      Added NET/ROM routing ioctl.
  22  *                      Darryl(G7LED)   Fix autobinding (on connect).
  23  *                                      Fixed nr_release(), set TCP_CLOSE, wakeup app
  24  *                                      context, THEN make the sock dead.
  25  *                                      Circuit ID check before allocating it on
  26  *                                      a connection.
  27  *                      Alan(GW4PTS)    sendmsg/recvmsg only. Fixed connect clear bug
  28  *                                      inherited from AX.25
  29  */
  30   
  31 #include <linux/config.h>
  32 #ifdef CONFIG_NETROM
  33 #include <linux/errno.h>
  34 #include <linux/types.h>
  35 #include <linux/socket.h>
  36 #include <linux/in.h>
  37 #include <linux/kernel.h>
  38 #include <linux/sched.h>
  39 #include <linux/timer.h>
  40 #include <linux/string.h>
  41 #include <linux/sockios.h>
  42 #include <linux/net.h>
  43 #include <linux/stat.h>
  44 #include <net/ax25.h>
  45 #include <linux/inet.h>
  46 #include <linux/netdevice.h>
  47 #include <linux/if_arp.h>
  48 #include <linux/skbuff.h>
  49 #include <net/sock.h>
  50 #include <asm/segment.h>
  51 #include <asm/system.h>
  52 #include <linux/fcntl.h>
  53 #include <linux/termios.h>      /* For TIOCINQ/OUTQ */
  54 #include <linux/mm.h>
  55 #include <linux/interrupt.h>
  56 #include <linux/notifier.h>
  57 #include <net/netrom.h>
  58 #include <linux/proc_fs.h>
  59 #include <net/ip.h>
  60 #include <net/arp.h>
  61 #include <linux/if_arp.h>
  62 
  63 struct nr_parms_struct nr_default;
  64 
  65 static unsigned short circuit = 0x101;
  66 
  67 static struct sock *volatile nr_list = NULL;
  68 
  69 /*
  70  *      Socket removal during an interrupt is now safe.
  71  */
  72 static void nr_remove_socket(struct sock *sk)
     /* [previous][next][first][last][top][bottom][index][help] */
  73 {
  74         struct sock *s;
  75         unsigned long flags;
  76         
  77         save_flags(flags);
  78         cli();
  79 
  80         if ((s = nr_list) == sk) {
  81                 nr_list = s->next;
  82                 restore_flags(flags);
  83                 return;
  84         }
  85 
  86         while (s != NULL && s->next != NULL) {
  87                 if (s->next == sk) {
  88                         s->next = sk->next;
  89                         restore_flags(flags);
  90                         return;
  91                 }
  92 
  93                 s = s->next;
  94         }
  95 
  96         restore_flags(flags);
  97 }
  98 
  99 /*
 100  *      Kill all bound sockets on a dropped device.
 101  */
 102 static void nr_kill_by_device(struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 103 {
 104         struct sock *s;
 105         
 106         for (s = nr_list; s != NULL; s = s->next) {
 107                 if (s->nr->device == dev) {
 108                         s->nr->state  = NR_STATE_0;
 109                         s->nr->device = NULL;
 110                         s->state = TCP_CLOSE;
 111                         s->err   = ENETUNREACH;
 112                         s->state_change(s);
 113                         s->dead  = 1;
 114                 }
 115         }
 116 }
 117 
 118 /*
 119  *      Handle device status changes.
 120  */
 121 static int nr_device_event(struct notifier_block *this, unsigned long event, void *ptr)
     /* [previous][next][first][last][top][bottom][index][help] */
 122 {
 123         struct device *dev = (struct device *)ptr;
 124 
 125         if (event != NETDEV_DOWN)
 126                 return NOTIFY_DONE;
 127                 
 128         nr_kill_by_device(dev);
 129         nr_rt_device_down(dev);
 130         
 131         return NOTIFY_DONE;
 132 }
 133 
 134 /*
 135  *      Add a socket to the bound sockets list.
 136  */
 137 static void nr_insert_socket(struct sock *sk)
     /* [previous][next][first][last][top][bottom][index][help] */
 138 {
 139         unsigned long flags;
 140 
 141         save_flags(flags);
 142         cli();
 143 
 144         sk->next = nr_list;
 145         nr_list  = sk;
 146 
 147         restore_flags(flags);
 148 }
 149 
 150 /*
 151  *      Find a socket that wants to accept the Connect Request we just
 152  *      received.
 153  */
 154 static struct sock *nr_find_listener(ax25_address *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 155 {
 156         unsigned long flags;
 157         struct sock *s;
 158 
 159         save_flags(flags);
 160         cli();
 161 
 162         for (s = nr_list; s != NULL; s = s->next) {
 163                 if (ax25cmp(&s->nr->source_addr, addr) == 0 && s->state == TCP_LISTEN) {
 164                         restore_flags(flags);
 165                         return s;
 166                 }
 167         }
 168 
 169         restore_flags(flags);
 170         return NULL;
 171 }
 172 
 173 /*
 174  *      Find a connected NET/ROM socket given my circuit IDs.
 175  */
 176 static struct sock *nr_find_socket(unsigned char index, unsigned char id)
     /* [previous][next][first][last][top][bottom][index][help] */
 177 {
 178         struct sock *s;
 179         unsigned long flags;
 180 
 181         save_flags(flags);
 182         cli();
 183 
 184         for (s = nr_list; s != NULL; s = s->next) {
 185                 if (s->nr->my_index == index && s->nr->my_id == id) {
 186                         restore_flags(flags);
 187                         return s;
 188                 }
 189         }
 190 
 191         restore_flags(flags);
 192 
 193         return NULL;
 194 }
 195 
 196 /*
 197  *      Find a connected NET/ROM socket given their circuit IDs.
 198  */
 199 static struct sock *nr_find_peer(unsigned char index, unsigned char id)
     /* [previous][next][first][last][top][bottom][index][help] */
 200 {
 201         struct sock *s;
 202         unsigned long flags;
 203 
 204         save_flags(flags);
 205         cli();
 206 
 207         for (s = nr_list; s != NULL; s = s->next) {
 208                 if (s->nr->your_index == index && s->nr->your_id == id) {
 209                         restore_flags(flags);
 210                         return s;
 211                 }
 212         }
 213 
 214         restore_flags(flags);
 215 
 216         return NULL;
 217 }
 218 
 219 /*
 220  *      Deferred destroy.
 221  */
 222 void nr_destroy_socket(struct sock *);
 223 
 224 /*
 225  *      Handler for deferred kills.
 226  */
 227 static void nr_destroy_timer(unsigned long data)
     /* [previous][next][first][last][top][bottom][index][help] */
 228 {
 229         nr_destroy_socket((struct sock *)data);
 230 }
 231 
 232 /*
 233  *      This is called from user mode and the timers. Thus it protects itself against
 234  *      interrupt users but doesn't worry about being called during work.
 235  *      Once it is removed from the queue no interrupt or bottom half will
 236  *      touch it and we are (fairly 8-) ) safe.
 237  */
 238 void nr_destroy_socket(struct sock *sk) /* Not static as its used by the timer */
     /* [previous][next][first][last][top][bottom][index][help] */
 239 {
 240         struct sk_buff *skb;
 241         unsigned long flags;
 242         
 243         save_flags(flags);
 244         cli();
 245         
 246         del_timer(&sk->timer);
 247         
 248         nr_remove_socket(sk);
 249         nr_clear_queues(sk);            /* Flush the queues */
 250         
 251         while ((skb = skb_dequeue(&sk->receive_queue)) != NULL) {
 252                 if (skb->sk != sk) {                    /* A pending connection */
 253                         skb->sk->dead = 1;      /* Queue the unaccepted socket for death */
 254                         nr_set_timer(skb->sk);
 255                         skb->sk->nr->state = NR_STATE_0;
 256                 }
 257 
 258                 kfree_skb(skb, FREE_READ);
 259         }
 260         
 261         if (sk->wmem_alloc || sk->rmem_alloc) { /* Defer: outstanding buffers */
 262                 init_timer(&sk->timer);
 263                 sk->timer.expires  = jiffies + 10 * HZ;
 264                 sk->timer.function = nr_destroy_timer;
 265                 sk->timer.data     = (unsigned long)sk;
 266                 add_timer(&sk->timer);
 267         } else {
 268                 kfree_s(sk->nr, sizeof(*sk->nr));
 269                 sk_free(sk);
 270         }
 271 
 272         restore_flags(flags);
 273 }
 274 
 275 /*
 276  *      Handling for system calls applied via the various interfaces to a
 277  *      NET/ROM socket object.
 278  */
 279  
 280 static int nr_fcntl(struct socket *sock, unsigned int cmd, unsigned long arg)
     /* [previous][next][first][last][top][bottom][index][help] */
 281 {
 282         return -EINVAL;
 283 }
 284 
 285 static int nr_setsockopt(struct socket *sock, int level, int optname,
     /* [previous][next][first][last][top][bottom][index][help] */
 286         char *optval, int optlen)
 287 {
 288         struct sock *sk;
 289         int err, opt;
 290 
 291         sk = (struct sock *)sock->data;
 292         
 293         if (level == SOL_SOCKET)
 294                 return sock_setsockopt(sk, level, optname, optval, optlen);
 295 
 296         if (level != SOL_NETROM)
 297                 return -EOPNOTSUPP;
 298 
 299         if (optval == NULL)
 300                 return -EINVAL;
 301 
 302         if ((err = verify_area(VERIFY_READ, optval, sizeof(int))) != 0)
 303                 return err;
 304 
 305         opt = get_fs_long((unsigned long *)optval);
 306         
 307         switch (optname) {
 308                 case NETROM_T1:
 309                         if (opt < 1)
 310                                 return -EINVAL;
 311                         sk->nr->rtt = (opt * PR_SLOWHZ) / 2;
 312                         return 0;
 313 
 314                 case NETROM_T2:
 315                         if (opt < 1)
 316                                 return -EINVAL;
 317                         sk->nr->t2 = opt * PR_SLOWHZ;
 318                         return 0;
 319                         
 320                 case NETROM_N2:
 321                         if (opt < 1 || opt > 31)
 322                                 return -EINVAL;
 323                         sk->nr->n2 = opt;
 324                         return 0;
 325                         
 326                 case NETROM_HDRINCL:
 327                         sk->nr->hdrincl = opt ? 1 : 0;
 328                         return 0;
 329                         
 330                 default:
 331                         return -ENOPROTOOPT;
 332         }
 333 }
 334 
 335 static int nr_getsockopt(struct socket *sock, int level, int optname,
     /* [previous][next][first][last][top][bottom][index][help] */
 336         char *optval, int *optlen)
 337 {
 338         struct sock *sk;
 339         int val = 0;
 340         int err; 
 341 
 342         sk = (struct sock *)sock->data;
 343         
 344         if (level == SOL_SOCKET)
 345                 return sock_getsockopt(sk, level, optname, optval, optlen);
 346         
 347         if (level != SOL_NETROM)
 348                 return -EOPNOTSUPP;
 349         
 350         switch (optname) {
 351                 case NETROM_T1:
 352                         val = (sk->nr->t1 * 2) / PR_SLOWHZ;
 353                         break;
 354                         
 355                 case NETROM_T2:
 356                         val = sk->nr->t2 / PR_SLOWHZ;
 357                         break;
 358                         
 359                 case NETROM_N2:
 360                         val = sk->nr->n2;
 361                         break;
 362                                                 
 363                 case NETROM_HDRINCL:
 364                         val = sk->nr->hdrincl;
 365                         break;
 366 
 367                 default:
 368                         return -ENOPROTOOPT;
 369         }
 370 
 371         if ((err = verify_area(VERIFY_WRITE, optlen, sizeof(int))) != 0)
 372                 return err;
 373 
 374         put_fs_long(sizeof(int), (unsigned long *)optlen);
 375 
 376         if ((err = verify_area(VERIFY_WRITE, optval, sizeof(int))) != 0)
 377                 return err;
 378 
 379         put_fs_long(val, (unsigned long *)optval);
 380 
 381         return 0;
 382 }
 383 
 384 static int nr_listen(struct socket *sock, int backlog)
     /* [previous][next][first][last][top][bottom][index][help] */
 385 {
 386         struct sock *sk = (struct sock *)sock->data;
 387 
 388         if (sk->state != TCP_LISTEN) {
 389                 memset(&sk->nr->user_addr, '\0', AX25_ADDR_LEN);
 390                 sk->max_ack_backlog = backlog;
 391                 sk->state           = TCP_LISTEN;
 392                 return 0;
 393         }
 394 
 395         return -EOPNOTSUPP;
 396 }
 397 
 398 static void def_callback1(struct sock *sk)
     /* [previous][next][first][last][top][bottom][index][help] */
 399 {
 400         if (!sk->dead)
 401                 wake_up_interruptible(sk->sleep);
 402 }
 403 
 404 static void def_callback2(struct sock *sk, int len)
     /* [previous][next][first][last][top][bottom][index][help] */
 405 {
 406         if (!sk->dead)
 407                 wake_up_interruptible(sk->sleep);
 408 }
 409 
 410 static int nr_create(struct socket *sock, int protocol)
     /* [previous][next][first][last][top][bottom][index][help] */
 411 {
 412         struct sock *sk;
 413         nr_cb *nr;
 414 
 415         if (sock->type != SOCK_SEQPACKET || protocol != 0)
 416                 return -ESOCKTNOSUPPORT;
 417 
 418         if ((sk = sk_alloc(GFP_ATOMIC)) == NULL)
 419                 return -ENOMEM;
 420 
 421         if ((nr = (nr_cb *)kmalloc(sizeof(*nr), GFP_ATOMIC)) == NULL) {
 422                 sk_free(sk);
 423                 return -ENOMEM;
 424         }
 425 
 426         skb_queue_head_init(&sk->receive_queue);
 427         skb_queue_head_init(&sk->write_queue);
 428         skb_queue_head_init(&sk->back_log);
 429 
 430         init_timer(&sk->timer);
 431 
 432         sk->socket        = sock;
 433         sk->type          = sock->type;
 434         sk->protocol      = protocol;
 435         sk->allocation    = GFP_KERNEL;
 436         sk->rcvbuf        = SK_RMEM_MAX;
 437         sk->sndbuf        = SK_WMEM_MAX;
 438         sk->state         = TCP_CLOSE;
 439         sk->priority      = SOPRI_NORMAL;
 440         sk->mtu           = NETROM_MTU; /* 236 */
 441         sk->zapped        = 1;
 442         sk->window        = nr_default.window;
 443 
 444         sk->state_change = def_callback1;
 445         sk->data_ready   = def_callback2;
 446         sk->write_space  = def_callback1;
 447         sk->error_report = def_callback1;
 448 
 449         if (sock != NULL) {
 450                 sock->data = (void *)sk;
 451                 sk->sleep  = sock->wait;
 452         }
 453 
 454         skb_queue_head_init(&nr->ack_queue);
 455         skb_queue_head_init(&nr->reseq_queue);
 456         skb_queue_head_init(&nr->frag_queue);
 457 
 458         nr->my_index = 0;
 459         nr->my_id    = 0;
 460         nr->rtt      = nr_default.timeout / 2;
 461         nr->t1       = nr_default.timeout;
 462         nr->t2       = nr_default.ack_delay;
 463         nr->n2       = nr_default.tries;
 464 
 465         nr->t1timer  = 0;
 466         nr->t2timer  = 0;
 467         nr->t4timer  = 0;
 468         nr->n2count  = 0;
 469 
 470         nr->va       = 0;
 471         nr->vr       = 0;
 472         nr->vs       = 0;
 473         nr->vl       = 0;
 474 
 475         nr->your_index = 0;
 476         nr->your_id    = 0;
 477 
 478         nr->my_index   = 0;
 479         nr->my_id      = 0;
 480 
 481         nr->bpqext     = 1;
 482         nr->fraglen    = 0;
 483         nr->hdrincl    = 0;
 484         nr->state      = NR_STATE_0;
 485         nr->device     = NULL;
 486 
 487         memset(&nr->source_addr, '\0', AX25_ADDR_LEN);
 488         memset(&nr->user_addr,   '\0', AX25_ADDR_LEN);
 489         memset(&nr->dest_addr,   '\0', AX25_ADDR_LEN);
 490 
 491         nr->sk = sk;
 492         sk->nr = nr;
 493 
 494         return 0;
 495 }
 496 
 497 static struct sock *nr_make_new(struct sock *osk)
     /* [previous][next][first][last][top][bottom][index][help] */
 498 {
 499         struct sock *sk;
 500         nr_cb *nr;
 501 
 502         if (osk->type != SOCK_SEQPACKET)
 503                 return NULL;
 504 
 505         if ((sk = (struct sock *)sk_alloc(GFP_ATOMIC)) == NULL)
 506                 return NULL;
 507 
 508         if ((nr = (nr_cb *)kmalloc(sizeof(*nr), GFP_ATOMIC)) == NULL) {
 509                 sk_free(sk);
 510                 return NULL;
 511         }
 512 
 513         skb_queue_head_init(&sk->receive_queue);
 514         skb_queue_head_init(&sk->write_queue);
 515         skb_queue_head_init(&sk->back_log);
 516 
 517         init_timer(&sk->timer);
 518 
 519         sk->type        = osk->type;
 520         sk->socket      = osk->socket;
 521         sk->priority    = osk->priority;
 522         sk->protocol    = osk->protocol;
 523         sk->rcvbuf      = osk->rcvbuf;
 524         sk->sndbuf      = osk->sndbuf;
 525         sk->debug       = osk->debug;
 526         sk->state       = TCP_ESTABLISHED;
 527         sk->window      = osk->window;
 528         sk->mtu         = osk->mtu;
 529         sk->sleep       = osk->sleep;
 530         sk->zapped      = osk->zapped;
 531 
 532         sk->state_change = def_callback1;
 533         sk->data_ready   = def_callback2;
 534         sk->write_space  = def_callback1;
 535         sk->error_report = def_callback1;
 536 
 537         skb_queue_head_init(&nr->ack_queue);
 538         skb_queue_head_init(&nr->reseq_queue);
 539         skb_queue_head_init(&nr->frag_queue);
 540 
 541         nr->rtt      = osk->nr->rtt;
 542         nr->t1       = osk->nr->t1;
 543         nr->t2       = osk->nr->t2;
 544         nr->n2       = osk->nr->n2;
 545 
 546         nr->device   = osk->nr->device;
 547         nr->bpqext   = osk->nr->bpqext;
 548         nr->hdrincl  = osk->nr->hdrincl;
 549         nr->fraglen  = 0;
 550 
 551         nr->t1timer  = 0;
 552         nr->t2timer  = 0;
 553         nr->t4timer  = 0;
 554         nr->n2count  = 0;
 555 
 556         nr->va       = 0;
 557         nr->vr       = 0;
 558         nr->vs       = 0;
 559         nr->vl       = 0;
 560         
 561         sk->nr = nr;
 562         nr->sk = sk;
 563 
 564         return sk;
 565 }
 566 
 567 static int nr_dup(struct socket *newsock, struct socket *oldsock)
     /* [previous][next][first][last][top][bottom][index][help] */
 568 {
 569         struct sock *sk = (struct sock *)oldsock->data;
 570 
 571         return nr_create(newsock, sk->protocol);
 572 }
 573 
 574 static int nr_release(struct socket *sock, struct socket *peer)
     /* [previous][next][first][last][top][bottom][index][help] */
 575 {
 576         struct sock *sk = (struct sock *)sock->data;
 577 
 578         if (sk == NULL) return 0;
 579 
 580         switch (sk->nr->state) {
 581 
 582                 case NR_STATE_0:
 583                         sk->state     = TCP_CLOSE;
 584                         sk->state_change(sk);
 585                         sk->dead      = 1;
 586                         nr_destroy_socket(sk);
 587                         break;
 588 
 589                 case NR_STATE_1:
 590                         sk->nr->state = NR_STATE_0;
 591                         sk->state     = TCP_CLOSE;
 592                         sk->state_change(sk);
 593                         sk->dead      = 1;
 594                         nr_destroy_socket(sk);
 595                         break;
 596 
 597                 case NR_STATE_2:
 598                         nr_write_internal(sk, NR_DISCACK);
 599                         sk->nr->state = NR_STATE_0;
 600                         sk->state     = TCP_CLOSE;
 601                         sk->state_change(sk);
 602                         sk->dead      = 1;
 603                         nr_destroy_socket(sk);
 604                         break;                  
 605 
 606                 case NR_STATE_3:
 607                         nr_clear_queues(sk);
 608                         sk->nr->n2count = 0;
 609                         nr_write_internal(sk, NR_DISCREQ);
 610                         sk->nr->t1timer = sk->nr->t1 = nr_calculate_t1(sk);
 611                         sk->nr->t2timer = 0;
 612                         sk->nr->t4timer = 0;
 613                         sk->nr->state   = NR_STATE_2;
 614                         sk->state       = TCP_CLOSE;
 615                         sk->state_change(sk);
 616                         sk->dead        = 1;
 617                         sk->destroy     = 1;
 618                         break;
 619 
 620                 default:
 621                         break;
 622         }
 623 
 624         sock->data = NULL;      
 625         sk->socket = NULL;      /* Not used, but we should do this. **/
 626 
 627         return 0;
 628 }
 629 
 630 static int nr_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
     /* [previous][next][first][last][top][bottom][index][help] */
 631 {
 632         struct sock *sk;
 633         struct full_sockaddr_ax25 *addr = (struct full_sockaddr_ax25 *)uaddr;
 634         struct device *dev;
 635         ax25_address *user, *source;
 636         
 637         sk = (struct sock *)sock->data;
 638 
 639         if (sk->zapped == 0)
 640                 return -EIO;
 641                 
 642         if (addr_len != sizeof(struct sockaddr_ax25) && addr_len != sizeof(struct full_sockaddr_ax25))
 643                 return -EINVAL;
 644 
 645         if ((dev = nr_dev_get(&addr->fsa_ax25.sax25_call)) == NULL) {
 646                 if (sk->debug)
 647                         printk("NET/ROM: bind failed: invalid node callsign\n");
 648                 return -EADDRNOTAVAIL;
 649         }
 650 
 651         /*
 652          * Only the super user can set an arbitrary user callsign.
 653          */
 654         if (addr->fsa_ax25.sax25_ndigis == 1) {
 655                 if (!suser())
 656                         return -EPERM;
 657                 sk->nr->user_addr   = addr->fsa_digipeater[0];
 658                 sk->nr->source_addr = addr->fsa_ax25.sax25_call;
 659         } else {
 660                 source = &addr->fsa_ax25.sax25_call;
 661 
 662                 if ((user = ax25_findbyuid(current->euid)) == NULL) {
 663                         if (ax25_uid_policy && !suser())
 664                                 return -EPERM;
 665                         user = source;
 666                 }
 667 
 668                 sk->nr->user_addr   = *user;
 669                 sk->nr->source_addr = *source;
 670         }
 671 
 672         sk->nr->device = dev;
 673         nr_insert_socket(sk);
 674 
 675         sk->zapped = 0;
 676 
 677         if (sk->debug)
 678                 printk("NET/ROM: socket is bound\n");
 679 
 680         return 0;
 681 }
 682 
 683 static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
     /* [previous][next][first][last][top][bottom][index][help] */
 684         int addr_len, int flags)
 685 {
 686         struct sock *sk = (struct sock *)sock->data;
 687         struct sockaddr_ax25 *addr = (struct sockaddr_ax25 *)uaddr;
 688         ax25_address *user, *source = NULL;
 689         struct device *dev;
 690         
 691         if (sk->state == TCP_ESTABLISHED && sock->state == SS_CONNECTING) {
 692                 sock->state = SS_CONNECTED;
 693                 return 0;       /* Connect completed during a ERESTARTSYS event */
 694         }
 695         
 696         if (sk->state == TCP_CLOSE && sock->state == SS_CONNECTING) {
 697                 sock->state = SS_UNCONNECTED;
 698                 return -ECONNREFUSED;
 699         }
 700         
 701         if (sk->state == TCP_ESTABLISHED)
 702                 return -EISCONN;        /* No reconnect on a seqpacket socket */
 703                 
 704         sk->state   = TCP_CLOSE;        
 705         sock->state = SS_UNCONNECTED;
 706 
 707         if (addr_len != sizeof(struct sockaddr_ax25))
 708                 return -EINVAL;
 709 
 710         if (sk->zapped) {       /* Must bind first - autobinding in this may or may not work */
 711                 sk->zapped = 0;
 712 
 713                 if ((dev = nr_dev_first()) == NULL)
 714                         return -ENETUNREACH;
 715 
 716                 source = (ax25_address *)dev->dev_addr;
 717 
 718                 if ((user = ax25_findbyuid(current->euid)) == NULL) {
 719                         if (ax25_uid_policy && !suser())
 720                                 return -EPERM;
 721                         user = source;
 722                 }
 723 
 724                 sk->nr->user_addr   = *user;
 725                 sk->nr->source_addr = *source;
 726                 sk->nr->device      = dev;
 727 
 728                 nr_insert_socket(sk);           /* Finish the bind */
 729         }
 730 
 731         sk->nr->dest_addr = addr->sax25_call;
 732 
 733         while (nr_find_socket((unsigned char)circuit / 256, (unsigned char)circuit % 256) != NULL)
 734                 circuit++;
 735 
 736         sk->nr->my_index = circuit / 256;
 737         sk->nr->my_id    = circuit % 256;
 738 
 739         circuit++;
 740         
 741         /* Move to connecting socket, start sending Connect Requests */
 742         sock->state   = SS_CONNECTING;
 743         sk->state     = TCP_SYN_SENT;
 744         nr_establish_data_link(sk);
 745         sk->nr->state = NR_STATE_1;
 746         nr_set_timer(sk);
 747         
 748         /* Now the loop */
 749         if (sk->state != TCP_ESTABLISHED && (flags & O_NONBLOCK))
 750                 return -EINPROGRESS;
 751                 
 752         cli();  /* To avoid races on the sleep */
 753 
 754         /*
 755          * A Connect Ack with Choke or timeout or failed routing will go to closed.
 756          */
 757         while (sk->state == TCP_SYN_SENT) {
 758                 interruptible_sleep_on(sk->sleep);
 759                 if (current->signal & ~current->blocked) {
 760                         sti();
 761                         return -ERESTARTSYS;
 762                 }
 763         }
 764 
 765         if (sk->state != TCP_ESTABLISHED) {
 766                 sti();
 767                 sock->state = SS_UNCONNECTED;
 768                 return sock_error(sk);  /* Always set at this point */
 769         }
 770         
 771         sock->state = SS_CONNECTED;
 772 
 773         sti();
 774         
 775         return 0;
 776 }
 777         
 778 static int nr_socketpair(struct socket *sock1, struct socket *sock2)
     /* [previous][next][first][last][top][bottom][index][help] */
 779 {
 780         return -EOPNOTSUPP;
 781 }
 782 
 783 static int nr_accept(struct socket *sock, struct socket *newsock, int flags)
     /* [previous][next][first][last][top][bottom][index][help] */
 784 {
 785         struct sock *sk;
 786         struct sock *newsk;
 787         struct sk_buff *skb;
 788 
 789         if (newsock->data)
 790                 sk_free(newsock->data);
 791 
 792         newsock->data = NULL;
 793         
 794         sk = (struct sock *)sock->data;
 795 
 796         if (sk->type != SOCK_SEQPACKET)
 797                 return -EOPNOTSUPP;
 798         
 799         if (sk->state != TCP_LISTEN)
 800                 return -EINVAL;
 801                 
 802         /*
 803          *      The write queue this time is holding sockets ready to use
 804          *      hooked into the SABM we saved
 805          */
 806         do {
 807                 cli();
 808                 if ((skb = skb_dequeue(&sk->receive_queue)) == NULL) {
 809                         if (flags & O_NONBLOCK) {
 810                                 sti();
 811                                 return 0;
 812                         }
 813                         interruptible_sleep_on(sk->sleep);
 814                         if (current->signal & ~current->blocked) {
 815                                 sti();
 816                                 return -ERESTARTSYS;
 817                         }
 818                 }
 819         } while (skb == NULL);
 820 
 821         newsk = skb->sk;
 822         newsk->pair = NULL;
 823         sti();
 824 
 825         /* Now attach up the new socket */
 826         skb->sk = NULL;
 827         kfree_skb(skb, FREE_READ);
 828         sk->ack_backlog--;
 829         newsock->data = newsk;
 830 
 831         return 0;
 832 }
 833 
 834 static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
     /* [previous][next][first][last][top][bottom][index][help] */
 835         int *uaddr_len, int peer)
 836 {
 837         struct full_sockaddr_ax25 *sax = (struct full_sockaddr_ax25 *)uaddr;
 838         struct sock *sk;
 839         
 840         sk = (struct sock *)sock->data;
 841         
 842         if (peer != 0) {
 843                 if (sk->state != TCP_ESTABLISHED)
 844                         return -ENOTCONN;
 845                 sax->fsa_ax25.sax25_family = AF_NETROM;
 846                 sax->fsa_ax25.sax25_ndigis = 1;
 847                 sax->fsa_ax25.sax25_call = sk->nr->user_addr;
 848                 sax->fsa_digipeater[0]   = sk->nr->dest_addr;
 849                 *uaddr_len = sizeof(struct sockaddr_ax25) + AX25_ADDR_LEN;
 850         } else {
 851                 sax->fsa_ax25.sax25_family = AF_NETROM;
 852                 sax->fsa_ax25.sax25_ndigis = 0;
 853                 sax->fsa_ax25.sax25_call   = sk->nr->source_addr;
 854                 *uaddr_len = sizeof(struct sockaddr_ax25);
 855         }
 856 
 857         return 0;
 858 }
 859  
 860 int nr_rx_frame(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 861 {
 862         struct sock *sk;
 863         struct sock *make;      
 864         ax25_address *src, *dest, *user;
 865         unsigned short circuit_index, circuit_id;
 866         unsigned short frametype, window, timeout;
 867         
 868 
 869         skb->sk = NULL;         /* Initially we don't know who its for */
 870 
 871         /*
 872          *      skb->data points to the netrom frame start
 873          */
 874         
 875         src  = (ax25_address *)(skb->data + 0);
 876         dest = (ax25_address *)(skb->data + 7);
 877 
 878         circuit_index = skb->data[15];
 879         circuit_id    = skb->data[16];
 880         frametype     = skb->data[19];
 881 
 882 #ifdef CONFIG_INET
 883         /*
 884          * Check for an incoming IP over NET/ROM frame.
 885          */
 886          if ((frametype & 0x0F) == NR_PROTOEXT && circuit_index == NR_PROTO_IP && circuit_id == NR_PROTO_IP) {
 887                 skb_pull(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
 888                 skb->h.raw = skb->data;
 889 
 890                 return nr_rx_ip(skb, dev);
 891          }
 892 #endif
 893 
 894         /*
 895          * Find an existing socket connection, based on circuit ID, if its
 896          * a Connect Request base it on their circuit ID.
 897          */
 898         if (((frametype & 0x0F) != NR_CONNREQ && (sk = nr_find_socket(circuit_index, circuit_id)) != NULL) ||
 899             ((frametype & 0x0F) == NR_CONNREQ && (sk = nr_find_peer(circuit_index, circuit_id)) != NULL)) {
 900                 skb->h.raw = skb->data;
 901 
 902                 if ((frametype & 0x0F) == NR_CONNACK && skb->len == 22)
 903                         sk->nr->bpqext = 1;
 904                 else
 905                         sk->nr->bpqext = 0;
 906 
 907                 return nr_process_rx_frame(sk, skb);
 908         }
 909 
 910         if ((frametype & 0x0F) != NR_CONNREQ)
 911                 return 0;
 912                 
 913         sk = nr_find_listener(dest);
 914 
 915         user = (ax25_address *)(skb->data + 21);
 916 
 917         if (sk == NULL || sk->ack_backlog == sk->max_ack_backlog || (make = nr_make_new(sk)) == NULL) {
 918                 nr_transmit_dm(skb);
 919                 return 0;
 920         }
 921 
 922         window = skb->data[20];
 923 
 924         skb->sk             = make;
 925         make->state         = TCP_ESTABLISHED;
 926 
 927         /* Fill in his circuit details */
 928         make->nr->source_addr = *dest;
 929         make->nr->dest_addr   = *src;
 930         make->nr->user_addr   = *user;
 931 
 932         make->nr->your_index = circuit_index;
 933         make->nr->your_id    = circuit_id;
 934 
 935         make->nr->my_index   = circuit / 256;
 936         make->nr->my_id      = circuit % 256;
 937         
 938         circuit++;
 939 
 940         /* Window negotiation */
 941         if (window < make->window)
 942                 make->window = window;
 943 
 944         /* L4 timeout negotiation */
 945         if (skb->len == 37) {
 946                 timeout = skb->data[36] * 256 + skb->data[35];
 947                 if (timeout * PR_SLOWHZ < make->nr->rtt * 2)
 948                         make->nr->rtt = (timeout * PR_SLOWHZ) / 2;
 949                 make->nr->bpqext = 1;
 950         } else {
 951                 make->nr->bpqext = 0;
 952         }
 953 
 954         nr_write_internal(make, NR_CONNACK);
 955 
 956         make->nr->condition = 0x00;
 957         make->nr->vs        = 0;
 958         make->nr->va        = 0;
 959         make->nr->vr        = 0;
 960         make->nr->vl        = 0;
 961         make->nr->state     = NR_STATE_3;
 962         sk->ack_backlog++;
 963         make->pair = sk;
 964 
 965         nr_insert_socket(make);
 966 
 967         skb_queue_head(&sk->receive_queue, skb);
 968 
 969         nr_set_timer(make);
 970 
 971         if (!sk->dead)
 972                 sk->data_ready(sk, skb->len);
 973 
 974         return 1;
 975 }
 976 
 977 static int nr_sendmsg(struct socket *sock, struct msghdr *msg, int len, int noblock, int flags)
     /* [previous][next][first][last][top][bottom][index][help] */
 978 {
 979         struct sock *sk = (struct sock *)sock->data;
 980         struct sockaddr_ax25 *usax = (struct sockaddr_ax25 *)msg->msg_name;
 981         int err;
 982         struct sockaddr_ax25 sax;
 983         struct sk_buff *skb;
 984         unsigned char *asmptr;
 985         int size;
 986         
 987         if (sk->err)
 988                 return sock_error(sk);
 989 
 990         if (flags)
 991                 return -EINVAL;
 992 
 993         if (sk->zapped)
 994                 return -EADDRNOTAVAIL;
 995 
 996         if (sk->nr->device == NULL)
 997                 return -ENETUNREACH;
 998                 
 999         if (usax) {
1000                 if (msg->msg_namelen < sizeof(sax))
1001                         return -EINVAL;
1002                 sax = *usax;
1003                 if (ax25cmp(&sk->nr->dest_addr, &sax.sax25_call) != 0)
1004                         return -EISCONN;
1005                 if (sax.sax25_family != AF_NETROM)
1006                         return -EINVAL;
1007         } else {
1008                 if (sk->state != TCP_ESTABLISHED)
1009                         return -ENOTCONN;
1010                 sax.sax25_family = AF_NETROM;
1011                 sax.sax25_call   = sk->nr->dest_addr;
1012         }
1013         
1014         if (sk->debug)
1015                 printk("NET/ROM: sendto: Addresses built.\n");
1016 
1017         /* Build a packet */
1018         if (sk->debug)
1019                 printk("NET/ROM: sendto: building packet.\n");
1020 
1021         size = len + AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + NR_NETWORK_LEN + NR_TRANSPORT_LEN;
1022 
1023         if ((skb = sock_alloc_send_skb(sk, size, 0, 0, &err)) == NULL)
1024                 return err;
1025 
1026         skb->sk   = sk;
1027         skb->free = 1;
1028         skb->arp  = 1;
1029 
1030         skb_reserve(skb, size - len);
1031         
1032         /*
1033          *      Push down the NET/ROM header
1034          */
1035 
1036         asmptr = skb_push(skb, NR_TRANSPORT_LEN);
1037 
1038         if (sk->debug)
1039                 printk("Building NET/ROM Header.\n");
1040 
1041         /* Build a NET/ROM Transport header */
1042 
1043         *asmptr++ = sk->nr->your_index;
1044         *asmptr++ = sk->nr->your_id;
1045         *asmptr++ = 0;          /* To be filled in later */
1046         *asmptr++ = 0;          /*      Ditto            */
1047         *asmptr++ = NR_INFO;
1048         
1049         if (sk->debug)
1050                 printk("Built header.\n");
1051 
1052         /*
1053          *      Put the data on the end
1054          */
1055 
1056         skb->h.raw = skb_put(skb, len);
1057 
1058         asmptr = skb->h.raw;
1059         
1060         if (sk->debug)
1061                 printk("NET/ROM: Appending user data\n");
1062 
1063         /* User data follows immediately after the NET/ROM transport header */
1064         memcpy_fromiovec(asmptr, msg->msg_iov, len);
1065 
1066         if (sk->debug)
1067                 printk("NET/ROM: Transmitting buffer\n");
1068 
1069         if (sk->state != TCP_ESTABLISHED) {
1070                 kfree_skb(skb, FREE_WRITE);
1071                 return -ENOTCONN;
1072         }
1073 
1074         nr_output(sk, skb);     /* Shove it onto the queue */
1075 
1076         return len;
1077 }
1078 
1079 
1080 static int nr_recvmsg(struct socket *sock, struct msghdr *msg, int size, int noblock,
     /* [previous][next][first][last][top][bottom][index][help] */
1081                    int flags, int *addr_len)
1082 {
1083         struct sock *sk = (struct sock *)sock->data;
1084         struct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;
1085         int copied;
1086         struct sk_buff *skb;
1087         int er;
1088 
1089         if (sk->err)
1090                 return sock_error(sk);
1091         
1092         if (addr_len != NULL)
1093                 *addr_len = sizeof(*sax);
1094 
1095         /*
1096          * This works for seqpacket too. The receiver has ordered the queue for
1097          * us! We do one quick check first though
1098          */
1099         if (sk->state != TCP_ESTABLISHED)
1100                 return -ENOTCONN;
1101 
1102         /* Now we can treat all alike */
1103         if ((skb = skb_recv_datagram(sk, flags, noblock, &er)) == NULL)
1104                 return er;
1105 
1106         if (!sk->nr->hdrincl) {
1107                 skb_pull(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
1108                 skb->h.raw = skb->data;
1109         }
1110 
1111         copied = (size < skb->len) ? size : skb->len;
1112         skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
1113         
1114         if (sax != NULL) {
1115                 struct sockaddr_ax25 addr;
1116                 
1117                 addr.sax25_family = AF_NETROM;
1118                 memcpy(&addr.sax25_call, skb->data + 7, AX25_ADDR_LEN);
1119 
1120                 *sax = addr;
1121 
1122                 *addr_len = sizeof(*sax);
1123         }
1124 
1125         skb_free_datagram(sk, skb);
1126 
1127         return copied;
1128 }
1129 
1130 static int nr_shutdown(struct socket *sk, int how)
     /* [previous][next][first][last][top][bottom][index][help] */
1131 {
1132         return -EOPNOTSUPP;
1133 }
1134 
1135 static int nr_select(struct socket *sock , int sel_type, select_table *wait)
     /* [previous][next][first][last][top][bottom][index][help] */
1136 {
1137         struct sock *sk = (struct sock *)sock->data;
1138 
1139         return datagram_select(sk, sel_type, wait);
1140 }
1141 
1142 static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
     /* [previous][next][first][last][top][bottom][index][help] */
1143 {
1144         struct sock *sk = (struct sock *)sock->data;
1145         int err;
1146         long amount = 0;
1147 
1148         switch (cmd) {
1149                 case TIOCOUTQ:
1150                         if ((err = verify_area(VERIFY_WRITE, (void *)arg, sizeof(unsigned long))) != 0)
1151                                 return err;
1152                         amount = sk->sndbuf - sk->wmem_alloc;
1153                         if (amount < 0)
1154                                 amount = 0;
1155                         put_fs_long(amount, (unsigned long *)arg);
1156                         return 0;
1157 
1158                 case TIOCINQ: {
1159                         struct sk_buff *skb;
1160                         /* These two are safe on a single CPU system as only user tasks fiddle here */
1161                         if ((skb = skb_peek(&sk->receive_queue)) != NULL)
1162                                 amount = skb->len - 20;
1163                         if ((err = verify_area(VERIFY_WRITE, (void *)arg, sizeof(unsigned long))) != 0)
1164                                 return err;
1165                         put_fs_long(amount, (unsigned long *)arg);
1166                         return 0;
1167                 }
1168 
1169                 case SIOCGSTAMP:
1170                         if (sk != NULL) {
1171                                 if (sk->stamp.tv_sec==0)
1172                                         return -ENOENT;
1173                                 if ((err = verify_area(VERIFY_WRITE,(void *)arg,sizeof(struct timeval))) != 0)
1174                                         return err;
1175                                 memcpy_tofs((void *)arg, &sk->stamp, sizeof(struct timeval));
1176                                 return 0;
1177                         }
1178                         return -EINVAL;
1179 
1180                 case SIOCGIFADDR:
1181                 case SIOCSIFADDR:
1182                 case SIOCGIFDSTADDR:
1183                 case SIOCSIFDSTADDR:
1184                 case SIOCGIFBRDADDR:
1185                 case SIOCSIFBRDADDR:
1186                 case SIOCGIFNETMASK:
1187                 case SIOCSIFNETMASK:
1188                 case SIOCGIFMETRIC:
1189                 case SIOCSIFMETRIC:
1190                         return -EINVAL;
1191 
1192                 case SIOCADDRT:
1193                 case SIOCDELRT:
1194                 case SIOCNRDECOBS:
1195                 case SIOCNRRTCTL:
1196                         if (!suser()) return -EPERM;
1197                         return nr_rt_ioctl(cmd, (void *)arg);
1198 
1199                 case SIOCNRGETPARMS: {
1200                         struct nr_parms_struct nr_parms;
1201                         if ((err = verify_area(VERIFY_WRITE, (void *)arg, sizeof(struct nr_parms_struct))) != 0)
1202                                 return err;
1203                         memcpy_fromfs(&nr_parms, (void *)arg, sizeof(struct nr_parms_struct));
1204                         nr_parms = nr_default;
1205                         memcpy_tofs((void *)arg, &nr_parms, sizeof(struct nr_parms_struct));
1206                         return 0;
1207                 }
1208 
1209                 case SIOCNRSETPARMS: {
1210                         struct nr_parms_struct nr_parms;
1211                         if (!suser()) return -EPERM;
1212                         if ((err = verify_area(VERIFY_READ, (void *)arg, sizeof(struct nr_parms_struct))) != 0)
1213                                 return err;
1214                         memcpy_fromfs(&nr_parms, (void *)arg, sizeof(struct nr_parms_struct));
1215                         nr_default = nr_parms;
1216                         return 0;
1217                 }
1218                 
1219                 default:
1220                         return dev_ioctl(cmd, (void *)arg);
1221         }
1222 
1223         /*NOTREACHED*/
1224         return(0);
1225 }
1226 
1227 static int nr_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
1228 {
1229         struct sock *s;
1230         struct device *dev;
1231         const char *devname;
1232         int len = 0;
1233         off_t pos = 0;
1234         off_t begin = 0;
1235   
1236         cli();
1237 
1238         len += sprintf(buffer, "user_addr dest_node src_node  dev    my  your  st vs vr va    t1     t2    n2  rtt wnd Snd-Q Rcv-Q\n");
1239 
1240         for (s = nr_list; s != NULL; s = s->next) {
1241                 if ((dev = s->nr->device) == NULL)
1242                         devname = "???";
1243                 else
1244                         devname = dev->name;
1245         
1246                 len += sprintf(buffer + len, "%-9s ",
1247                         ax2asc(&s->nr->user_addr));
1248                 len += sprintf(buffer + len, "%-9s ",
1249                         ax2asc(&s->nr->dest_addr));
1250                 len += sprintf(buffer + len, "%-9s %-3s  %02X/%02X %02X/%02X %2d %2d %2d %2d %3d/%03d %2d/%02d %2d/%02d %3d %3d %5d %5d\n",
1251                         ax2asc(&s->nr->source_addr),
1252                         devname, s->nr->my_index, s->nr->my_id,
1253                         s->nr->your_index, s->nr->your_id,
1254                         s->nr->state,
1255                         s->nr->vs, s->nr->vr, s->nr->va,
1256                         s->nr->t1timer / PR_SLOWHZ,
1257                         s->nr->t1      / PR_SLOWHZ,
1258                         s->nr->t2timer / PR_SLOWHZ,
1259                         s->nr->t2      / PR_SLOWHZ,
1260                         s->nr->n2count, s->nr->n2,
1261                         s->nr->rtt     / PR_SLOWHZ,
1262                         s->window,
1263                         s->wmem_alloc, s->rmem_alloc);
1264                 
1265                 pos = begin + len;
1266 
1267                 if (pos < offset) {
1268                         len   = 0;
1269                         begin = pos;
1270                 }
1271                 
1272                 if (pos > offset + length)
1273                         break;
1274         }
1275 
1276         sti();
1277 
1278         *start = buffer + (offset - begin);
1279         len   -= (offset - begin);
1280 
1281         if (len > length) len = length;
1282 
1283         return(len);
1284 } 
1285 
1286 static struct proto_ops nr_proto_ops = {
1287         AF_NETROM,
1288         
1289         nr_create,
1290         nr_dup,
1291         nr_release,
1292         nr_bind,
1293         nr_connect,
1294         nr_socketpair,
1295         nr_accept,
1296         nr_getname,
1297         nr_select,
1298         nr_ioctl,
1299         nr_listen,
1300         nr_shutdown,
1301         nr_setsockopt,
1302         nr_getsockopt,
1303         nr_fcntl,
1304         nr_sendmsg,
1305         nr_recvmsg
1306 };
1307 
1308 static struct notifier_block nr_dev_notifier = {
1309         nr_device_event,
1310         0
1311 };
1312 
1313 void nr_proto_init(struct net_proto *pro)
     /* [previous][next][first][last][top][bottom][index][help] */
1314 {
1315         sock_register(nr_proto_ops.family, &nr_proto_ops);
1316         register_netdevice_notifier(&nr_dev_notifier);
1317         printk("G4KLX NET/ROM for Linux. Version 0.4 ALPHA for AX25.032 Linux 1.3.77\n");
1318 
1319         nr_default.quality    = NR_DEFAULT_QUAL;
1320         nr_default.obs_count  = NR_DEFAULT_OBS;
1321         nr_default.ttl        = NR_DEFAULT_TTL;
1322         nr_default.timeout    = NR_DEFAULT_T1;
1323         nr_default.ack_delay  = NR_DEFAULT_T2;
1324         nr_default.busy_delay = NR_DEFAULT_T4;
1325         nr_default.tries      = NR_DEFAULT_N2;
1326         nr_default.window     = NR_DEFAULT_WINDOW;
1327 
1328         proc_net_register(&(struct proc_dir_entry) {
1329                 PROC_NET_NR, 2, "nr",
1330                 S_IFREG | S_IRUGO, 1, 0, 0,
1331                 0, &proc_net_inode_operations, 
1332                 nr_get_info
1333         });
1334         proc_net_register(&(struct proc_dir_entry) {
1335                 PROC_NET_NR_NEIGH, 8, "nr_neigh",
1336                 S_IFREG | S_IRUGO, 1, 0, 0,
1337                 0, &proc_net_inode_operations, 
1338                 nr_neigh_get_info
1339         });
1340         proc_net_register(&(struct proc_dir_entry) {
1341                 PROC_NET_NR_NODES, 8, "nr_nodes",
1342                 S_IFREG | S_IRUGO, 1, 0, 0,
1343                 0, &proc_net_inode_operations, 
1344                 nr_nodes_get_info
1345         });
1346 }
1347 
1348 #endif

/* [previous][next][first][last][top][bottom][index][help] */