summaryrefslogtreecommitdiff
path: root/src/gsmd/gsmd.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gsmd/gsmd.h')
-rw-r--r--src/gsmd/gsmd.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/gsmd/gsmd.h b/src/gsmd/gsmd.h
new file mode 100644
index 0000000..ff05a27
--- /dev/null
+++ b/src/gsmd/gsmd.h
@@ -0,0 +1,68 @@
+#ifndef __GSMD_H
+#define __GSMD_H
+
+#include <sys/types.h>
+
+#include <common/linux_list.h>
+
+#include "select.h"
+
+/* Refer to 3GPP TS 07.07 v 7.8.0, Chapter 4.1 */
+#define LGSM_ATCMD_F_EXTENDED 0x01 /* as opposed to basic */
+#define LGSM_ATCMD_F_PARAM 0x02 /* as opposed to action */
+
+struct gsmd_atcmd {
+ struct llist_head list;
+ void *ctx;
+ int (*cb)(struct gsmd_atcmd *, void *);
+ u_int8_t flags;
+ int32_t ret;
+ u_int32_t buflen;
+ char buf[];
+};
+
+enum llparse_state {
+ LLPARSE_STATE_IDLE, /* idle, not parsing a response */
+ LLPARSE_STATE_IDLE_CR, /* CR before response (V1) */
+ LLPARSE_STATE_IDLE_LF, /* LF before response (V1) */
+ LLPARSE_STATE_RESULT, /* within result payload */
+ LLPARSE_STATE_RESULT_CR, /* CR after result */
+ LLPARSE_STATE_ERROR, /* something went wrong */
+ /* ... idle again */
+};
+
+/* we can't take any _single_ response bigger than this: */
+#define LLPARSE_BUF_SIZE 256
+
+struct llparser {
+ enum llparse_state state;
+ unsigned int len;
+ unsigned int flags;
+ void *ctx;
+ int (*cb)(const char *buf, int len, void *ctx);
+ char *cur;
+ char buf[LLPARSE_BUF_SIZE];
+};
+
+#define GSMD_FLAG_V0 0x0001 /* V0 responses to be expected from TA */
+
+struct gsmd {
+ unsigned int flags;
+ struct gsmd_fd gfd_uart;
+ struct gsmd_fd gfd_sock;
+ struct llparser llp;
+ struct llist_head users;
+ struct llist_head pending_atcmds; /* our busy gsmd_atcmds */
+ struct llist_head busy_atcmds; /* our busy gsmd_atcmds */
+};
+
+struct gsmd_user {
+ struct llist_head list; /* our entry in the global list */
+ struct llist_head finished_ucmds; /* our busy gsmd_ucmds */
+ struct gsmd *gsmd;
+ struct gsmd_fd gfd; /* the socket */
+ u_int32_t subscriptions; /* bitmaks of subscribed event groups */
+};
+
+#define DEBUGP(x, args ...) printf("%s:%s(%d):" x, __FILE__, __FUNCTION__, __LINE__, ## args)
+#endif
personal git repositories of Harald Welte. Your mileage may vary