diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2019-05-11 22:31:12 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2019-05-11 22:31:12 +0200 |
commit | cf189940be05ac0df56ce188ea870e9e80579091 (patch) | |
tree | e106a5e471bb34dfd1a1ddfabe15915388284f15 /include |
Initial code import
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 1 | ||||
-rw-r--r-- | include/osmocom/e1d/proto.h | 109 | ||||
-rw-r--r-- | include/osmocom/e1d/proto_clnt.h | 47 | ||||
-rw-r--r-- | include/osmocom/e1d/proto_srv.h | 49 |
4 files changed, 206 insertions, 0 deletions
diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..e74dd6e --- /dev/null +++ b/include/Makefile.am @@ -0,0 +1 @@ +nobase_include_HEADERS = osmocom/e1d/proto_clnt.h osmocom/e1d/proto.h osmocom/e1d/proto_srv.h diff --git a/include/osmocom/e1d/proto.h b/include/osmocom/e1d/proto.h new file mode 100644 index 0000000..a3c94bb --- /dev/null +++ b/include/osmocom/e1d/proto.h @@ -0,0 +1,109 @@ +/* + * proto.h + * + * (C) 2019 by Sylvain Munaut <tnt@246tNt.com> + * + * All Rights Reserved + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include <stdint.h> + +#include <osmocom/core/select.h> + + +/* E1DP_CMD_INTF_QUERY + * filter: intf (optional) + * in: n/a + * out: array of osmo_e1dp_intf_info + * + * E1DP_CMD_LINE_QUERY + * filter: intf (required), line (optional) + * in: n/a + * out: array of osmo_e1dp_line_info + * + * E1DP_CMD_TS_QUERY + * filter: intf (required), line (required), ts (optional) + * in: n/a + * out: array of osmo_e1dp_ts_info + * + * E1DP_CMD_TS_OPEN + * filter: intf (required), line (required), ts (required) + * in: osmo_e1dp_ts_config + * out: osmo_e1dp_ts_info with the opened TS (or an invalid one with id == -1 for errors) + * + message with the file descriptor + */ + +enum osmo_e1dp_msg_type { + E1DP_CMD_INTF_QUERY = 0x00, + E1DP_CMD_LINE_QUERY = 0x01, + E1DP_CMD_TS_QUERY = 0x02, + E1DP_CMD_TS_OPEN = 0x04, + E1DP_EVT_TYPE = 0x40, + E1DP_RESP_TYPE = 0x80, + E1DP_ERR_TYPE = 0xc0, + E1DP_TYPE_MSK = 0xc0, +}; + +enum osmo_e1dp_ts_mode { + E1DP_TSMODE_OFF = 0x00, + E1DP_TSMODE_RAW = 0x10, + E1DP_TSMODE_HDLCFCS = 0x11, +}; + + +#define E1DP_MAGIC 0x00e1 +#define E1DP_MAX_LEN 4096 +#define E1DP_INVALID 0xff + + +struct osmo_e1dp_msg_hdr { + uint16_t magic; + uint16_t len; + + uint8_t type; + uint8_t intf; + uint8_t line; + uint8_t ts; +} __attribute__((packed)); + +struct osmo_e1dp_intf_info { + uint8_t id; + uint8_t n_lines; +} __attribute__((packed)); + +struct osmo_e1dp_line_info { + uint8_t id; + uint8_t status; /* TBD */ +} __attribute__((packed)); + +struct osmo_e1dp_ts_config { + uint8_t mode; +} __attribute__((packed)); + +struct osmo_e1dp_ts_info { + uint8_t id; + struct osmo_e1dp_ts_config cfg; + uint8_t status; /* TBD */ +} __attribute__((packed)); + + +struct msgb *osmo_e1dp_recv(struct osmo_fd *ofd, int *fd); +int osmo_e1dp_send(struct osmo_fd *ofd, struct msgb *msgb, int fd); diff --git a/include/osmocom/e1d/proto_clnt.h b/include/osmocom/e1d/proto_clnt.h new file mode 100644 index 0000000..9288af9 --- /dev/null +++ b/include/osmocom/e1d/proto_clnt.h @@ -0,0 +1,47 @@ +/* + * proto_clnt.h + * + * (C) 2019 by Sylvain Munaut <tnt@246tNt.com> + * + * All Rights Reserved + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include <osmocom/core/msgb.h> + +#include <osmocom/e1d/proto.h> + +struct osmo_e1dp_client; + +struct osmo_e1dp_client *osmo_e1dp_client_create(void *ctx, const char *path); +void osmo_e1dp_client_destroy(struct osmo_e1dp_client *srv); + +int osmo_e1dp_client_intf_query(struct osmo_e1dp_client *clnt, + struct osmo_e1dp_intf_info **ii, int *n, + uint8_t intf); +int osmo_e1dp_client_line_query(struct osmo_e1dp_client *clnt, + struct osmo_e1dp_line_info **li, int *n, + uint8_t intf, uint8_t line); +int osmo_e1dp_client_ts_query(struct osmo_e1dp_client *clnt, + struct osmo_e1dp_ts_info **ti, int *n, + uint8_t intf, uint8_t line, uint8_t ts); +int osmo_e1dp_client_ts_open(struct osmo_e1dp_client *clnt, + uint8_t intf, uint8_t line, uint8_t ts, + enum osmo_e1dp_ts_mode mode); diff --git a/include/osmocom/e1d/proto_srv.h b/include/osmocom/e1d/proto_srv.h new file mode 100644 index 0000000..c5faec8 --- /dev/null +++ b/include/osmocom/e1d/proto_srv.h @@ -0,0 +1,49 @@ +/* + * proto_srv.h + * + * (C) 2019 by Sylvain Munaut <tnt@246tNt.com> + * + * All Rights Reserved + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include <osmocom/core/msgb.h> + +struct osmo_e1dp_server; + +#define E1DP_SF_INTF_OPT (1<<0) +#define E1DP_SF_INTF_REQ (1<<1) +#define E1DP_SF_LINE_OPT (1<<2) +#define E1DP_SF_LINE_REQ (1<<3) +#define E1DP_SF_TS_OPT (1<<4) +#define E1DP_SF_TS_REQ (1<<5) + +typedef int (*osmo_e1dp_server_handler_fn)(void *data, struct msgb *msgb, struct msgb *rmsgb, int *rfd); + +struct osmo_e1dp_server_handler { + uint8_t type; + int flags; + int payload_len; + osmo_e1dp_server_handler_fn fn; +}; + +struct osmo_e1dp_server *osmo_e1dp_server_create(void *ctx, const char *path, + struct osmo_e1dp_server_handler *handlers, void *handler_data); +void osmo_e1dp_server_destroy(struct osmo_e1dp_server *srv); |