summaryrefslogtreecommitdiffstats
path: root/rose/rsusers.sh
blob: 09c2e97f872c5c17681e0422b61ad91226ecc754 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /bin/sh

ALL=n

if [ $# = 1 ]; then
    ALL=y
fi

echo -en "Linux/ROSE 001. AX.25, NET/ROM and ROSE Users.\r"

if [ -r /proc/net/ax25 ]; then
    cat /proc/net/ax25 | awk '
	BEGIN  {
		printf "Active AX.25 Sessions\r"
		printf "Dest       Source     State\r"
		n = 0
	       }
	NR > 1 {
		if ($4 == 0) {
		    state = "LISTENING"
		} else if ($4 == 1) {
		    state = "CONNECTING"
		} else if ($4 == 2) {
		    state = "DISCONNECTING"
		} else if ($4 == 3) {
		    state = "CONNECTED"
		} else {
		    state = "RECOVERY"
		}
		if ($4 != 0) {
		    printf "%-9s  %-9s  %s\r", $1, $2, state
		    n++
		} else {
		    if (ALL == "y") {
			printf "%-9s  %-9s  %s\r", $1, $2, state
			n++
		    }
		}
	       }
	END    {
		    if (n == 0) {
			printf "None active\r"
		    }
	       }' ALL=$ALL

	echo -en "\r"
fi

if [ -r /proc/net/nr ]; then
    cat /proc/net/nr | awk '
	BEGIN  {
		printf "Active NET/ROM Sessions\r"
		printf "User       Dest       Source     State\r"
		n = 0
	       }
	NR > 1 {
		if ($7 == 0) {
		    state = "LISTENING"
		} else if ($7 == 1) {
		    state = "CONNECTING"
		} else if ($7 == 2) {
		    state = "DISCONNECTING"
		} else if ($7 == 3) {
		    state = "CONNECTED"
		} else {
		    state = "RECOVERY"
		}
		if ($7 != 0) {
		    printf "%-9s  %-9s  %-9s  %s\r", $1, $2, $3, state
		    n++
		} else {
		    if (ALL == "y") {
			printf "%-9s  %-9s  %-9s  %s\r", $1, $2, $3, state
			n++
		    }
		}
	       }
	END    {
		    if (n == 0) {
			printf "None active\r"
		    }
	       }' ALL=$ALL

	echo -en "\r"
fi

if [ -r /proc/net/rose ]; then
    cat /proc/net/rose | awk '
	BEGIN  {
		printf "Active ROSE Sessions\r"
		printf "Dest                   Source                 State\r"
		n = 0
	       }
	NR > 1 {
		if ($7 == 0) {
		    state = "LISTENING"
		} else if ($7 == 1) {
		    state = "CONNECTING"
		} else if ($7 == 2) {
		    state = "DISCONNECTING"
		} else if ($7 == 3) {
		    state = "CONNECTED"
		} else {
		    state = "RESETTING"
		}
		if ($7 != 0) {
		    printf "%-10s  %-9s  %-10s  %-9s  %s\r", $1, $2, $3, $4, state
		    n++
		} else {
		    if (ALL == "y") {
			printf "%-10s  %-9s  %-10s  %-9s  %s\r", $1, $2, $3, $4, state
			n++
		    }
		}
	       }
	END    {
		    if (n == 0) {
			printf "None active\r"
		    }
	       }' ALL=$ALL

	echo -en "\r"
fi

read

exit 0