]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ldattach: Allow changing the MTU for GSM0710 framing
authorSeppo Takalo <seppo.takalo@nordicsemi.no>
Thu, 24 Jul 2025 11:38:59 +0000 (14:38 +0300)
committerSeppo Takalo <seppo.takalo@nordicsemi.no>
Mon, 28 Jul 2025 10:43:56 +0000 (13:43 +0300)
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 <value>' 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 <seppo.takalo@nordicsemi.no>
bash-completion/ldattach
sys-utils/ldattach.8.adoc
sys-utils/ldattach.c

index 02b4b5b93db34ca4fb455c0e2671188742c74f20..878037d47ad04db6b05472b8f60f90dbdadc8ee6 100644 (file)
@@ -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) )
index 6a51d672b004c175454874004acf3bac8573c486..6025e6082eefea47ff975e11d8aa6f058fbf201d 100644 (file)
@@ -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
index 25903b4eb737b9df9c3e66bee3b724b5ca8fcfaa..0bc97c90393c345298f686a3c90e8c6c96d2e45b 100644 (file)
@@ -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 <value>  set CMUX maximum frame size\n"), out);
+
        fputs(_("\nKnown <ldisc> 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)