mirror of
https://github.com/rcornwell/sims.git
synced 2026-04-03 20:32:34 +00:00
SCP: Update SCP to current.
This commit is contained in:
8
makefile
8
makefile
@@ -581,21 +581,21 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
|
||||
endif
|
||||
ifneq (,$(call find_include,dlfcn))
|
||||
ifneq (,$(call find_lib,dl))
|
||||
OS_CCDEFS += -DHAVE_DLOPEN=$(LIBSOEXT)
|
||||
OS_CCDEFS += -DSIM_HAVE_DLOPEN=$(LIBSOEXT)
|
||||
OS_LDFLAGS += -ldl
|
||||
$(info using libdl: $(call find_lib,dl) $(call find_include,dlfcn))
|
||||
else
|
||||
ifneq (,$(findstring BSD,$(OSTYPE))$(findstring AIX,$(OSTYPE))$(findstring Haiku,$(OSTYPE)))
|
||||
OS_CCDEFS += -DHAVE_DLOPEN=so
|
||||
OS_CCDEFS += -DSIM_HAVE_DLOPEN=so
|
||||
$(info using libdl: $(call find_include,dlfcn))
|
||||
else
|
||||
ifneq (,$(call find_lib,dld))
|
||||
OS_CCDEFS += -DHAVE_DLOPEN=$(LIBSOEXT)
|
||||
OS_CCDEFS += -DSIM_HAVE_DLOPEN=$(LIBSOEXT)
|
||||
OS_LDFLAGS += -ldld
|
||||
$(info using libdld: $(call find_lib,dld) $(call find_include,dlfcn))
|
||||
else
|
||||
ifeq (Darwin,$(OSTYPE))
|
||||
OS_CCDEFS += -DHAVE_DLOPEN=dylib
|
||||
OS_CCDEFS += -DSIM_HAVE_DLOPEN=dylib
|
||||
$(info using macOS dlopen with .dylib)
|
||||
endif
|
||||
endif
|
||||
|
||||
37
scp.c
37
scp.c
@@ -238,7 +238,7 @@
|
||||
#endif
|
||||
#include <setjmp.h>
|
||||
|
||||
#if defined(HAVE_DLOPEN) /* Dynamic Readline support */
|
||||
#if defined(SIM_HAVE_DLOPEN) /* Dynamic Readline support */
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
@@ -6411,8 +6411,10 @@ FILE *f;
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
#else
|
||||
#define FIND_CMD "which"
|
||||
#define FIND_CMD2 ""
|
||||
#define FIND_CMD "command -v"
|
||||
#define FIND_CMD2 "2>/dev/null"
|
||||
#define FIND_CMD_EXTRA "which"
|
||||
#define FIND_CMD2_EXTRA "2>/dev/null"
|
||||
#endif
|
||||
memset (toolpath, 0, sizeof(toolpath));
|
||||
snprintf (findcmd, sizeof (findcmd), "%s %s %s", FIND_CMD, tool, FIND_CMD2);
|
||||
@@ -6424,6 +6426,19 @@ if ((f = popen (findcmd, "r"))) {
|
||||
} while (toolpath[0] == '\0');
|
||||
pclose (f);
|
||||
}
|
||||
if (toolpath[0] == '\0') { /* Not found yet? */
|
||||
#if defined(FIND_CMD_EXTRA) /* Try with alternative command */
|
||||
snprintf (findcmd, sizeof (findcmd), "%s %s %s", FIND_CMD_EXTRA, tool, FIND_CMD2_EXTRA);
|
||||
if ((f = popen (findcmd, "r"))) {
|
||||
do {
|
||||
if (NULL == fgets (toolpath, sizeof(toolpath)-1, f))
|
||||
break;
|
||||
sim_trim_endspc (toolpath);
|
||||
} while (toolpath[0] == '\0');
|
||||
pclose (f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return toolpath;
|
||||
}
|
||||
|
||||
@@ -10076,7 +10091,7 @@ return read_line_p (NULL, cptr, size, stream);
|
||||
char *read_line_p (const char *prompt, char *cptr, int32 size, FILE *stream)
|
||||
{
|
||||
char *tptr;
|
||||
#if defined(HAVE_DLOPEN)
|
||||
#if defined(SIM_HAVE_DLOPEN)
|
||||
static int initialized = 0;
|
||||
typedef char *(*readline_func)(const char *);
|
||||
static readline_func p_readline = NULL;
|
||||
@@ -10089,15 +10104,15 @@ if (prompt && (!initialized)) {
|
||||
|
||||
#define S__STR_QUOTE(tok) #tok
|
||||
#define S__STR(tok) S__STR_QUOTE(tok)
|
||||
handle = dlopen("libncurses." S__STR(HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen("libcurses." S__STR(HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen("libreadline." S__STR(HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen("libncurses." S__STR(SIM_HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen("libcurses." S__STR(SIM_HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen("libreadline." S__STR(SIM_HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
|
||||
if (!handle)
|
||||
handle = dlopen("libreadline." S__STR(HAVE_DLOPEN) ".7", RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen("libreadline." S__STR(SIM_HAVE_DLOPEN) ".7", RTLD_NOW|RTLD_GLOBAL);
|
||||
if (!handle)
|
||||
handle = dlopen("libreadline." S__STR(HAVE_DLOPEN) ".6", RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen("libreadline." S__STR(SIM_HAVE_DLOPEN) ".6", RTLD_NOW|RTLD_GLOBAL);
|
||||
if (!handle)
|
||||
handle = dlopen("libreadline." S__STR(HAVE_DLOPEN) ".5", RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen("libreadline." S__STR(SIM_HAVE_DLOPEN) ".5", RTLD_NOW|RTLD_GLOBAL);
|
||||
if (handle) {
|
||||
p_readline = (readline_func)((size_t)dlsym(handle, "readline"));
|
||||
p_add_history = (add_history_func)((size_t)dlsym(handle, "add_history"));
|
||||
@@ -10150,7 +10165,7 @@ if ((*cptr == ';') || (*cptr == '#')) { /* ignore comment */
|
||||
*cptr = 0;
|
||||
}
|
||||
|
||||
#if defined (HAVE_DLOPEN)
|
||||
#if defined (SIM_HAVE_DLOPEN)
|
||||
if (prompt && p_add_history && *cptr) /* Save non blank lines in history */
|
||||
p_add_history (cptr);
|
||||
#endif
|
||||
|
||||
@@ -819,10 +819,9 @@ _sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*ima
|
||||
temp = ascii_to_dec_029[(int)c];
|
||||
break;
|
||||
}
|
||||
(*image)[col++] = temp & 0xfff;
|
||||
if (temp & 0xf000) {
|
||||
if (temp & 0xf000)
|
||||
(*image)[0] |= CARD_ERR;
|
||||
}
|
||||
(*image)[col++] = temp & 0xfff;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1354,10 +1353,6 @@ sim_card_attach(UNIT * uptr, CONST char *cptr)
|
||||
|
||||
/* Go read the deck */
|
||||
r = _sim_read_deck(uptr, eof);
|
||||
/* Remove added eof from count */
|
||||
if (eof) {
|
||||
previous_cards++;
|
||||
}
|
||||
uptr->pos = saved_pos;
|
||||
detach_unit(uptr);
|
||||
if (was_attached) {
|
||||
|
||||
@@ -5222,7 +5222,7 @@ if (UuidCreate_c)
|
||||
else
|
||||
_rand_uuid_gen (uuidaddr);
|
||||
}
|
||||
#elif defined (HAVE_DLOPEN)
|
||||
#elif defined (SIM_HAVE_DLOPEN)
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void
|
||||
@@ -5233,7 +5233,7 @@ void *handle;
|
||||
|
||||
#define S__STR_QUOTE(tok) #tok
|
||||
#define S__STR(tok) S__STR_QUOTE(tok)
|
||||
handle = dlopen("libuuid." S__STR(HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
|
||||
handle = dlopen("libuuid." S__STR(SIM_HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
|
||||
if (handle)
|
||||
uuid_generate_c = (void (*)(void *))((size_t)dlsym(handle, "uuid_generate"));
|
||||
if (uuid_generate_c)
|
||||
|
||||
52
sim_ether.c
52
sim_ether.c
@@ -1225,11 +1225,11 @@ extern "C" {
|
||||
#include <winreg.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
#ifdef SIM_HAVE_DLOPEN
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#if defined(USE_SHARED) && (defined(_WIN32) || defined(HAVE_DLOPEN))
|
||||
#if defined(USE_SHARED) && (defined(_WIN32) || defined(SIM_HAVE_DLOPEN))
|
||||
/* Dynamic DLL loading technique and modified source comes from
|
||||
Etherial/WireShark capture_pcap.c */
|
||||
|
||||
@@ -1249,7 +1249,7 @@ static const char* lib_name =
|
||||
#elif defined(__APPLE__)
|
||||
"/usr/lib/libpcap.A.dylib";
|
||||
#else
|
||||
"libpcap." __STR(HAVE_DLOPEN);
|
||||
"libpcap." __STR(SIM_HAVE_DLOPEN);
|
||||
#endif
|
||||
|
||||
static char no_pcap[PCAP_ERRBUF_SIZE] =
|
||||
@@ -1258,7 +1258,7 @@ static char no_pcap[PCAP_ERRBUF_SIZE] =
|
||||
#elif defined(__APPLE__)
|
||||
"/usr/lib/libpcap.A.dylib failed to load, install libpcap to use pcap networking";
|
||||
#else
|
||||
"libpcap." __STR(HAVE_DLOPEN) " failed to load, install libpcap to use pcap networking";
|
||||
"libpcap." __STR(SIM_HAVE_DLOPEN) " failed to load, install libpcap to use pcap networking";
|
||||
#endif
|
||||
#undef __STR
|
||||
#undef __STR_QUOTE
|
||||
@@ -1529,7 +1529,7 @@ int pcap_setnonblock(pcap_t* a, int nonblock, char *errbuf) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif /* defined(USE_SHARED) && (defined(_WIN32) || defined(HAVE_DLOPEN)) */
|
||||
#endif /* defined(USE_SHARED) && (defined(_WIN32) || defined(SIM_HAVE_DLOPEN)) */
|
||||
|
||||
/* Some platforms have always had pcap_sendpacket */
|
||||
#if defined(_WIN32) || defined(__VMS)
|
||||
@@ -4014,15 +4014,24 @@ return SCPE_OK;
|
||||
t_stat eth_filter(ETH_DEV* dev, int addr_count, ETH_MAC* const addresses,
|
||||
ETH_BOOL all_multicast, ETH_BOOL promiscuous)
|
||||
{
|
||||
return eth_filter_hash(dev, addr_count, addresses,
|
||||
all_multicast, promiscuous,
|
||||
NULL);
|
||||
return eth_filter_hash_ex(dev, addr_count, addresses,
|
||||
all_multicast, promiscuous, FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
t_stat eth_filter_hash(ETH_DEV* dev, int addr_count, ETH_MAC* const addresses,
|
||||
ETH_BOOL all_multicast, ETH_BOOL promiscuous,
|
||||
ETH_MULTIHASH* const hash)
|
||||
{
|
||||
return eth_filter_hash_ex(dev, addr_count, addresses,
|
||||
all_multicast, promiscuous, TRUE,
|
||||
hash);
|
||||
}
|
||||
|
||||
t_stat eth_filter_hash_ex(ETH_DEV* dev, int addr_count, ETH_MAC* const addresses,
|
||||
ETH_BOOL all_multicast, ETH_BOOL promiscuous,
|
||||
ETH_BOOL match_broadcast, ETH_MULTIHASH* const hash)
|
||||
{
|
||||
int i;
|
||||
char buf[116+66*ETH_FILTER_MAX];
|
||||
char mac[20];
|
||||
@@ -4035,7 +4044,7 @@ struct bpf_program bpf;
|
||||
if (!dev) return SCPE_UNATT;
|
||||
|
||||
/* filter count OK? */
|
||||
if ((addr_count < 0) || (addr_count > ETH_FILTER_MAX))
|
||||
if ((addr_count < 0) || ((addr_count + (match_broadcast ? 1 : 0)) > ETH_FILTER_MAX))
|
||||
return SCPE_ARG;
|
||||
else
|
||||
if (!addresses && (addr_count != 0))
|
||||
@@ -4050,6 +4059,11 @@ if (dev->reflections == -1)
|
||||
for (i = 0; i < addr_count; i++)
|
||||
memcpy(dev->filter_address[i], addresses[i], sizeof(ETH_MAC));
|
||||
dev->addr_count = addr_count;
|
||||
if (match_broadcast) {
|
||||
memset(&dev->filter_address[addr_count], 0xFF, sizeof(ETH_MAC));
|
||||
++addr_count;
|
||||
}
|
||||
dev->addr_count = addr_count;
|
||||
|
||||
/* store other flags */
|
||||
dev->all_multicast = all_multicast;
|
||||
@@ -4219,6 +4233,26 @@ fprintf(st, " Read Queue: High: %d\n", dev->read_queue.high);
|
||||
fprintf(st, " Read Queue: Loss: %d\n", dev->read_queue.loss);
|
||||
fprintf(st, " Peak Write Queue Size: %d\n", dev->write_queue_peak);
|
||||
#endif
|
||||
if (dev->error_needs_reset)
|
||||
fprintf(st, " In Error Needs Reset: True\n");
|
||||
if (dev->error_reopen_count)
|
||||
fprintf(st, " Error Reopen Count: %d\n", (int)dev->error_reopen_count);
|
||||
if (1) {
|
||||
int i, count = 0;
|
||||
ETH_MAC zeros = {0, 0, 0, 0, 0, 0};
|
||||
char buffer[20];
|
||||
|
||||
for (i = 0; i < ETH_FILTER_MAX; i++) {
|
||||
if (memcmp(zeros, &dev->filter_address[i], sizeof(ETH_MAC))) {
|
||||
eth_mac_fmt(&dev->filter_address[i], buffer);
|
||||
fprintf(st, " MAC Filter[%2d]: %s\n", count++, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dev->all_multicast)
|
||||
fprintf(st, " All Multicast mode: Enabled\n");
|
||||
if (dev->promiscuous)
|
||||
fprintf(st, " Promiscuous mode: Enabled\n");
|
||||
if (dev->bpf_filter)
|
||||
fprintf(st, " BPF Filter: %s\n", dev->bpf_filter);
|
||||
#if defined(HAVE_SLIRP_NETWORK)
|
||||
|
||||
14
sim_ether.h
14
sim_ether.h
@@ -124,8 +124,8 @@ extern "C" {
|
||||
#if defined(USE_NETWORK) && defined(USE_SHARED)
|
||||
#undef USE_SHARED
|
||||
#endif
|
||||
/* USE_SHARED only works on Windows or if HAVE_DLOPEN */
|
||||
#if defined(USE_SHARED) && !defined(_WIN32) && !defined(HAVE_DLOPEN)
|
||||
/* USE_SHARED only works on Windows or if SIM_HAVE_DLOPEN */
|
||||
#if defined(USE_SHARED) && !defined(_WIN32) && !defined(SIM_HAVE_DLOPEN)
|
||||
#undef USE_SHARED
|
||||
#endif
|
||||
|
||||
@@ -342,11 +342,17 @@ t_stat eth_filter (ETH_DEV* dev, int addr_count, /* set filter on incomin
|
||||
ETH_MAC* const addresses,
|
||||
ETH_BOOL all_multicast,
|
||||
ETH_BOOL promiscuous);
|
||||
t_stat eth_filter_hash (ETH_DEV* dev, int addr_count, /* set filter on incoming packets with AUTODIN II based hash */
|
||||
t_stat eth_filter_hash (ETH_DEV* dev, int addr_count, /* set filter on incoming packets with hash */
|
||||
ETH_MAC* const addresses,
|
||||
ETH_BOOL all_multicast,
|
||||
ETH_BOOL promiscuous,
|
||||
ETH_MULTIHASH* const hash);
|
||||
ETH_MULTIHASH* const hash); /* AUTODIN II based 8 byte imperfect hash */
|
||||
t_stat eth_filter_hash_ex (ETH_DEV* dev, int addr_count,/* set filter on incoming packets with hash */
|
||||
ETH_MAC* const addresses,
|
||||
ETH_BOOL all_multicast,
|
||||
ETH_BOOL promiscuous,
|
||||
ETH_BOOL match_broadcast,
|
||||
ETH_MULTIHASH* const hash); /* AUTODIN II based 8 byte imperfect hash */
|
||||
t_stat eth_check_address_conflict (ETH_DEV* dev,
|
||||
ETH_MAC* const address);
|
||||
const char *eth_version (void); /* Version of dynamically loaded library (pcap) */
|
||||
|
||||
@@ -55,7 +55,7 @@ extern "C" {
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
#ifdef SIM_HAVE_DLOPEN
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -170,6 +170,7 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
|
||||
rbp = (struct bootp_t *)m->m_data;
|
||||
m->m_data += sizeof(struct udpiphdr);
|
||||
memset(rbp, 0, sizeof(struct bootp_t));
|
||||
daddr.sin_addr.s_addr = 0xffffffffu;
|
||||
|
||||
if (dhcp_msg_type == DHCPDISCOVER) {
|
||||
if (preq_addr.s_addr != htonl(0L)) {
|
||||
@@ -308,8 +309,6 @@ static void bootp_reply(Slirp *slirp, const struct bootp_t *bp)
|
||||
}
|
||||
*q = RFC1533_END;
|
||||
|
||||
daddr.sin_addr.s_addr = 0xffffffffu;
|
||||
|
||||
m->m_len = sizeof(struct bootp_t) -
|
||||
sizeof(struct ip) - sizeof(struct udphdr);
|
||||
udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY);
|
||||
|
||||
Reference in New Issue
Block a user