]> bbs.cooldavid.org Git - net-next-2.6.git/blame - net/ax25/ax25_ds_in.c
[TCP]: Move the tcp sock states to net/tcp_states.h
[net-next-2.6.git] / net / ax25 / ax25_ds_in.c
CommitLineData
1da177e4
LT
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
8 * Copyright (C) Joerg Reuter DL1BKE (jreuter@yaina.de)
9 */
10#include <linux/errno.h>
11#include <linux/types.h>
12#include <linux/socket.h>
13#include <linux/in.h>
14#include <linux/kernel.h>
15#include <linux/sched.h>
16#include <linux/timer.h>
17#include <linux/string.h>
18#include <linux/sockios.h>
19#include <linux/net.h>
20#include <net/ax25.h>
21#include <linux/inet.h>
22#include <linux/netdevice.h>
23#include <linux/skbuff.h>
24#include <net/sock.h>
25#include <net/ip.h> /* For ip_rcv */
c752f073 26#include <net/tcp_states.h>
1da177e4
LT
27#include <asm/uaccess.h>
28#include <asm/system.h>
29#include <linux/fcntl.h>
30#include <linux/mm.h>
31#include <linux/interrupt.h>
32
33/*
34 * State machine for state 1, Awaiting Connection State.
35 * The handling of the timer(s) is in file ax25_ds_timer.c.
36 * Handling of state 0 and connection release is in ax25.c.
37 */
38static int ax25_ds_state1_machine(ax25_cb *ax25, struct sk_buff *skb, int frametype, int pf, int type)
39{
40 switch (frametype) {
41 case AX25_SABM:
42 ax25->modulus = AX25_MODULUS;
43 ax25->window = ax25->ax25_dev->values[AX25_VALUES_WINDOW];
44 ax25_send_control(ax25, AX25_UA, pf, AX25_RESPONSE);
45 break;
46
47 case AX25_SABME:
48 ax25->modulus = AX25_EMODULUS;
49 ax25->window = ax25->ax25_dev->values[AX25_VALUES_EWINDOW];
50 ax25_send_control(ax25, AX25_UA, pf, AX25_RESPONSE);
51 break;
52
53 case AX25_DISC:
54 ax25_send_control(ax25, AX25_DM, pf, AX25_RESPONSE);
55 break;
56
57 case AX25_UA:
58 ax25_calculate_rtt(ax25);
59 ax25_stop_t1timer(ax25);
60 ax25_start_t3timer(ax25);
61 ax25_start_idletimer(ax25);
62 ax25->vs = 0;
63 ax25->va = 0;
64 ax25->vr = 0;
65 ax25->state = AX25_STATE_3;
66 ax25->n2count = 0;
67 if (ax25->sk != NULL) {
68 bh_lock_sock(ax25->sk);
69 ax25->sk->sk_state = TCP_ESTABLISHED;
70 /*
71 * For WAIT_SABM connections we will produce an accept
72 * ready socket here
73 */
74 if (!sock_flag(ax25->sk, SOCK_DEAD))
75 ax25->sk->sk_state_change(ax25->sk);
76 bh_unlock_sock(ax25->sk);
77 }
78 ax25_dama_on(ax25);
79
80