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_destory_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->dead          = 0;
 436         sk->next          = NULL;
 437         sk->broadcast     = 0;
 438         sk->allocation    = GFP_KERNEL;
 439         sk->rcvbuf        = SK_RMEM_MAX;
 440         sk->sndbuf        = SK_WMEM_MAX;
 441         sk->wmem_alloc    = 0;
 442         sk->rmem_alloc    = 0;
 443         sk->users         = 0;
 444         sk->debug         = 0;
 445         sk->destroy       = 0;
 446         sk->prot          = NULL;       /* So we use default free mechanisms */
 447         sk->err           = 0;
 448         sk->localroute    = 0;
 449         sk->send_head     = NULL;
 450         sk->state         = TCP_CLOSE;
 451         sk->shutdown      = 0;
 452         sk->priority      = SOPRI_NORMAL;
 453         sk->ack_backlog   = 0;
 454         sk->mtu           = NETROM_MTU; /* 236 */
 455         sk->zapped        = 1;
 456         sk->window        = nr_default.window;
 457 
 458         sk->state_change = def_callback1;
 459         sk->data_ready   = def_callback2;
 460         sk->write_space  = def_callback1;
 461         sk->error_report = def_callback1;
 462 
 463         if (sock != NULL) {
 464                 sock->data = (void *)sk;
 465                 sk->sleep  = sock->wait;
 466         }
 467 
 468         skb_queue_head_init(&nr->ack_queue);
 469         skb_queue_head_init(&nr->reseq_queue);
 470         skb_queue_head_init(&nr->frag_queue);
 471 
 472         nr->my_index = 0;
 473         nr->my_id    = 0;
 474         nr->rtt      = nr_default.timeout / 2;
 475         nr->t1       = nr_default.timeout;
 476         nr->t2       = nr_default.ack_delay;
 477         nr->n2       = nr_default.tries;
 478 
 479         nr->t1timer  = 0;
 480         nr->t2timer  = 0;
 481         nr->t4timer  = 0;
 482         nr->n2count  = 0;
 483 
 484         nr->va       = 0;
 485         nr->vr       = 0;
 486         nr->vs       = 0;
 487         nr->vl       = 0;
 488 
 489         nr->your_index = 0;
 490         nr->your_id    = 0;
 491 
 492         nr->my_index   = 0;
 493         nr->my_id      = 0;
 494 
 495         nr->bpqext     = 1;
 496         nr->fraglen    = 0;
 497         nr->hdrincl    = 0;
 498         nr->state      = NR_STATE_0;
 499         nr->device     = NULL;
 500 
 501         memset(&nr->source_addr, '\0', AX25_ADDR_LEN);
 502         memset(&nr->user_addr,   '\0', AX25_ADDR_LEN);
 503         memset(&nr->dest_addr,   '\0', AX25_ADDR_LEN);
 504 
 505         nr->sk = sk;
 506         sk->nr = nr;
 507 
 508         return 0;
 509 }
 510 
 511 static struct sock *nr_make_new(struct sock *osk)
     /* [previous][next][first][last][top][bottom][index][help] */
 512 {
 513         struct sock *sk;
 514         nr_cb *nr;
 515 
 516         if (osk->type != SOCK_SEQPACKET)
 517                 return NULL;
 518 
 519         if ((sk = (struct sock *)sk_alloc(GFP_ATOMIC)) == NULL)
 520                 return NULL;
 521 
 522         if ((nr = (nr_cb *)kmalloc(sizeof(*nr), GFP_ATOMIC)) == NULL) {
 523                 sk_free(sk);
 524                 return NULL;
 525         }
 526 
 527         skb_queue_head_init(&sk->receive_queue);
 528         skb_queue_head_init(&sk->write_queue);
 529         skb_queue_head_init(&sk->back_log);
 530 
 531         init_timer(&sk->timer);
 532 
 533         sk->type        = osk->type;
 534         sk->socket      = osk->socket;
 535         sk->dead        = 0;
 536         sk->next        = NULL;
 537         sk->priority    = osk->priority;
 538         sk->broadcast   = 0;
 539         sk->protocol    = osk->protocol;
 540         sk->rcvbuf      = osk->rcvbuf;
 541         sk->sndbuf      = osk->sndbuf;
 542         sk->wmem_alloc  = 0;
 543         sk->rmem_alloc  = 0;
 544         sk->users       = 0;
 545         sk->ack_backlog = 0;
 546         sk->destroy     = 0;
 547         sk->prot        = NULL; /* So we use default free mechanisms */
 548         sk->err         = 0;
 549         sk->localroute  = 0;
 550         sk->send_head   = NULL;
 551         sk->debug       = osk->debug;
 552         sk->state       = TCP_ESTABLISHED;
 553         sk->window      = osk->window;
 554         sk->shutdown    = 0;
 555         sk->mtu         = osk->mtu;
 556         sk->sleep       = osk->sleep;
 557         sk->zapped      = osk->zapped;
 558 
 559         sk->state_change = def_callback1;
 560         sk->data_ready   = def_callback2;
 561         sk->write_space  = def_callback1;
 562         sk->error_report = def_callback1;
 563 
 564         skb_queue_head_init(&nr->ack_queue);
 565         skb_queue_head_init(&nr->reseq_queue);
 566         skb_queue_head_init(&nr->frag_queue);
 567 
 568         nr->rtt      = osk->nr->rtt;
 569         nr->t1       = osk->nr->t1;
 570         nr->t2       = osk->nr->t2;
 571         nr->n2       = osk->nr->n2;
 572 
 573         nr->device   = osk->nr->device;
 574         nr->bpqext   = osk->nr->bpqext;
 575         nr->hdrincl  = osk->nr->hdrincl;
 576         nr->fraglen  = 0;
 577 
 578         nr->t1timer  = 0;
 579         nr->t2timer  = 0;
 580         nr->t4timer  = 0;
 581         nr->n2count  = 0;
 582 
 583         nr->va       = 0;
 584         nr->vr       = 0;
 585         nr->vs       = 0;
 586         nr->vl       = 0;
 587         
 588         sk->nr = nr;
 589         nr->sk = sk;
 590 
 591         return sk;
 592 }
 593 
 594 static int nr_dup(struct socket *newsock, struct socket *oldsock)
     /* [previous][next][first][last][top][bottom][index][help] */
 595 {
 596         struct sock *sk = (struct sock *)oldsock->data;
 597 
 598         return nr_create(newsock, sk->protocol);
 599 }
 600 
 601 static int nr_release(struct socket *sock, struct socket *peer)
     /* [previous][next][first][last][top][bottom][index][help] */
 602 {
 603         struct sock *sk = (struct sock *)sock->data;
 604 
 605         if (sk == NULL) return 0;
 606 
 607         switch (sk->nr->state) {
 608 
 609                 case NR_STATE_0:
 610                         sk->state     = TCP_CLOSE;
 611                         sk->state_change(sk);
 612                         sk->dead      = 1;
 613                         nr_destroy_socket(sk);
 614                         break;
 615 
 616                 case NR_STATE_1:
 617                         sk->nr->state = NR_STATE_0;
 618                         sk->state     = TCP_CLOSE;
 619                         sk->state_change(sk);
 620                         sk->dead      = 1;
 621                         nr_destroy_socket(sk);
 622                         break;
 623 
 624                 case NR_STATE_2:
 625                         nr_write_internal(sk, NR_DISCACK);
 626                         sk->nr->state = NR_STATE_0;
 627                         sk->state     = TCP_CLOSE;
 628                         sk->state_change(sk);
 629                         sk->dead      = 1;
 630                         nr_destroy_socket(sk);
 631                         break;                  
 632 
 633                 case NR_STATE_3:
 634                         nr_clear_queues(sk);
 635                         sk->nr->n2count = 0;
 636                         nr_write_internal(sk, NR_DISCREQ);
 637                         sk->nr->t1timer = sk->nr->t1 = nr_calculate_t1(sk);
 638                         sk->nr->t2timer = 0;
 639                         sk->nr->t4timer = 0;
 640                         sk->nr->state   = NR_STATE_2;
 641                         sk->state       = TCP_CLOSE;
 642                         sk->state_change(sk);
 643                         sk->dead        = 1;
 644                         sk->destroy     = 1;
 645                         break;
 646 
 647                 default:
 648                         break;
 649         }
 650 
 651         sock->data = NULL;      
 652         sk->socket = NULL;      /* Not used, but we should do this. **/
 653 
 654         return 0;
 655 }
 656 
 657 static int nr_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
     /* [previous][next][first][last][top][bottom][index][help] */
 658 {
 659         struct sock *sk;
 660         struct full_sockaddr_ax25 *addr = (struct full_sockaddr_ax25 *)uaddr;
 661         struct device *dev;
 662         ax25_address *user, *source;
 663         
 664         sk = (struct sock *)sock->data;
 665 
 666         if (sk->zapped == 0)
 667                 return -EIO;
 668                 
 669         if (addr_len != sizeof(struct sockaddr_ax25) && addr_len != sizeof(struct full_sockaddr_ax25))
 670                 return -EINVAL;
 671 
 672         if ((dev = nr_dev_get(&addr->fsa_ax25.sax25_call)) == NULL) {
 673                 if (sk->debug)
 674                         printk("NET/ROM: bind failed: invalid node callsign\n");
 675                 return -EADDRNOTAVAIL;
 676         }
 677 
 678         /*
 679          * Only the super user can set an arbitrary user callsign.
 680          */
 681         if (addr->fsa_ax25.sax25_ndigis == 1) {
 682                 if (!suser())
 683                         return -EPERM;
 684                 sk->nr->user_addr   = addr->fsa_digipeater[0];
 685                 sk->nr->source_addr = addr->fsa_ax25.sax25_call;
 686         } else {
 687                 source = &addr->fsa_ax25.sax25_call;
 688 
 689                 if ((user = ax25_findbyuid(current->euid)) == NULL) {
 690                         if (ax25_uid_policy && !suser())
 691                                 return -EPERM;
 692                         user = source;
 693                 }
 694 
 695                 sk->nr->user_addr   = *user;
 696                 sk->nr->source_addr = *source;
 697         }
 698 
 699         sk->nr->device = dev;
 700         nr_insert_socket(sk);
 701 
 702         sk->zapped = 0;
 703 
 704         if (sk->debug)
 705                 printk("NET/ROM: socket is bound\n");
 706 
 707         return 0;
 708 }
 709 
 710 static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
     /* [previous][next][first][last][top][bottom][index][help] */
 711         int addr_len, int flags)
 712 {
 713         struct sock *sk = (struct sock *)sock->data;
 714         struct sockaddr_ax25 *addr = (struct sockaddr_ax25 *)uaddr;
 715         ax25_address *user, *source = NULL;
 716         struct device *dev;
 717         
 718         if (sk->state == TCP_ESTABLISHED && sock->state == SS_CONNECTING) {
 719                 sock->state = SS_CONNECTED;
 720                 return 0;       /* Connect completed during a ERESTARTSYS event */
 721         }
 722         
 723         if (sk->state == TCP_CLOSE && sock->state == SS_CONNECTING) {
 724                 sock->state = SS_UNCONNECTED;
 725                 return -ECONNREFUSED;
 726         }
 727         
 728         if (sk->state == TCP_ESTABLISHED)
 729                 return -EISCONN;        /* No reconnect on a seqpacket socket */
 730                 
 731         sk->state   = TCP_CLOSE;        
 732         sock->state = SS_UNCONNECTED;
 733 
 734         if (addr_len != sizeof(struct sockaddr_ax25))
 735                 return -EINVAL;
 736 
 737         if (sk->zapped) {       /* Must bind first - autobinding in this may or may not work */
 738                 sk->zapped = 0;
 739 
 740                 if ((dev = nr_dev_first()) == NULL)
 741                         return -ENETUNREACH;
 742 
 743                 source = (ax25_address *)dev->dev_addr;
 744 
 745                 if ((user = ax25_findbyuid(current->euid)) == NULL) {
 746                         if (ax25_uid_policy && !suser())
 747                                 return -EPERM;
 748                         user = source;
 749                 }
 750 
 751                 sk->nr->user_addr   = *user;
 752                 sk->nr->source_addr = *source;
 753                 sk->nr->device      = dev;
 754 
 755                 nr_insert_socket(sk);           /* Finish the bind */
 756         }
 757 
 758         sk->nr->dest_addr = addr->sax25_call;
 759 
 760         while (nr_find_socket((unsigned char)circuit / 256, (unsigned char)circuit % 256) != NULL)
 761                 circuit++;
 762 
 763         sk->nr->my_index = circuit / 256;
 764         sk->nr->my_id    = circuit % 256;
 765 
 766         circuit++;
 767         
 768         /* Move to connecting socket, start sending Connect Requests */
 769         sock->state   = SS_CONNECTING;
 770         sk->state     = TCP_SYN_SENT;
 771         nr_establish_data_link(sk);
 772         sk->nr->state = NR_STATE_1;
 773         nr_set_timer(sk);
 774         
 775         /* Now the loop */
 776         if (sk->state != TCP_ESTABLISHED && (flags & O_NONBLOCK))
 777                 return -EINPROGRESS;
 778                 
 779         cli();  /* To avoid races on the sleep */
 780 
 781         /*
 782          * A Connect Ack with Choke or timeout or failed routing will go to closed.
 783          */
 784         while (sk->state == TCP_SYN_SENT) {
 785                 interruptible_sleep_on(sk->sleep);
 786                 if (current->signal & ~current->blocked) {
 787                         sti();
 788                         return -ERESTARTSYS;
 789                 }
 790         }
 791 
 792         if (sk->state != TCP_ESTABLISHED) {
 793                 sti();
 794                 sock->state = SS_UNCONNECTED;
 795                 return sock_error(sk);  /* Always set at this point */
 796         }
 797         
 798         sock->state = SS_CONNECTED;
 799 
 800         sti();
 801         
 802         return 0;
 803 }
 804         
 805 static int nr_socketpair(struct socket *sock1, struct socket *sock2)
     /* [previous][next][first][last][top][bottom][index][help] */
 806 {
 807         return -EOPNOTSUPP;
 808 }
 809 
 810 static int nr_accept(struct socket *sock, struct socket *newsock, int flags)
     /* [previous][next][first][last][top][bottom][index][help] */
 811 {
 812         struct sock *sk;
 813         struct sock *newsk;
 814         struct sk_buff *skb;
 815 
 816         if (newsock->data)
 817                 sk_free(newsock->data);
 818 
 819         newsock->data = NULL;
 820         
 821         sk = (struct sock *)sock->data;
 822 
 823         if (sk->type != SOCK_SEQPACKET)
 824                 return -EOPNOTSUPP;
 825         
 826         if (sk->state != TCP_LISTEN)
 827                 return -EINVAL;
 828                 
 829         /*
 830          *      The write queue this time is holding sockets ready to use
 831          *      hooked into the SABM we saved
 832          */
 833         do {
 834                 cli();
 835                 if ((skb = skb_dequeue(&sk->receive_queue)) == NULL) {
 836                         if (flags & O_NONBLOCK) {
 837                                 sti();
 838                                 return 0;
 839                         }
 840                         interruptible_sleep_on(sk->sleep);
 841                         if (current->signal & ~current->blocked) {
 842                                 sti();
 843                                 return -ERESTARTSYS;
 844                         }
 845                 }
 846         } while (skb == NULL);
 847 
 848         newsk = skb->sk;
 849         newsk->pair = NULL;
 850         sti();
 851 
 852         /* Now attach up the new socket */
 853         skb->sk = NULL;
 854         kfree_skb(skb, FREE_READ);
 855         sk->ack_backlog--;
 856         newsock->data = newsk;
 857 
 858         return 0;
 859 }
 860 
 861 static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
     /* [previous][next][first][last][top][bottom][index][help] */
 862         int *uaddr_len, int peer)
 863 {
 864         struct full_sockaddr_ax25 *sax = (struct full_sockaddr_ax25 *)uaddr;
 865         struct sock *sk;
 866         
 867         sk = (struct sock *)sock->data;
 868         
 869         if (peer != 0) {
 870                 if (sk->state != TCP_ESTABLISHED)
 871                         return -ENOTCONN;
 872                 sax->fsa_ax25.sax25_family = AF_NETROM;
 873                 sax->fsa_ax25.sax25_ndigis = 1;
 874                 sax->fsa_ax25.sax25_call = sk->nr->user_addr;
 875                 sax->fsa_digipeater[0]   = sk->nr->dest_addr;
 876                 *uaddr_len = sizeof(struct sockaddr_ax25) + AX25_ADDR_LEN;
 877         } else {
 878                 sax->fsa_ax25.sax25_family = AF_NETROM;
 879                 sax->fsa_ax25.sax25_ndigis = 0;
 880                 sax->fsa_ax25.sax25_call   = sk->nr->source_addr;
 881                 *uaddr_len = sizeof(struct sockaddr_ax25);
 882         }
 883 
 884         return 0;
 885 }
 886  
 887 int nr_rx_frame(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
 888 {
 889         struct sock *sk;
 890         struct sock *make;      
 891         ax25_address *src, *dest, *user;
 892         unsigned short circuit_index, circuit_id;
 893         unsigned short frametype, window, timeout;
 894         
 895 
 896         skb->sk = NULL;         /* Initially we don't know who its for */
 897 
 898         /*
 899          *      skb->data points to the netrom frame start
 900          */
 901         
 902         src  = (ax25_address *)(skb->data + 0);
 903         dest = (ax25_address *)(skb->data + 7);
 904 
 905         circuit_index = skb->data[15];
 906         circuit_id    = skb->data[16];
 907         frametype     = skb->data[19];
 908 
 909 #ifdef CONFIG_INET
 910         /*
 911          * Check for an incoming IP over NET/ROM frame.
 912          */
 913          if ((frametype & 0x0F) == NR_PROTOEXT && circuit_index == NR_PROTO_IP && circuit_id == NR_PROTO_IP) {
 914                 skb_pull(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
 915                 skb->h.raw = skb->data;
 916 
 917                 return nr_rx_ip(skb, dev);
 918          }
 919 #endif
 920 
 921         /*
 922          * Find an existing socket connection, based on circuit ID, if its
 923          * a Connect Request base it on their circuit ID.
 924          */
 925         if (((frametype & 0x0F) != NR_CONNREQ && (sk = nr_find_socket(circuit_index, circuit_id)) != NULL) ||
 926             ((frametype & 0x0F) == NR_CONNREQ && (sk = nr_find_peer(circuit_index, circuit_id)) != NULL)) {
 927                 skb->h.raw = skb->data;
 928 
 929                 if ((frametype & 0x0F) == NR_CONNACK && skb->len == 22)
 930                         sk->nr->bpqext = 1;
 931                 else
 932                         sk->nr->bpqext = 0;
 933 
 934                 return nr_process_rx_frame(sk, skb);
 935         }
 936 
 937         if ((frametype & 0x0F) != NR_CONNREQ)
 938                 return 0;
 939                 
 940         sk = nr_find_listener(dest);
 941 
 942         user = (ax25_address *)(skb->data + 21);
 943 
 944         if (sk == NULL || sk->ack_backlog == sk->max_ack_backlog || (make = nr_make_new(sk)) == NULL) {
 945                 nr_transmit_dm(skb);
 946                 return 0;
 947         }
 948 
 949         window = skb->data[20];
 950 
 951         skb->sk             = make;
 952         make->state         = TCP_ESTABLISHED;
 953 
 954         /* Fill in his circuit details */
 955         make->nr->source_addr = *dest;
 956         make->nr->dest_addr   = *src;
 957         make->nr->user_addr   = *user;
 958 
 959         make->nr->your_index = circuit_index;
 960         make->nr->your_id    = circuit_id;
 961 
 962         make->nr->my_index   = circuit / 256;
 963         make->nr->my_id      = circuit % 256;
 964         
 965         circuit++;
 966 
 967         /* Window negotiation */
 968         if (window < make->window)
 969                 make->window = window;
 970 
 971         /* L4 timeout negotiation */
 972         if (skb->len == 37) {
 973                 timeout = skb->data[36] * 256 + skb->data[35];
 974                 if (timeout * PR_SLOWHZ < make->nr->rtt * 2)
 975                         make->nr->rtt = (timeout * PR_SLOWHZ) / 2;
 976                 make->nr->bpqext = 1;
 977         } else {
 978                 make->nr->bpqext = 0;
 979         }
 980 
 981         nr_write_internal(make, NR_CONNACK);
 982 
 983         make->nr->condition = 0x00;
 984         make->nr->vs        = 0;
 985         make->nr->va        = 0;
 986         make->nr->vr        = 0;
 987         make->nr->vl        = 0;
 988         make->nr->state     = NR_STATE_3;
 989         sk->ack_backlog++;
 990         make->pair = sk;
 991 
 992         nr_insert_socket(make);
 993 
 994         skb_queue_head(&sk->receive_queue, skb);
 995 
 996         nr_set_timer(make);
 997 
 998         if (!sk->dead)
 999                 sk->data_ready(sk, skb->len);
1000 
1001         return 1;
1002 }
1003 
1004 static int nr_sendmsg(struct socket *sock, struct msghdr *msg, int len, int noblock, int flags)
     /* [previous][next][first][last][top][bottom][index][help] */
1005 {
1006         struct sock *sk = (struct sock *)sock->data;
1007         struct sockaddr_ax25 *usax = (struct sockaddr_ax25 *)msg->msg_name;
1008         int err;
1009         struct sockaddr_ax25 sax;
1010         struct sk_buff *skb;
1011         unsigned char *asmptr;
1012         int size;
1013         
1014         if (sk->err)
1015                 return sock_error(sk);
1016 
1017         if (flags)
1018                 return -EINVAL;
1019 
1020         if (sk->zapped)
1021                 return -EADDRNOTAVAIL;
1022 
1023         if (sk->nr->device == NULL)
1024                 return -ENETUNREACH;
1025                 
1026         if (usax) {
1027                 if (msg->msg_namelen < sizeof(sax))
1028                         return -EINVAL;
1029                 sax = *usax;
1030                 if (ax25cmp(&sk->nr->dest_addr, &sax.sax25_call) != 0)
1031                         return -EISCONN;
1032                 if (sax.sax25_family != AF_NETROM)
1033                         return -EINVAL;
1034         } else {
1035                 if (sk->state != TCP_ESTABLISHED)
1036                         return -ENOTCONN;
1037                 sax.sax25_family = AF_NETROM;
1038                 sax.sax25_call   = sk->nr->dest_addr;
1039         }
1040         
1041         if (sk->debug)
1042                 printk("NET/ROM: sendto: Addresses built.\n");
1043 
1044         /* Build a packet */
1045         if (sk->debug)
1046                 printk("NET/ROM: sendto: building packet.\n");
1047 
1048         size = len + AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + NR_NETWORK_LEN + NR_TRANSPORT_LEN;
1049 
1050         if ((skb = sock_alloc_send_skb(sk, size, 0, 0, &err)) == NULL)
1051                 return err;
1052 
1053         skb->sk   = sk;
1054         skb->free = 1;
1055         skb->arp  = 1;
1056 
1057         skb_reserve(skb, size - len);
1058         
1059         /*
1060          *      Push down the NET/ROM header
1061          */
1062 
1063         asmptr = skb_push(skb, NR_TRANSPORT_LEN);
1064 
1065         if (sk->debug)
1066                 printk("Building NET/ROM Header.\n");
1067 
1068         /* Build a NET/ROM Transport header */
1069 
1070         *asmptr++ = sk->nr->your_index;
1071         *asmptr++ = sk->nr->your_id;
1072         *asmptr++ = 0;          /* To be filled in later */
1073         *asmptr++ = 0;          /*      Ditto            */
1074         *asmptr++ = NR_INFO;
1075         
1076         if (sk->debug)
1077                 printk("Built header.\n");
1078 
1079         /*
1080          *      Put the data on the end
1081          */
1082 
1083         skb->h.raw = skb_put(skb, len);
1084 
1085         asmptr = skb->h.raw;
1086         
1087         if (sk->debug)
1088                 printk("NET/ROM: Appending user data\n");
1089 
1090         /* User data follows immediately after the NET/ROM transport header */
1091         memcpy_fromiovec(asmptr, msg->msg_iov, len);
1092 
1093         if (sk->debug)
1094                 printk("NET/ROM: Transmitting buffer\n");
1095 
1096         if (sk->state != TCP_ESTABLISHED) {
1097                 kfree_skb(skb, FREE_WRITE);
1098                 return -ENOTCONN;
1099         }
1100 
1101         nr_output(sk, skb);     /* Shove it onto the queue */
1102 
1103         return len;
1104 }
1105 
1106 
1107 static int nr_recvmsg(struct socket *sock, struct msghdr *msg, int size, int noblock,
     /* [previous][next][first][last][top][bottom][index][help] */
1108                    int flags, int *addr_len)
1109 {
1110         struct sock *sk = (struct sock *)sock->data;
1111         struct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;
1112         int copied;
1113         struct sk_buff *skb;
1114         int er;
1115 
1116         if (sk->err)
1117                 return sock_error(sk);
1118         
1119         if (addr_len != NULL)
1120                 *addr_len = sizeof(*sax);
1121 
1122         /*
1123          * This works for seqpacket too. The receiver has ordered the queue for
1124          * us! We do one quick check first though
1125          */
1126         if (sk->state != TCP_ESTABLISHED)
1127                 return -ENOTCONN;
1128 
1129         /* Now we can treat all alike */
1130         if ((skb = skb_recv_datagram(sk, flags, noblock, &er)) == NULL)
1131                 return er;
1132 
1133         if (!sk->nr->hdrincl) {
1134                 skb_pull(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
1135                 skb->h.raw = skb->data;
1136         }
1137 
1138         copied = (size < skb->len) ? size : skb->len;
1139         skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
1140         
1141         if (sax != NULL) {
1142                 struct sockaddr_ax25 addr;
1143                 
1144                 addr.sax25_family = AF_NETROM;
1145                 memcpy(&addr.sax25_call, skb->data + 7, AX25_ADDR_LEN);
1146 
1147                 *sax = addr;
1148 
1149                 *addr_len = sizeof(*sax);
1150         }
1151 
1152         skb_free_datagram(sk, skb);
1153 
1154         return copied;
1155 }
1156 
1157 static int nr_shutdown(struct socket *sk, int how)
     /* [previous][next][first][last][top][bottom][index][help] */
1158 {
1159         return -EOPNOTSUPP;
1160 }
1161 
1162 static int nr_select(struct socket *sock , int sel_type, select_table *wait)
     /* [previous][next][first][last][top][bottom][index][help] */
1163 {
1164         struct sock *sk = (struct sock *)sock->data;
1165 
1166         return datagram_select(sk, sel_type, wait);
1167 }
1168 
1169 static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
     /* [previous][next][first][last][top][bottom][index][help] */
1170 {
1171         struct sock *sk = (struct sock *)sock->data;
1172         int err;
1173         long amount = 0;
1174 
1175         switch (cmd) {
1176                 case TIOCOUTQ:
1177                         if ((err = verify_area(VERIFY_WRITE, (void *)arg, sizeof(unsigned long))) != 0)
1178                                 return err;
1179                         amount = sk->sndbuf - sk->wmem_alloc;
1180                         if (amount < 0)
1181                                 amount = 0;
1182                         put_fs_long(amount, (unsigned long *)arg);
1183                         return 0;
1184 
1185                 case TIOCINQ: {
1186                         struct sk_buff *skb;
1187                         /* These two are safe on a single CPU system as only user tasks fiddle here */
1188                         if ((skb = skb_peek(&sk->receive_queue)) != NULL)
1189                                 amount = skb->len - 20;
1190                         if ((err = verify_area(VERIFY_WRITE, (void *)arg, sizeof(unsigned long))) != 0)
1191                                 return err;
1192                         put_fs_long(amount, (unsigned long *)arg);
1193                         return 0;
1194                 }
1195 
1196                 case SIOCGSTAMP:
1197                         if (sk != NULL) {
1198                                 if (sk->stamp.tv_sec==0)
1199                                         return -ENOENT;
1200                                 if ((err = verify_area(VERIFY_WRITE,(void *)arg,sizeof(struct timeval))) != 0)
1201                                         return err;
1202                                 memcpy_tofs((void *)arg, &sk->stamp, sizeof(struct timeval));
1203                                 return 0;
1204                         }
1205                         return -EINVAL;
1206 
1207                 case SIOCGIFADDR:
1208                 case SIOCSIFADDR:
1209                 case SIOCGIFDSTADDR:
1210                 case SIOCSIFDSTADDR:
1211                 case SIOCGIFBRDADDR:
1212                 case SIOCSIFBRDADDR:
1213                 case SIOCGIFNETMASK:
1214                 case SIOCSIFNETMASK:
1215                 case SIOCGIFMETRIC:
1216                 case SIOCSIFMETRIC:
1217                         return -EINVAL;
1218 
1219                 case SIOCADDRT:
1220                 case SIOCDELRT:
1221                 case SIOCNRDECOBS:
1222                 case SIOCNRRTCTL:
1223                         if (!suser()) return -EPERM;
1224                         return nr_rt_ioctl(cmd, (void *)arg);
1225 
1226                 case SIOCNRGETPARMS: {
1227                         struct nr_parms_struct nr_parms;
1228                         if ((err = verify_area(VERIFY_WRITE, (void *)arg, sizeof(struct nr_parms_struct))) != 0)
1229                                 return err;
1230                         memcpy_fromfs(&nr_parms, (void *)arg, sizeof(struct nr_parms_struct));
1231                         nr_parms = nr_default;
1232                         memcpy_tofs((void *)arg, &nr_parms, sizeof(struct nr_parms_struct));
1233                         return 0;
1234                 }
1235 
1236                 case SIOCNRSETPARMS: {
1237                         struct nr_parms_struct nr_parms;
1238                         if (!suser()) return -EPERM;
1239                         if ((err = verify_area(VERIFY_READ, (void *)arg, sizeof(struct nr_parms_struct))) != 0)
1240                                 return err;
1241                         memcpy_fromfs(&nr_parms, (void *)arg, sizeof(struct nr_parms_struct));
1242                         nr_default = nr_parms;
1243                         return 0;
1244                 }
1245                 
1246                 default:
1247                         return dev_ioctl(cmd, (void *)arg);
1248         }
1249 
1250         /*NOTREACHED*/
1251         return(0);
1252 }
1253 
1254 static int nr_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
     /* [previous][next][first][last][top][bottom][index][help] */
1255 {
1256         struct sock *s;
1257         struct device *dev;
1258         const char *devname;
1259         int len = 0;
1260         off_t pos = 0;
1261         off_t begin = 0;
1262   
1263         cli();
1264 
1265         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");
1266 
1267         for (s = nr_list; s != NULL; s = s->next) {
1268                 if ((dev = s->nr->device) == NULL)
1269                         devname = "???";
1270                 else
1271                         devname = dev->name;
1272         
1273                 len += sprintf(buffer + len, "%-9s ",
1274                         ax2asc(&s->nr->user_addr));
1275                 len += sprintf(buffer + len, "%-9s ",
1276                         ax2asc(&s->nr->dest_addr));
1277                 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",
1278                         ax2asc(&s->nr->source_addr),
1279                         devname, s->nr->my_index, s->nr->my_id,
1280                         s->nr->your_index, s->nr->your_id,
1281                         s->nr->state,
1282                         s->nr->vs, s->nr->vr, s->nr->va,
1283                         s->nr->t1timer / PR_SLOWHZ,
1284                         s->nr->t1      / PR_SLOWHZ,
1285                         s->nr->t2timer / PR_SLOWHZ,
1286                         s->nr->t2      / PR_SLOWHZ,
1287                         s->nr->n2count, s->nr->n2,
1288                         s->nr->rtt     / PR_SLOWHZ,
1289                         s->window,
1290                         s->wmem_alloc, s->rmem_alloc);
1291                 
1292                 pos = begin + len;
1293 
1294                 if (pos < offset) {
1295                         len   = 0;
1296                         begin = pos;
1297                 }
1298                 
1299                 if (pos > offset + length)
1300                         break;
1301         }
1302 
1303         sti();
1304 
1305         *start = buffer + (offset - begin);
1306         len   -= (offset - begin);
1307 
1308         if (len > length) len = length;
1309 
1310         return(len);
1311 } 
1312 
1313 static struct proto_ops nr_proto_ops = {
1314         AF_NETROM,
1315         
1316         nr_create,
1317         nr_dup,
1318         nr_release,
1319         nr_bind,
1320         nr_connect,
1321         nr_socketpair,
1322         nr_accept,
1323         nr_getname,
1324         nr_select,
1325         nr_ioctl,
1326         nr_listen,
1327         nr_shutdown,
1328         nr_setsockopt,
1329         nr_getsockopt,
1330         nr_fcntl,
1331         nr_sendmsg,
1332         nr_recvmsg
1333 };
1334 
1335 static struct notifier_block nr_dev_notifier = {
1336         nr_device_event,
1337         0
1338 };
1339 
1340 void nr_proto_init(struct net_proto *pro)
     /* [previous][next][first][last][top][bottom][index][help] */
1341 {
1342         sock_register(nr_proto_ops.family, &nr_proto_ops);
1343         register_netdevice_notifier(&nr_dev_notifier);
1344         printk("G4KLX NET/ROM for Linux. Version 0.4 ALPHA for AX25.032 Linux 1.3.77\n");
1345 
1346         nr_default.quality    = NR_DEFAULT_QUAL;
1347         nr_default.obs_count  = NR_DEFAULT_OBS;
1348         nr_default.ttl        = NR_DEFAULT_TTL;
1349         nr_default.timeout    = NR_DEFAULT_T1;
1350         nr_default.ack_delay  = NR_DEFAULT_T2;
1351         nr_default.busy_delay = NR_DEFAULT_T4;
1352         nr_default.tries      = NR_DEFAULT_N2;
1353         nr_default.window     = NR_DEFAULT_WINDOW;
1354 
1355         proc_net_register(&(struct proc_dir_entry) {
1356                 PROC_NET_NR, 2, "nr",
1357                 S_IFREG | S_IRUGO, 1, 0, 0,
1358                 0, &proc_net_inode_operations, 
1359                 nr_get_info
1360         });
1361         proc_net_register(&(struct proc_dir_entry) {
1362                 PROC_NET_NR_NEIGH, 8, "nr_neigh",
1363                 S_IFREG | S_IRUGO, 1, 0, 0,
1364                 0, &proc_net_inode_operations, 
1365                 nr_neigh_get_info
1366         });
1367         proc_net_register(&(struct proc_dir_entry) {
1368                 PROC_NET_NR_NODES, 8, "nr_nodes",
1369                 S_IFREG | S_IRUGO, 1, 0, 0,
1370                 0, &proc_net_inode_operations, 
1371                 nr_nodes_get_info
1372         });
1373 }
1374 
1375 #endif

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