[WATCHDOG] Mixcom Watchdog - clean-up printk's
[linux-2.6/zen-sources.git] / net / rxrpc / ar-proc.c
blob58f4b4e5cece404eba4368ad0b1d79bb646a4d2a
1 /* /proc/net/ support for AF_RXRPC
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/module.h>
13 #include <net/sock.h>
14 #include <net/af_rxrpc.h>
15 #include "ar-internal.h"
17 static const char *rxrpc_conn_states[] = {
18 [RXRPC_CONN_UNUSED] = "Unused ",
19 [RXRPC_CONN_CLIENT] = "Client ",
20 [RXRPC_CONN_SERVER_UNSECURED] = "SvUnsec ",
21 [RXRPC_CONN_SERVER_CHALLENGING] = "SvChall ",
22 [RXRPC_CONN_SERVER] = "SvSecure",
23 [RXRPC_CONN_REMOTELY_ABORTED] = "RmtAbort",
24 [RXRPC_CONN_LOCALLY_ABORTED] = "LocAbort",
25 [RXRPC_CONN_NETWORK_ERROR] = "NetError",
28 const char *rxrpc_call_states[] = {
29 [RXRPC_CALL_CLIENT_SEND_REQUEST] = "ClSndReq",
30 [RXRPC_CALL_CLIENT_AWAIT_REPLY] = "ClAwtRpl",
31 [RXRPC_CALL_CLIENT_RECV_REPLY] = "ClRcvRpl",
32 [RXRPC_CALL_CLIENT_FINAL_ACK] = "ClFnlACK",
33 [RXRPC_CALL_SERVER_SECURING] = "SvSecure",
34 [RXRPC_CALL_SERVER_ACCEPTING] = "SvAccept",
35 [RXRPC_CALL_SERVER_RECV_REQUEST] = "SvRcvReq",
36 [RXRPC_CALL_SERVER_ACK_REQUEST] = "SvAckReq",
37 [RXRPC_CALL_SERVER_SEND_REPLY] = "SvSndRpl",
38 [RXRPC_CALL_SERVER_AWAIT_ACK] = "SvAwtACK",
39 [RXRPC_CALL_COMPLETE] = "Complete",
40 [RXRPC_CALL_SERVER_BUSY] = "SvBusy ",
41 [RXRPC_CALL_REMOTELY_ABORTED] = "RmtAbort",
42 [RXRPC_CALL_LOCALLY_ABORTED] = "LocAbort",
43 [RXRPC_CALL_NETWORK_ERROR] = "NetError",
44 [RXRPC_CALL_DEAD] = "Dead ",
48 * generate a list of extant and dead calls in /proc/net/rxrpc_calls
50 static void *rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos)
52 struct list_head *_p;
53 loff_t pos = *_pos;
55 read_lock(&rxrpc_call_lock);
56 if (!pos)
57 return SEQ_START_TOKEN;
58 pos--;
60 list_for_each(_p, &rxrpc_calls)
61 if (!pos--)
62 break;
64 return _p != &rxrpc_calls ? _p : NULL;
67 static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *pos)
69 struct list_head *_p;
71 (*pos)++;
73 _p = v;
74 _p = (v == SEQ_START_TOKEN) ? rxrpc_calls.next : _p->next;
76 return _p != &rxrpc_calls ? _p : NULL;
79 static void rxrpc_call_seq_stop(struct seq_file *seq, void *v)
81 read_unlock(&rxrpc_call_lock);
84 static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
86 struct rxrpc_transport *trans;
87 struct rxrpc_call *call;
88 char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1];
90 if (v == SEQ_START_TOKEN) {
91 seq_puts(seq,
92 "Proto Local Remote "
93 " SvID ConnID CallID End Use State Abort "
94 " UserID\n");
95 return 0;
98 call = list_entry(v, struct rxrpc_call, link);
99 trans = call->conn->trans;
101 sprintf(lbuff, NIPQUAD_FMT":%u",
102 NIPQUAD(trans->local->srx.transport.sin.sin_addr),
103 ntohs(trans->local->srx.transport.sin.sin_port));
105 sprintf(rbuff, NIPQUAD_FMT":%u",
106 NIPQUAD(trans->peer->srx.transport.sin.sin_addr),
107 ntohs(trans->peer->srx.transport.sin.sin_port));
109 seq_printf(seq,
110 "UDP %-22.22s %-22.22s %4x %08x %08x %s %3u"
111 " %-8.8s %08x %lx\n",
112 lbuff,
113 rbuff,
114 ntohs(call->conn->service_id),
115 ntohl(call->conn->cid),
116 ntohl(call->call_id),
117 call->conn->in_clientflag ? "Svc" : "Clt",
118 atomic_read(&call->usage),
119 rxrpc_call_states[call->state],
120 call->abort_code,
121 call->user_call_ID);
123 return 0;
126 static struct seq_operations rxrpc_call_seq_ops = {
127 .start = rxrpc_call_seq_start,
128 .next = rxrpc_call_seq_next,
129 .stop = rxrpc_call_seq_stop,
130 .show = rxrpc_call_seq_show,
133 static int rxrpc_call_seq_open(struct inode *inode, struct file *file)
135 return seq_open(file, &rxrpc_call_seq_ops);
138 struct file_operations rxrpc_call_seq_fops = {
139 .owner = THIS_MODULE,
140 .open = rxrpc_call_seq_open,
141 .read = seq_read,
142 .llseek = seq_lseek,
143 .release = seq_release_private,
147 * generate a list of extant virtual connections in /proc/net/rxrpc_conns
149 static void *rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos)
151 struct list_head *_p;
152 loff_t pos = *_pos;
154 read_lock(&rxrpc_connection_lock);
155 if (!pos)
156 return SEQ_START_TOKEN;
157 pos--;
159 list_for_each(_p, &rxrpc_connections)
160 if (!pos--)
161 break;
163 return _p != &rxrpc_connections ? _p : NULL;
166 static void *rxrpc_connection_seq_next(struct seq_file *seq, void *v,
167 loff_t *pos)
169 struct list_head *_p;
171 (*pos)++;
173 _p = v;
174 _p = (v == SEQ_START_TOKEN) ? rxrpc_connections.next : _p->next;
176 return _p != &rxrpc_connections ? _p : NULL;
179 static void rxrpc_connection_seq_stop(struct seq_file *seq, void *v)
181 read_unlock(&rxrpc_connection_lock);
184 static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
186 struct rxrpc_connection *conn;
187 struct rxrpc_transport *trans;
188 char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1];
190 if (v == SEQ_START_TOKEN) {
191 seq_puts(seq,
192 "Proto Local Remote "
193 " SvID ConnID Calls End Use State Key "
194 " Serial ISerial\n"
196 return 0;
199 conn = list_entry(v, struct rxrpc_connection, link);
200 trans = conn->trans;
202 sprintf(lbuff, NIPQUAD_FMT":%u",
203 NIPQUAD(trans->local->srx.transport.sin.sin_addr),
204 ntohs(trans->local->srx.transport.sin.sin_port));
206 sprintf(rbuff, NIPQUAD_FMT":%u",
207 NIPQUAD(trans->peer->srx.transport.sin.sin_addr),
208 ntohs(trans->peer->srx.transport.sin.sin_port));
210 seq_printf(seq,
211 "UDP %-22.22s %-22.22s %4x %08x %08x %s %3u"
212 " %s %08x %08x %08x\n",
213 lbuff,
214 rbuff,
215 ntohs(conn->service_id),
216 ntohl(conn->cid),
217 conn->call_counter,
218 conn->in_clientflag ? "Svc" : "Clt",
219 atomic_read(&conn->usage),
220 rxrpc_conn_states[conn->state],
221 key_serial(conn->key),
222 atomic_read(&conn->serial),
223 atomic_read(&conn->hi_serial));
225 return 0;
228 static struct seq_operations rxrpc_connection_seq_ops = {
229 .start = rxrpc_connection_seq_start,
230 .next = rxrpc_connection_seq_next,
231 .stop = rxrpc_connection_seq_stop,
232 .show = rxrpc_connection_seq_show,
236 static int rxrpc_connection_seq_open(struct inode *inode, struct file *file)
238 return seq_open(file, &rxrpc_connection_seq_ops);
241 struct file_operations rxrpc_connection_seq_fops = {
242 .owner = THIS_MODULE,
243 .open = rxrpc_connection_seq_open,
244 .read = seq_read,
245 .llseek = seq_lseek,
246 .release = seq_release_private,