File: ldattach-Allow-changing-the-MTU-for-GSM0710-framing.patch

package info (click to toggle)
util-linux 2.41.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 92,992 kB
  • sloc: ansic: 179,068; sh: 22,693; yacc: 1,284; makefile: 530; xml: 422; python: 316; lex: 89; ruby: 75; csh: 37; exp: 19; sed: 16; perl: 15; sql: 9
file content (149 lines) | stat: -rw-r--r-- 4,761 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
From: Seppo Takalo <seppo.takalo@nordicsemi.no>
Date: Thu, 24 Jul 2025 14:38:59 +0300
Subject: 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 <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  |  5 +++++
 sys-utils/ldattach.8.adoc |  5 ++++-
 sys-utils/ldattach.c      | 21 +++++++++++++--------
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/bash-completion/ldattach b/bash-completion/ldattach
index 02b4b5b..878037d 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 07549fb..20001a7 100644
--- a/sys-utils/ldattach.8.adoc
+++ b/sys-utils/ldattach.8.adoc
@@ -16,7 +16,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
 
@@ -109,6 +109,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 e06047c..98fbe83 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 <value>  set CMUX maximum frame size\n"), out);
+
 	fputs(_("\nKnown <ldisc> names:\n"), out);
 	print_table(out, ld_discs);
 	fputs(USAGE_SEPARATOR, out);
@@ -258,22 +261,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)
@@ -287,6 +287,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'},
@@ -303,6 +304,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}
 	};
 
@@ -319,7 +321,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':
@@ -346,6 +348,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;
@@ -474,7 +479,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)