blob: c7c1890dcc5afceebe60c8d37025458e9a1ee85b [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 Welte39cfbf42016-07-28 09:04:11 +020014 struct timeval ts;
Harald Welteafb6d392016-10-17 18:50:19 +020015 /* length of frame data after this header */
Harald Welte39cfbf42016-07-28 09:04:11 +020016 uint32_t len;
Harald Welteafb6d392016-10-17 18:50:19 +020017 /* line/span number on which frame was received */
Harald Welte39cfbf42016-07-28 09:04:11 +020018 uint8_t line_nr;
Harald Welteafb6d392016-10-17 18:50:19 +020019 /* timeslot number on which frame was received */
Harald Welte39cfbf42016-07-28 09:04:11 +020020 uint8_t ts_nr;
Harald Welteafb6d392016-10-17 18:50:19 +020021 /* see osmo_e1cap_capture_mode */
Harald Welte39cfbf42016-07-28 09:04:11 +020022 uint8_t capture_mode;
Harald Welteafb6d392016-10-17 18:50:19 +020023 /* any optional future flags */
Harald Welte39cfbf42016-07-28 09:04:11 +020024 uint8_t flags;
Harald Welte232b9722016-10-18 23:50:49 +020025 uint8_t align[8];
26 uint8_t data[0];
27} __attribute__((packed));
28
29struct msgb;
30struct e1inp_ts;
Harald Welte39cfbf42016-07-28 09:04:11 +020031
32int e1frame_store(struct e1inp_ts *ts, struct msgb *msg, enum osmo_e1cap_capture_mode mode);
Harald Weltedf7a3062016-10-19 10:47:17 +020033void storage_close(void);
Harald Weltedbb0f5a2016-10-18 23:51:54 +020034
35struct osmo_e1cap_file;
36struct osmo_e1cap_file *osmo_e1cap_open(void *ctx, const char *path);
37struct osmo_e1cap_pkthdr *osmo_e1cap_read_next(struct osmo_e1cap_file *f);