1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2003 Los Alamos National Laboratory (LANL)
6 * This file is part of Lustre, http://www.lustre.org/
8 * This file is free software; you can redistribute it and/or
9 * modify it under the terms of version 2.1 of the GNU Lesser General
10 * Public License as published by the Free Software Foundation.
12 * Lustre 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 Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Portals; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <sys/types.h>
24 #include <sys/socket.h>
25 #include <netinet/tcp.h>
30 #include <sys/ioctl.h>
35 #include <portals/api-support.h>
36 #include <portals/lib-types.h>
40 #define GMNAL_IOC_GET_GNID 1
42 * portals always uses unit 0
43 * Can this be configurable?
50 unsigned u_getgmnid(char *name, int get_local_id);
51 void usage(char *prg, int h);
53 int main(int argc, char **argv)
62 while ((c = getopt(argc, argv, "n:lh")) != -1) {
88 if (!name && !get_local_id) {
93 nid = u_getgmnid(name, get_local_id);
99 u_getgmnid(char *name, int get_local_id)
101 struct gm_port *gm_port;
103 gm_status_t gm_status = GM_SUCCESS;
106 * gm global or local ids are never 0
108 unsigned global_nid = 0, local_nid = 0;
110 gm_status = gm_init();
111 if (gm_status != GM_SUCCESS) {
112 fprintf(stderr, "gm_init :: %s\n", gm_strerror(gm_status));
116 gm_status = gm_open(&gm_port, GM_UNIT, gm_port_id,
117 "gmnalnid", GM_API_VERSION);
119 if (gm_status != GM_SUCCESS) {
121 * Couldn't open port 2
125 for (gm_port_id=4; gm_port_id<8; gm_port_id++) {
126 gm_status = gm_open(&gm_port,
131 if (gm_status == GM_SUCCESS) {
134 fprintf(stderr, "gm_open :: %s\n",
135 gm_strerror(gm_status));
144 gm_status = gm_host_name_to_node_id_ex(gm_port, 1000000, name,
146 if (gm_status != GM_SUCCESS) {
147 fprintf(stderr, "gm_host_name_to_node_id_ex :: %s\n",
148 gm_strerror(gm_status));
155 gm_status = gm_node_id_to_global_id(gm_port, local_nid, &global_nid) ;
156 if (gm_status != GM_SUCCESS) {
157 fprintf(stderr, "gm_node_id_to_global_id :: %s\n",
158 gm_strerror(gm_status));
169 usage(char *prg, int h)
172 fprintf(stderr, "usage %s -n hostname | -l | -h\n", prg);
174 printf("\nGet Myrinet Global network ids for specified host\n");
175 printf("-l gets network id for local host\n");