From fa407e678b60d1d1a2f2476b37ecd905daa7328b Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sat, 23 May 2015 17:08:51 -0700 Subject: [PATCH] PDP10, PDP11, VAX, MUX: Fix allowed line attach syntax to accept UDP in any order among attach arguments --- PDP11/pdp11_dmc.c | 2 +- sim_tmxr.c | 64 ++++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/PDP11/pdp11_dmc.c b/PDP11/pdp11_dmc.c index 31a0daa3..e0e01113 100644 --- a/PDP11/pdp11_dmc.c +++ b/PDP11/pdp11_dmc.c @@ -3818,7 +3818,7 @@ if (!peer[0]) { sim_printf ("Peer must be specified before attach\n"); return SCPE_ARG; } -sprintf (attach_string, "Line=%d,%s,Connect=%s,%s", dmc, cptr, peer); +sprintf (attach_string, "Line=%d,Connect=%s,%s", dmc, peer, cptr); ans = tmxr_open_master (mp, attach_string); /* open master socket */ if (ans != SCPE_OK) return ans; diff --git a/sim_tmxr.c b/sim_tmxr.c index 40e9bea3..7cca0bcd 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -2287,37 +2287,6 @@ while (*tptr) { if (0 == MATCH_CMD (gbuf, "CONNECT")) { if ((NULL == cptr) || ('\0' == *cptr)) return SCPE_ARG; - serport = sim_open_serial (cptr, NULL, &r); - if (serport != INVALID_HANDLE) { - sim_close_serial (serport); - if (strchr (cptr, ';') && mp->modem_control) - return SCPE_ARG; - } - else { - memset (hostport, '\0', sizeof(hostport)); - strncpy (hostport, cptr, sizeof(hostport)-1); - if ((cptr = strchr (hostport, ';'))) - *(cptr++) = '\0'; - if (cptr) { - get_glyph (cptr, cptr, 0); /* upcase this string */ - if (0 == MATCH_CMD (cptr, "NOTELNET")) - notelnet = TRUE; - else - if (0 == MATCH_CMD (cptr, "TELNET")) - if (datagram) - return SCPE_ARG; - else - notelnet = FALSE; - else - return SCPE_ARG; - } - sock = sim_connect_sock_ex (NULL, hostport, "localhost", NULL, (datagram ? SIM_SOCK_OPT_DATAGRAM : 0) | (packet ? SIM_SOCK_OPT_NODELAY : 0)); - if (sock != INVALID_SOCKET) - sim_close_sock (sock); - else - return SCPE_ARG; - cptr = hostport; - } strcpy (destination, cptr); continue; } @@ -2356,6 +2325,39 @@ while (*tptr) { return SCPE_ARG; } } + if (destination[0]) { + /* Validate destination */ + serport = sim_open_serial (destination, NULL, &r); + if (serport != INVALID_HANDLE) { + sim_close_serial (serport); + if (strchr (destination, ';') && mp->modem_control) + return SCPE_ARG; + } + else { + memset (hostport, '\0', sizeof(hostport)); + strncpy (hostport, destination, sizeof(hostport)-1); + if ((cptr = strchr (hostport, ';'))) + *(cptr++) = '\0'; + if (cptr) { + get_glyph (cptr, cptr, 0); /* upcase this string */ + if (0 == MATCH_CMD (cptr, "NOTELNET")) + notelnet = TRUE; + else + if (0 == MATCH_CMD (cptr, "TELNET")) + if (datagram) + return SCPE_ARG; + else + notelnet = FALSE; + else + return SCPE_ARG; + } + sock = sim_connect_sock_ex (NULL, hostport, "localhost", NULL, (datagram ? SIM_SOCK_OPT_DATAGRAM : 0) | (packet ? SIM_SOCK_OPT_NODELAY : 0)); + if (sock != INVALID_SOCKET) + sim_close_sock (sock); + else + return SCPE_ARG; + } + } if (line == -1) { if (modem_control != mp->modem_control) return SCPE_ARG;