+ return 0;
+}
+
+int
+jt_ptl_print_peers (int argc, char **argv)
+{
+ struct portals_cfg pcfg;
+ char buffer[2][64];
+ int index;
+ int rc;
+
+ if (!g_nal_is_compatible (argv[0], SOCKNAL, RANAL,
+ OPENIBNAL, IIBNAL, VIBNAL, 0))
+ return -1;
+
+ for (index = 0;;index++) {
+ PCFG_INIT (pcfg, NAL_CMD_GET_PEER);
+ pcfg.pcfg_count = index;
+
+ rc = pcfg_ioctl (&pcfg);
+ if (rc != 0)
+ break;
+
+ if (g_nal_is_compatible(NULL, SOCKNAL, 0))
+ printf (LPX64"[%d]%s@%s:%d #%d\n",
+ pcfg.pcfg_nid, pcfg.pcfg_wait,
+ ptl_ipaddr_2_str (pcfg.pcfg_size, buffer[0], 1),
+ ptl_ipaddr_2_str (pcfg.pcfg_id, buffer[1], 1),
+ pcfg.pcfg_misc, pcfg.pcfg_count);
+ else if (g_nal_is_compatible(NULL, RANAL, 0))
+ printf (LPX64"[%d]@%s:%d\n",
+ pcfg.pcfg_nid, pcfg.pcfg_wait,
+ ptl_ipaddr_2_str (pcfg.pcfg_id, buffer[1], 1),
+ pcfg.pcfg_misc);
+ else
+ printf (LPX64"[%d]\n",
+ pcfg.pcfg_nid, pcfg.pcfg_wait);
+ }
+
+ if (index == 0)
+ printf ("<no peers>\n");
+ return 0;
+}
+
+int
+jt_ptl_add_peer (int argc, char **argv)
+{
+ struct portals_cfg pcfg;
+ ptl_nid_t nid;
+ __u32 ip = 0;
+ int port = 0;
+ int rc;
+
+ if (!g_nal_is_compatible (argv[0], SOCKNAL, RANAL,
+ OPENIBNAL, IIBNAL, VIBNAL, 0))
+ return -1;
+
+ if (g_nal_is_compatible(NULL, SOCKNAL, RANAL, 0)) {
+ if (argc != 4) {
+ fprintf (stderr, "usage(tcp,ra): %s nid ipaddr port\n",
+ argv[0]);
+ return 0;
+ }
+ } else if (argc != 2) {
+ fprintf (stderr, "usage(openib,iib,vib): %s nid\n", argv[0]);
+ return 0;
+ }
+
+ if (ptl_parse_nid (&nid, argv[1]) != 0 ||
+ nid == PTL_NID_ANY) {
+ fprintf (stderr, "Can't parse NID: %s\n", argv[1]);
+ return -1;
+ }
+
+ if (g_nal_is_compatible (NULL, SOCKNAL, RANAL, 0)) {
+ if (ptl_parse_ipaddr (&ip, argv[2]) != 0) {
+ fprintf (stderr, "Can't parse ip addr: %s\n", argv[2]);
+ return -1;
+ }
+
+ if (ptl_parse_port (&port, argv[3]) != 0) {
+ fprintf (stderr, "Can't parse port: %s\n", argv[3]);
+ return -1;
+ }
+ }
+
+ PCFG_INIT(pcfg, NAL_CMD_ADD_PEER);