Skip to content

Commit 26f0a44

Browse files
committed
netutils/cmux: Add support for CMUX protocol
This commit adds CMUX (GSM 07.10) protocol support to netutils. CMUX allows multiplexing multiple virtual serial connections over a single physical serial link. Changes include: - CMUX protocol implementation - CRC table for frame validation - Basic frame handling Signed-off-by: Halysson <[email protected]>
1 parent bc73779 commit 26f0a44

File tree

7 files changed

+1213
-0
lines changed

7 files changed

+1213
-0
lines changed

include/netutils/cmux.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/****************************************************************************
2+
* apps/include/netutils/cmux.h
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed to the Apache Software Foundation (ASF) under one or more
7+
* contributor license agreements. See the NOTICE file distributed with
8+
* this work for additional information regarding copyright ownership. The
9+
* ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
* "License"); you may not use this file except in compliance with the
11+
* License. You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
* License for the specific language governing permissions and limitations
19+
* under the License.
20+
*
21+
****************************************************************************/
22+
23+
#ifndef __APPS_INCLUDE_NETUTILS_CMUX_H
24+
#define __APPS_INCLUDE_NETUTILS_CMUX_H
25+
26+
/****************************************************************************
27+
* Included Files
28+
****************************************************************************/
29+
30+
#include <sys/time.h>
31+
#include <stdbool.h>
32+
#include <debug.h>
33+
#include <errno.h>
34+
35+
/****************************************************************************
36+
* Public Types
37+
****************************************************************************/
38+
39+
struct cmux_settings_s
40+
{
41+
FAR const char *tty_name;
42+
FAR const char *script;
43+
int total_channels;
44+
};
45+
46+
/****************************************************************************
47+
* Public Function Prototypes
48+
****************************************************************************/
49+
50+
#undef EXTERN
51+
#if defined(__cplusplus)
52+
#define EXTERN extern "C"
53+
extern "C"
54+
{
55+
#else
56+
#define EXTERN extern
57+
#endif
58+
59+
int cmux_create(struct cmux_settings_s *settings);
60+
61+
#undef EXTERN
62+
#ifdef __cplusplus
63+
}
64+
#endif
65+
66+
#endif /* __APPS_INCLUDE_NETUTILS_CMUX_H */

netutils/cmux/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ##############################################################################
2+
# apps/netutils/cmux/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_NETUTILS_CMUX)
24+
target_sources(apps PRIVATE cmux.c)
25+
endif()

netutils/cmux/Kconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config NETUTILS_CMUX
7+
bool "Cmux tool"
8+
default n
9+
---help---
10+
Enable the CMUX (GSM 07.10) multiplexing protocol utility.
11+
CMUX allows multiplexing multiple virtual serial connections
12+
over a single physical serial link, commonly used with GSM/LTE
13+
modems to simultaneously handle AT commands, data connections,
14+
and other communication channels.
15+
16+
if NETUTILS_CMUX
17+
18+
endif # NETUTILS_CMUX

netutils/cmux/Make.defs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/netutils/cmux/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_NETUTILS_CMUX),)
24+
CONFIGURED_APPS += $(APPDIR)/netutils/cmux
25+
endif

netutils/cmux/Makefile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
############################################################################
2+
# apps/netutils/cmux/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http:#www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
CSRCS = cmux.c
26+
27+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)