From: Seppo Takalo Date: Thu, 24 Jul 2025 11:38:59 +0000 (+0300) Subject: ldattach: Allow changing the MTU for GSM0710 framing X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=308811f67d68403ce1671a6863efa92d41ee2544;p=thirdparty%2Futil-linux.git ldattach: Allow changing the MTU for GSM0710 framing Traditionally ldattach have hard coded MTU of 127 bytes which differs from defaults proposed in 3GPP TS 27.010 which is 31 bytes when basic framing is used. Add '-m ' parameter that is only GSM0710 specific and already handled by the kernel. Use same value for both MTU and MRU. Signed-off-by: Seppo Takalo --- diff --git a/bash-completion/ldattach b/bash-completion/ldattach index 02b4b5b93..878037d47 100644 --- a/bash-completion/ldattach +++ b/bash-completion/ldattach @@ -28,6 +28,10 @@ _ldattach_module() COMPREPLY=( $(compgen -W "$IFLAGS" -- $cur) ) return 0 ;; + '-m'|'--mtu') + COMPREPLY=( $(compgen -W "mtu" -- $cur) ) + return 0 + ;; '-h'|'--help'|'-V'|'--version') return 0 ;; @@ -46,6 +50,7 @@ _ldattach_module() --onestopbit --twostopbits --iflag + --mtu --help --version" COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) diff --git a/sys-utils/ldattach.8.adoc b/sys-utils/ldattach.8.adoc index 6a51d672b..6025e6082 100644 --- a/sys-utils/ldattach.8.adoc +++ b/sys-utils/ldattach.8.adoc @@ -18,7 +18,7 @@ ldattach - attach a line discipline to a serial line == SYNOPSIS -*ldattach* [*-1278denoVh*] [*-i* _iflag_] [*-s* _speed_] _ldisc device_ +*ldattach* [*-1278denoVh*] [*-i* _iflag_] [*-s* _speed_] [*-m* _mtu_] _ldisc device_ == DESCRIPTION @@ -111,6 +111,9 @@ Define an intro command that is sent through the serial line before the invocati *-p*, *--pause* _value_:: Sleep for _value_ seconds before the invocation of *ldattach*. Default is one second. +*-m*, *--mtu* _value_:: +Set maximum frame size for GSM0710 CMUX. If not specified, traditionally the default of 127 have been set by *ldattach*. This differs from 3GPP TS 27.010 default value of 31 bytes, so it is recommended to specify + include::man-common/help-version.adoc[] == AUTHORS diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c index 25903b4eb..0bc97c903 100644 --- a/sys-utils/ldattach.c +++ b/sys-utils/ldattach.c @@ -217,6 +217,9 @@ static void __attribute__((__noreturn__)) usage(void) fputs(USAGE_SEPARATOR, out); fprintf(out, USAGE_HELP_OPTIONS(25)); + fputs(_("\nOptions relevant to GSM0710:\n"), out); + fputs(_(" -m, --mtu set CMUX maximum frame size\n"), out); + fputs(_("\nKnown names:\n"), out); print_table(out, ld_discs); fputs(USAGE_SEPARATOR, out); @@ -260,22 +263,19 @@ static void handler(int s) _exit(EXIT_SUCCESS); } -static void gsm0710_set_conf(int tty_fd) +static void gsm0710_set_conf(int tty_fd, unsigned int mtu) { struct gsm_config c; - /* Add by guowenxue */ /* get n_gsm configuration */ ioctl(tty_fd, GSMIOC_GETCONF, &c); /* we are initiator and need encoding 0 (basic) */ c.initiator = 1; c.encapsulation = 0; - /* our modem defaults to a maximum size of 127 bytes */ - c.mru = 127; - c.mtu = 127; + c.mru = mtu; + c.mtu = mtu; /* set the new configuration */ ioctl(tty_fd, GSMIOC_SETCONF, &c); - /* Add by guowenxue end*/ } int main(int argc, char **argv) @@ -289,6 +289,7 @@ int main(int argc, char **argv) char *dev; int intropause = 1; char *introparm = NULL; + unsigned int gsm_mtu = 127; /* traditional default */ static const struct option opttbl[] = { {"speed", required_argument, NULL, 's'}, @@ -305,6 +306,7 @@ int main(int argc, char **argv) {"debug", no_argument, NULL, 'd'}, {"intro-command", required_argument, NULL, 'c'}, {"pause", required_argument, NULL, 'p'}, + {"mtu", required_argument, NULL, 'm'}, {NULL, 0, NULL, 0} }; @@ -321,7 +323,7 @@ int main(int argc, char **argv) errx(EXIT_FAILURE, _("bad usage")); while ((optc = - getopt_long(argc, argv, "dhV78neo12s:i:c:p:", opttbl, + getopt_long(argc, argv, "dhV78neo12s:i:c:p:m:", opttbl, NULL)) >= 0) { switch (optc) { case 'd': @@ -348,6 +350,9 @@ int main(int argc, char **argv) if (intropause > 10) errx(EXIT_FAILURE, "invalid pause: %s", optarg); break; + case 'm': + gsm_mtu = str2num_or_err(optarg, 10, _("invalid MTU argument"), 1, 32768); + break; case 'c': introparm = optarg; break; @@ -476,7 +481,7 @@ int main(int argc, char **argv) /* ldisc specific post-attach actions */ if (ldisc == N_GSM0710) - gsm0710_set_conf(tty_fd); + gsm0710_set_conf(tty_fd, gsm_mtu); /* Go into background if not in debug mode. */ if (!debug && daemon(0, 0) < 0)