diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7d3ee5c..e9b648e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,12 +20,14 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 + with: + submodules: true - name: Packages run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ cmake ninja-build pkg-config libgtk-4-dev libadwaita-1-dev \ - libpulse-dev libsndfile1-dev + libpulse-dev libsndfile1-dev libasound2-dev libusb-1.0-0-dev - name: Build run: | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..c120753 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "external/D-Modem"] + path = external/D-Modem + url = https://github.com/D-Modem/D-Modem.git + branch = main diff --git a/CMakeLists.txt b/CMakeLists.txt index b8cab64..3777f09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ # The macOS app (macos/) builds with Xcode and takes the core from here. # With DMODEM_GUI_WINPORT, the Windows app also builds for Linux and # macOS, over clang-retro MFC's portable Win32 layer (winport/). +# With DMODEM_GUI_EMBED, the Linux app has the modem in it +# (libdmodem_embed from the D-Modem submodule, external/D-Modem): it +# needs no dmodemd. cmake_minimum_required(VERSION 3.16) project(dmodem-gui VERSION 1.0.0 LANGUAGES C) @@ -15,6 +18,33 @@ option(DMODEM_GUI_SSH "Build libdmodemssh (libssh) for the Remote page" ON) option(DMODEM_GUI_WINPORT "Build the Windows app for Linux or macOS (winport/)" OFF) set(CLANG_RETRO_MFC "" CACHE PATH "A clang-retro MFC checkout, for DMODEM_GUI_WINPORT") +# the modem built in (docs/embedded-modem.md): the Linux app, when the +# submodule is there (git submodule update --init) +set(DMODEM_GUI_DMODEM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/D-Modem + CACHE PATH "The D-Modem tree, for DMODEM_GUI_EMBED") +if(EXISTS ${DMODEM_GUI_DMODEM_DIR}/CMakeLists.txt AND UNIX AND NOT APPLE) + set(_embed_default ON) +else() + set(_embed_default OFF) +endif() +option(DMODEM_GUI_EMBED "Build the modem into the Linux app (libdmodem_embed)" + ${_embed_default}) +if(DMODEM_GUI_EMBED AND DMODEM_GUI_LINUX) + if(NOT EXISTS ${DMODEM_GUI_DMODEM_DIR}/CMakeLists.txt) + message(FATAL_ERROR "DMODEM_GUI_EMBED: no D-Modem in " + "${DMODEM_GUI_DMODEM_DIR} (git submodule update --init)") + endif() + enable_language(CXX) + # (D-Modem's library and its SIP alone: no programs, modules or tests) + set(DMODEM_DMODEMD ON CACHE BOOL "" FORCE) + set(DMODEM_EMBED ON CACHE BOOL "" FORCE) + set(DMODEM_TESTS OFF CACHE BOOL "" FORCE) + set(DMODEM_ASTERISK OFF CACHE BOOL "" FORCE) + set(DMODEM_FREESWITCH OFF CACHE BOOL "" FORCE) + set(DMODEM_ARI OFF CACHE BOOL "" FORCE) + add_subdirectory(${DMODEM_GUI_DMODEM_DIR} d-modem EXCLUDE_FROM_ALL) +endif() + add_subdirectory(core) enable_testing() add_subdirectory(core/test) diff --git a/README.md b/README.md index 9d6a8fa..0331b76 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ Native apps for D-Modem on Windows, macOS and Linux. -Each app starts dmodemd (or connects to a dmodemd that already runs). It +The Linux app has the modem built in, so it needs no dmodemd. The Windows +and macOS apps start dmodemd (or connect to a dmodemd that already runs). It shows the modem as a desktop program. You can dial and answer from a window, change the settings without AT commands, and see the results of the last call. All three apps are thin native shells over one small C library, @@ -59,6 +60,7 @@ macOS, refer to [Building](docs/building.md). - [Features](docs/features.md): each page and menu of the apps, with the details of the Windows app - [Building](docs/building.md): Linux, Windows with clang-retro, macOS, and the Windows app on Linux and macOS +- [The built-in modem](docs/embedded-modem.md): the modem inside the Linux app, with no dmodemd - [Design](docs/design.md): how the apps are built, what they share, hardware modems (the MultiTech MT9234MU), the Windows 9x notes, and the Windows app on Linux and macOS - [libdmodemctl](core/include/dmodemctl.h): the API of the library - [Documentation style](docs/STYLE.md): the rules for ASD-STE100 Simplified Technical English diff --git a/docs/building.md b/docs/building.md index b27b7b1..17e6c17 100644 --- a/docs/building.md +++ b/docs/building.md @@ -2,10 +2,14 @@ Linux: + git submodule update --init sudo apt install cmake libgtk-4-dev libadwaita-1-dev libpulse-dev \ - libsndfile1-dev + libsndfile1-dev libasound2-dev libusb-1.0-0-dev cmake -S . -B build && cmake --build build && ./build/linux/dmodem-gui +The submodule `external/D-Modem` gives the built-in modem. Refer to +[The built-in modem](embedded-modem.md). + Windows: we build the Windows app with clang-retro. Get its toolchain package (`clang-dos-linux-x86_64.tar.xz` or `clang-dos-windows-x86_64.zip`, from the [nightly release](https://github.com/clang-retro/dos-sdk/releases/tag/nightly)). diff --git a/docs/design.md b/docs/design.md index e849d8a..9e90587 100644 --- a/docs/design.md +++ b/docs/design.md @@ -335,6 +335,10 @@ the pty in the group of the user (`-g`). Thus dmodemd does not need root. Each app can also use a modem that already runs: a device path on Linux and macOS, or a TCP address or a COM port on Windows. +The Linux app does not start dmodemd by default. It runs the modem in a +thread (`libdmodem_embed`), and its DTE is a socket. Refer to +[The built-in modem](embedded-modem.md). + ## Hardware modems: the MultiTech MT9234MU The "device" line can also open a hardware modem. The apps send AT commands diff --git a/docs/embedded-modem.md b/docs/embedded-modem.md new file mode 100644 index 0000000..6b902e9 --- /dev/null +++ b/docs/embedded-modem.md @@ -0,0 +1,77 @@ +# The built-in modem + +The Linux app has the D-Modem modem in it. Thus, the app does not need a +separate `dmodemd`. The Windows and macOS apps still start `dmodemd` at +this time. + +## What it does + +The app uses `libdmodem_embed`, the library of `dmodemd` in the D-Modem +repository ([docs/embed.md](https://github.com/D-Modem/D-Modem/blob/main/docs/embed.md)). + +1. When you click **Start**, the app starts the modem in a thread of the + app. +2. The library gives the app a socket. This socket is the DTE of the modem. + The app uses the socket as it uses the pty of `dmodemd`. +3. When you click **Stop**, the app hangs up the call and stops the thread. + +The built-in modem has these lines: a SIP account (or no account), a USB +modem, and a softmodem codec (ALSA). For "A modem that already runs", the +app opens the device and starts no modem. + +## Differences from dmodemd + +- There is no pty and no `/dev/ttyDM0` link. Other programs cannot use the + built-in modem. To share the modem with other programs, start `dmodemd`. +- The app does not need root. +- A USB modem needs a udev rule that lets the user open the device. +- A softmodem codec needs the user in the `audio` group. +- The modem keeps the measurements of the line in + `~/.local/share/dmodem-gui/dmodem0.data`. +- The **Log** page shows the log of the modem. + +## How to use dmodemd + +1. Open the line settings (the gear button on the Modem page). +2. In **Advanced**, set **Built-in modem** to off. +3. Optional: set the path of `dmodemd`. + +The app then starts `dmodemd` as before. + +## How to build it + +The D-Modem source is a git submodule in `external/D-Modem`. To get it: + + git submodule update --init + +If the submodule is there, CMake builds the built-in modem on Linux +(`DMODEM_GUI_EMBED`, on by default). To build the app with no built-in +modem, use `-DDMODEM_GUI_EMBED=OFF`. For a USB line and an ALSA line, also +install `libusb-1.0-0-dev` and `libasound2-dev`. + +The first build downloads libre and Mbed TLS for the SIP line of the modem. + +## Licence + +D-Modem and the GUI are both under the AGPL-3.0-only, or a commercial +licence from the D-Modem Authors. Thus the two combine under each licence. +The built-in modem links libre (BSD-3-Clause), Mbed TLS (Apache-2.0), and +on Linux the libusb and ALSA libraries of the system (LGPL-2.1). + +## Status + +| App | Status | +| --- | --- | +| Linux | Done. Tested: a call from the Dial button to another D-Modem connects at 62666 bit/s (V.91), and **Stop** hangs up. | +| Windows 7 and later | Not done. The library must build with clang-retro in the app. | +| Windows 95 to XP | Not done. Refer to "Windows 95" below. | +| macOS | Not done. Xcode must link the library. | + +### Windows 95 + +The Windows 95 build of the app uses the clang-retro configuration +`win32-picolibc`. It has a C library (picolibc) but no C++ library. The +modem is in C++17 and needs the `win98` configuration (msvcrt and libc++). +One program cannot use the two C libraries. Thus, an app with the built-in +modem will need Windows 98 SE or later. The Windows 95 build will continue +to use `dmodemd` on TCP, or a COM port. diff --git a/external/D-Modem b/external/D-Modem new file mode 160000 index 0000000..26f9919 --- /dev/null +++ b/external/D-Modem @@ -0,0 +1 @@ +Subproject commit 26f9919bb5d3c7ffb7460262b4066da55bfed78e diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index bb04c70..0445e63 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -14,6 +14,12 @@ add_executable(dmodem-gui src/termview.c src/audio.c) target_link_libraries(dmodem-gui PRIVATE dmodemctl dmodemssh PkgConfig::GTK) +# the modem built in (libdmodem_embed): no dmodemd to start +if(DMODEM_GUI_EMBED AND TARGET dmodem_embed) + target_link_libraries(dmodem-gui PRIVATE dmodem_embed) + target_compile_definitions(dmodem-gui PRIVATE DMODEM_GUI_EMBED) + set_target_properties(dmodem-gui PROPERTIES LINKER_LANGUAGE CXX) +endif() # where the MT9234MU's firmware is installed, and where it is in the source include(GNUInstallDirs) target_compile_definitions(dmodem-gui PRIVATE diff --git a/linux/src/app.h b/linux/src/app.h index a4280a1..3573fee 100644 --- a/linux/src/app.h +++ b/linux/src/app.h @@ -28,6 +28,9 @@ typedef struct Config { char *usb, *alsa; /* --usb's (auto), -a's (hw:1) */ char *device; /* the modem's device, "device" line */ char *dmodemd; /* its path, "" to look for it */ + /* the modem built into the app (libdmodem_embed, DMODEM_GUI_EMBED) + for the SIP, USB and ALSA lines; FALSE: dmodemd started */ + gboolean builtin; char *init; /* commands sent when the modem opens */ int debug; /* dmodemd -d */ /* the answering machine ([voice]): on, after how many RINGs, a @@ -60,6 +63,12 @@ struct App { /* the modem */ dmc_session *s; GSubprocess *proc; + /* the modem built in (modem.c; a struct dmodem_embed), when it + runs; its start's number, so that the news of an older start is + ignored */ + void *embed; + gboolean embed_running; + guint embed_gen; GCancellable *cancel; char *device; /* the DTE's path */ int fd; diff --git a/linux/src/config.c b/linux/src/config.c index 0638cac..6a29ef1 100644 --- a/linux/src/config.c +++ b/linux/src/config.c @@ -55,6 +55,7 @@ void config_load(Config *c) c->alsa = get_s(k, "alsa", "hw:1"); c->device = get_s(k, "device", "/dev/ttyDM0"); c->dmodemd = get_s(k, "dmodemd", ""); + c->builtin = get_b(k, "builtin", TRUE); c->init = get_s(k, "init", ""); c->debug = g_key_file_get_integer(k, "line", "debug", NULL); /* the answering machine: off until the user turns it on */ @@ -114,6 +115,7 @@ void config_save(const Config *c) g_key_file_set_string(k, "line", "alsa", c->alsa); g_key_file_set_string(k, "line", "device", c->device); g_key_file_set_string(k, "line", "dmodemd", c->dmodemd); + g_key_file_set_boolean(k, "line", "builtin", c->builtin); g_key_file_set_string(k, "line", "init", c->init); g_key_file_set_integer(k, "line", "debug", c->debug); g_key_file_set_boolean(k, "voice", "voicemail", c->voicemail); @@ -208,7 +210,7 @@ typedef struct Prefs { AdwEntryRow *user, *server, *country, *usb, *alsa, *device, *dmodemd, *init; AdwPasswordEntryRow *password; - AdwSwitchRow *anonymous, *listen, *t38, *v152, *v150; + AdwSwitchRow *anonymous, *listen, *t38, *v152, *v150, *builtin; AdwSpinRow *debug; AdwPreferencesGroup *sip, *usb_g, *alsa_g, *device_g; } Prefs; @@ -362,6 +364,9 @@ static void closed(AdwDialog *d, gpointer data) c->alsa = text_of(p->alsa); c->device = text_of(p->device); c->dmodemd = text_of(p->dmodemd); +#ifdef DMODEM_GUI_EMBED + c->builtin = adw_switch_row_get_active(p->builtin); +#endif c->init = text_of(p->init); c->debug = (int)adw_spin_row_get_value(p->debug); config_save(c); @@ -426,6 +431,10 @@ void prefs_show(App *a) AdwPreferencesGroup *adv = group(page, "Advanced", NULL); p->init = entry(adv, "Commands when the modem opens", c->init); +#ifdef DMODEM_GUI_EMBED + p->builtin = toggle(adv, "Built-in modem", "Run the modem in this " + "app. Off: start dmodemd", c->builtin); +#endif p->dmodemd = entry(adv, "dmodemd (empty to look for it)", c->dmodemd); GtkWidget *dbg = adw_spin_row_new_with_range(0, 9, 1); adw_preferences_row_set_title(ADW_PREFERENCES_ROW(dbg), diff --git a/linux/src/modem.c b/linux/src/modem.c index d05117f..d6eedab 100644 --- a/linux/src/modem.c +++ b/linux/src/modem.c @@ -8,6 +8,12 @@ * dmodemd runs as the user: it makes its pty and says where it is * ("Use `/dev/pts/3' as modem device"), and the app opens that. With * the "device" line nothing is started and the given device is opened. + * + * With the modem built in (DMODEM_GUI_EMBED, the "builtin" setting), + * the SIP, USB and ALSA lines start no dmodemd: libdmodem_embed runs the + * modem in a thread of the app, and its DTE is a socket in place of the + * pty. Its log lines and its end come from that thread, and go to the + * main loop with g_idle_add(). */ #include #include @@ -21,6 +27,10 @@ #include "app.h" +#ifdef DMODEM_GUI_EMBED +#include "dmodem_embed.h" +#endif + typedef struct Waiting { ResponseFn fn; gpointer data; @@ -140,6 +150,25 @@ static gboolean readable(gint fd, GIOCondition cond, gpointer data) return G_SOURCE_CONTINUE; } +/* the DTE fd (open, non-blocking) given to the session: name is what the + Modem page shows as its device */ +static void attach_dte(App *a, int fd, const char *name) +{ + a->fd = fd; + g_free(a->device); + a->device = g_strdup(name); + a->fd_watch = g_unix_fd_add(fd, G_IO_IN | G_IO_HUP | G_IO_ERR, + readable, a); + dmc_open(a->s, now_ms()); + window_opened(a); + /* the user's own commands first */ + if (*a->cfg.init) + modem_command(a, a->cfg.init, 0, NULL, NULL); + modem_pump(a); +} + +/* the device at path opened as the DTE (raw, 115200 bit/s): FALSE, with + a message, if it can't be */ static gboolean open_dte(App *a, const char *path) { int fd = open(path, O_RDWR | O_NOCTTY | O_NONBLOCK | O_CLOEXEC); @@ -163,20 +192,181 @@ static gboolean open_dte(App *a, const char *path) t.c_cflag |= CRTSCTS; tcsetattr(fd, TCSANOW, &t); } - a->fd = fd; - g_free(a->device); - a->device = g_strdup(path); - a->fd_watch = g_unix_fd_add(fd, G_IO_IN | G_IO_HUP | G_IO_ERR, - readable, a); - dmc_open(a->s, now_ms()); - window_opened(a); - /* the user's own commands first */ - if (*a->cfg.init) - modem_command(a, a->cfg.init, 0, NULL, NULL); - modem_pump(a); + attach_dte(a, fd, path); return TRUE; } +/* + * the modem built in (libdmodem_embed) + */ + +#ifdef DMODEM_GUI_EMBED +/* news from the modem's thread, for the main loop: a log line, or the + end (line NULL) with its status */ +typedef struct EmbedNews { + App *a; + guint gen; + char *line; + int status; +} EmbedNews; + +/* a log line, or the modem's end, on the main loop; news of an older + start is dropped */ +static gboolean embed_news(gpointer data) +{ + EmbedNews *n = data; + App *a = n->a; + if (n->gen == a->embed_gen) { + if (n->line) { + app_log(a, n->line); + if (dmc_daemon_error(n->line)) + window_toast(a, n->line + 7); + } else { + char *m = g_strdup_printf("The built-in modem stopped%s", + n->status < 0 ? + " (error)." : "."); + app_log(a, m); + if (n->status < 0) + window_toast(a, m); + g_free(m); + a->embed_running = FALSE; + close_dte(a); + window_state(a); + } + } + g_free(n->line); + g_free(n); + return G_SOURCE_REMOVE; +} + +/* the news of start gen (ctx) to the main loop */ +static void embed_post(App *a, guint gen, const char *line, int status) +{ + EmbedNews *n = g_new0(EmbedNews, 1); + n->a = a; + n->gen = gen; + n->line = line ? g_strdup(line) : NULL; + n->status = status; + g_idle_add(embed_news, n); +} + +/* the start that a callback is for: the app and the start's number */ +typedef struct EmbedCtx { + App *a; + guint gen; +} EmbedCtx; + +/* a line of the modem's log (the modem's thread) */ +static void embed_log(void *ctx, const char *line) +{ + EmbedCtx *c = ctx; + embed_post(c->a, c->gen, line, 0); +} + +/* the modem stopped (the modem's thread) */ +static void embed_exit(void *ctx, int status) +{ + EmbedCtx *c = ctx; + embed_post(c->a, c->gen, NULL, status); +} + +/* the line settings as libdmodem_embed has them; FALSE, with a message, + for a line it doesn't have */ +static gboolean embed_config(App *a, dmodem_embed_config *e) +{ + Config *c = &a->cfg; + dmodem_embed_config_init(e); + e->country = c->country; + e->log_level = c->debug; + if (!g_strcmp0(c->line, "usb")) { + e->line = DMODEM_EMBED_USB; + e->usb = c->usb; + } else if (!g_strcmp0(c->line, "alsa")) { + e->line = DMODEM_EMBED_ALSA; + e->alsa = c->alsa; + } else { + e->line = DMODEM_EMBED_SIP; + if (!c->sip_anonymous) { + e->sip_user = c->sip_user; + e->sip_password = c->sip_password; + e->sip_domain = c->sip_server; + } + e->sip_listen = c->listen; + e->sip_t38 = c->t38; + e->sip_v152 = c->v152; + e->sip_v150 = c->v150; + e->sip_srtp = !g_strcmp0(c->srtp, "no") ? 0 : + !g_strcmp0(c->srtp, "require") ? 2 : 1; + } + if (!(dmodem_embed_lines() & (1 << e->line))) { + window_toast(a, "The built-in modem has no such line in this " + "build: start dmodemd (line settings, Advanced)"); + return FALSE; + } + return TRUE; +} + +/* the modem started in the app on the line settings' line */ +static void embed_start(App *a) +{ + dmodem_embed_config e; + if (!embed_config(a, &e)) + return; + /* the data file of the line's measurements, where the user may + write it */ + char *dir = g_build_filename(g_get_user_data_dir(), "dmodem-gui", + NULL); + g_mkdir_with_parents(dir, 0700); + char *data = g_build_filename(dir, "dmodem0.data", NULL); + e.data_file = data; + if (!a->embed) + a->embed = dmodem_embed_new(); + if (!a->embed) { + g_free(dir); + g_free(data); + return; + } + /* (one context for each start, kept: the thread may use it until + its end) */ + EmbedCtx *ctx = g_new0(EmbedCtx, 1); + ctx->a = a; + ctx->gen = ++a->embed_gen; + dmodem_embed_on_log(a->embed, embed_log, ctx); + dmodem_embed_on_exit(a->embed, embed_exit, ctx); + int fd = dmodem_embed_start(a->embed, &e); + g_free(dir); + g_free(data); + if (fd < 0) { + char *m = g_strdup_printf("Can't start the built-in modem: %s", + dmodem_embed_error(a->embed)); + window_toast(a, m); + app_log(a, m); + g_free(m); + window_state(a); + return; + } + char *m = g_strdup_printf("The built-in modem (D-Modem %s) started.", + dmodem_embed_version()); + app_log(a, m); + g_free(m); + a->embed_running = TRUE; + attach_dte(a, fd, "Built-in modem"); + window_state(a); +} + +/* the modem built in stopped: its thread ended */ +static void embed_stop(App *a) +{ + if (!a->embed) + return; + /* (news of this start after now is not wanted) */ + a->embed_gen++; + dmodem_embed_stop(a->embed); + a->embed_running = FALSE; + app_log(a, "The built-in modem stopped."); +} +#endif + /* * dmodemd */ @@ -295,6 +485,17 @@ void modem_start(App *a) window_state(a); return; } +#ifdef DMODEM_GUI_EMBED + if (c->builtin) { + if (!g_strcmp0(c->line, "sip") && !config_sip_ready(c)) { + window_toast(a, "Set up the SIP account first"); + prefs_show(a); + return; + } + embed_start(a); + return; + } +#endif char *exe = find_dmodemd(c); if (!exe) { window_toast(a, "dmodemd was not found: install D-Modem, or " @@ -388,6 +589,15 @@ void modem_stop(App *a) close_dte(a); g_subprocess_send_signal(a->proc, SIGTERM); } else { +#ifdef DMODEM_GUI_EMBED + if (a->embed_running) { + /* hang up first, so the call ends cleanly */ + if (a->fd >= 0) + dmc_hangup(a->s); + modem_pump(a); + embed_stop(a); + } +#endif close_dte(a); } window_state(a); @@ -395,7 +605,7 @@ void modem_stop(App *a) gboolean modem_running(App *a) { - return a->proc != NULL || a->fd >= 0; + return a->proc != NULL || a->embed_running || a->fd >= 0; } void modem_type(App *a, const char *data, gsize n) diff --git a/linux/src/window.c b/linux/src/window.c index 49bca06..1ab4a7f 100644 --- a/linux/src/window.c +++ b/linux/src/window.c @@ -75,6 +75,13 @@ void window_state(App *a) gtk_widget_remove_css_class(a->run_btn, "suggested-action"); else gtk_widget_add_css_class(a->run_btn, "suggested-action"); + /* (what runs the line: the modem built in, or dmodemd) */ + gboolean builtin = FALSE; +#ifdef DMODEM_GUI_EMBED + builtin = a->cfg.builtin && g_strcmp0(a->cfg.line, "device"); +#endif + adw_preferences_row_set_title(ADW_PREFERENCES_ROW(a->run_row), + builtin ? "Built-in modem" : "dmodemd"); char *sum = config_summary(&a->cfg); adw_action_row_set_subtitle(ADW_ACTION_ROW(a->run_row), sum); g_free(sum); diff --git a/ssh/cmake/BundledLibssh.cmake b/ssh/cmake/BundledLibssh.cmake index 19c4239..144991e 100644 --- a/ssh/cmake/BundledLibssh.cmake +++ b/ssh/cmake/BundledLibssh.cmake @@ -3,8 +3,8 @@ include(FetchContent) include(ExternalProject) -set(DMODEM_MBEDTLS_URL https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.4/mbedtls-3.6.4.tar.bz2) -set(DMODEM_MBEDTLS_SHA256 ec35b18a6c593cf98c3e30db8b98ff93e8940a8c4e690e66b41dfc011d678110) +set(DMODEM_MBEDTLS_URL https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.7/mbedtls-3.6.7.tar.bz2) +set(DMODEM_MBEDTLS_SHA256 a7e8bcbec0e6f761b4af24f25677626b35f762f68eef79c08677a363212d11f6) set(DMODEM_LIBSSH_URL https://www.libssh.org/files/0.11/libssh-0.11.3.tar.xz) set(DMODEM_LIBSSH_SHA256 7d8a1361bb094ec3f511964e78a5a4dba689b5986e112afabe4f4d0d6c6125c3) @@ -63,10 +63,13 @@ ExternalProject_Add(dmodem_mbedtls -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DMBEDTLS_FATAL_WARNINGS=OFF BUILD_BYPRODUCTS ${_mbed_paths}) -# (Bionic has no S_IWRITE, the old name libssh uses) +# libssh's sha1() and sha256() renamed: libre (in the modem built in, +# DMODEM_GUI_EMBED) has functions of the same names set(_ssh_args) +set(_ssh_cflags "-Dsha1=dmodem_ssh_sha1 -Dsha256=dmodem_ssh_sha256") +# (Bionic has no S_IWRITE, the old name libssh uses) if(ANDROID) - list(APPEND _ssh_args -DCMAKE_C_FLAGS=-DS_IWRITE=S_IWUSR) + string(APPEND _ssh_cflags " -DS_IWRITE=S_IWUSR") endif() # clang-retro (cmake/clang-retro.cmake): its clang, newer than MinGW's # GCC, makes an error of src/threads/mbedtls.c's casts of libssh's mutex @@ -77,13 +80,13 @@ endif() # Windows, and its conflicts with , so libssh # uses none of them. if(CLANG_DOS) - set(_ssh_cflags -Wno-error=incompatible-function-pointer-types) + string(APPEND _ssh_cflags " -Wno-error=incompatible-function-pointer-types") if(CLANG_RETRO_CONFIG MATCHES "picolibc") string(APPEND _ssh_cflags " -D_DEFAULT_SOURCE -D__STDC_WANT_LIB_EXT1__=1 -I${CMAKE_CURRENT_LIST_DIR}/picolibc") list(APPEND _ssh_args -DHAVE_ARPA_INET_H= -DHAVE_IO_H= -DHAVE_TERMIOS_H=) endif() - list(APPEND _ssh_args "-DCMAKE_C_FLAGS=${_ssh_cflags}") endif() +list(APPEND _ssh_args "-DCMAKE_C_FLAGS=${_ssh_cflags}") # (WITH_SERVER: libssh runs a client's callbacks for the channels the # server opens, the forwarded agent's, only when it's built with it)