blob: 0ea9937ad51f9cc6262a90aaf7ebd679f6eb4770 [file] [log] [blame]
Harald Welte39cfbf42016-07-28 09:04:11 +02001#pragma once
2#include <stdint.h>
3
4enum osmo_e1cap_capture_mode {
5 OSMO_E1CAP_MODE_RAW,
6 OSMO_E1CAP_MODE_HDLC,
7 OSMO_E1CAP_MODE_TRAU,
8 OSMO_E1CAP_MODE_PGSL,
9};
10
11/* header for each frame we store */
12struct osmo_e1cap_pkthdr {
Harald Welteafb6d392016-10-17 18:50:19 +020013 /* Timestamp at which frame was received */
Harald Welte456888a2019-11-24 18:02:51 +010014 struct {
15 uint32_t tv_sec;
16 uint32_t tv_usec;
17 } ts;
Harald Welteafb6d392016-10-17 18:50:19 +020018 /* length of frame data after this header */
Harald Welte39cfbf42016-07-28 09:04:11 +020019 uint32_t len;
Harald Welteafb6d392016-10-17 18:50:19 +020020 /* line/span number on which frame was received */
Harald Welte39cfbf42016-07-28 09:04:11 +020021 uint8_t line_nr;
Harald Welteafb6d392016-10-17 18:50:19 +020022 /* timeslot number on which frame was received */
Harald Welte39cfbf42016-07-28 09:04:11 +020023 uint8_t ts_nr;
Harald Welteafb6d392016-10-17 18:50:19 +020024 /* see osmo_e1cap_capture_mode */
Harald Welte39cfbf42016-07-28 09:04:11 +020025 uint8_t capture_mode;
Harald Welteafb6d392016-10-17 18:50:19 +020026 /* any optional future flags */
Harald Welte39cfbf42016-07-28 09:04:11 +020027 uint8_t flags;
Harald Welte232b9722016-10-18 23:50:49 +020028 uint8_t align[8];
29 uint8_t data[0];
30} __attribute__((packed));
31
32struct msgb;
33struct e1inp_ts;
Harald Welte39cfbf42016-07-28 09:04:11 +020034
35int e1frame_store(struct e1inp_ts *ts, struct msgb *msg, enum osmo_e1cap_capture_mode mode);
Harald Weltedf7a3062016-10-19 10:47:17 +020036void storage_close(void);
Harald Weltedbb0f5a2016-10-18 23:51:54 +020037
38struct osmo_e1cap_file;
39struct osmo_e1cap_file *osmo_e1cap_open(void *ctx, const char *path);
40struct osmo_e1cap_pkthdr *osmo_e1cap_read_next(struct osmo_e1cap_file *f);