Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lnet / utils / ptlctl.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
5  *
6  *   This file is part of Portals, http://www.sf.net/projects/lustre/
7  *
8  *   Portals is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Portals is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Portals; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <lnet/lnetctl.h>
26 #include <libcfs/libcfsutil.h>
27
28
29 command_t list[] = {
30         {"network", jt_ptl_network, 0,"select/configure network (args: up|down|LND name)"},
31         {"net", jt_ptl_network, 0,"select/configure network (args: up|down|LND name)"},
32         {"list_nids", jt_ptl_list_nids, 0,"list local NIDs"},
33         {"which_nid", jt_ptl_which_nid, 0,"select the closest NID"},
34         {"print_interfaces", jt_ptl_print_interfaces, 0, "print interface entries (no args)"},
35         {"add_interface", jt_ptl_add_interface, 0, "add interface entry (args: ip [netmask])"},
36         {"del_interface", jt_ptl_del_interface, 0, "delete interface entries (args: [ip])"},
37         {"print_peers", jt_ptl_print_peers, 0, "print peer entries (no args)"},
38         {"add_peer", jt_ptl_add_peer, 0, "add peer entry (args: nid host port)"},
39         {"del_peer", jt_ptl_del_peer, 0, "delete peer entry (args: [nid] [host])"},
40         {"print_conns", jt_ptl_print_connections, 0, "print connections (no args)"},
41         {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid (args: [nid] [host]"},
42         {"push", jt_ptl_push_connection, 0, "flush connection to a remote nid (args: [nid]"},
43         {"active_tx", jt_ptl_print_active_txs, 0, "print active transmits (no args)"},
44         {"ping", jt_ptl_ping, 0, "ping (args: nid [timeout] [pid])"},
45         {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local NID (args: [hostname])"},
46         {"add_route", jt_ptl_add_route, 0, 
47          "add an entry to the routing table (args: gatewayNID targetNID [targetNID])"},
48         {"del_route", jt_ptl_del_route, 0, 
49          "delete all routes via a gateway from the routing table (args: gatewayNID"},
50         {"set_route", jt_ptl_notify_router, 0, 
51          "enable/disable a route in the routing table (args: gatewayNID up/down [time]"},
52         {"print_routes", jt_ptl_print_routes, 0, "print the routing table (args: none)"},
53         {"dump", jt_ioc_dump, 0, "usage: dump file, save ioctl buffer to file"},
54         {"fail", jt_ptl_fail_nid, 0, "usage: fail nid|_all_ [count]"},
55         {"testprotocompat", jt_ptl_testprotocompat, 0, "usage: testprotocompat count"},
56         {"help", Parser_help, 0, "help"},
57         {"exit", Parser_quit, 0, "quit"},
58         {"quit", Parser_quit, 0, "quit"},
59         { 0, 0, 0, NULL }
60 };
61
62 int main(int argc, char **argv)
63 {
64         int rc = 0;
65
66         rc = libcfs_arch_init();
67         if (rc < 0)
68                 return rc;
69
70         rc = ptl_initialize(argc, argv);
71         if (rc < 0)
72                 goto errorout;
73
74         Parser_init("ptlctl > ", list);
75         if (argc > 1) {
76                 rc = Parser_execarg(argc - 1, &argv[1], list);
77                 goto errorout;
78         }
79
80         Parser_commands();
81
82 errorout:
83         libcfs_arch_cleanup();
84         return rc;
85 }