blob: a59fc5be8412b87957e27d1da6f8877fa374e0b1 [file] [log] [blame]
Jacob Erlbecke04e0b02015-05-06 18:30:48 +02001/* gprs_ms.h
2 *
3 * Copyright (C) 2015 by Sysmocom s.f.m.c. GmbH
4 * Author: Jacob Erlbeck <jerlbeck@sysmocom.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#pragma once
22
23struct gprs_rlcmac_tbf;
24struct gprs_rlcmac_dl_tbf;
25struct gprs_rlcmac_ul_tbf;
26
27#include <stdint.h>
28#include <stddef.h>
29
30class GprsMs {
31public:
32 struct Callback {
33 virtual void ms_idle(class GprsMs *) = 0;
34 virtual void ms_active(class GprsMs *) = 0;
35 };
36
37 class Guard {
38 public:
39 Guard(GprsMs *ms);
40 ~Guard();
41
42 private:
43 GprsMs * const m_ms;
44 };
45
46 GprsMs(uint32_t tlli);
47 ~GprsMs();
48
49 void set_callback(Callback *cb) {m_cb = cb;}
50
51 gprs_rlcmac_ul_tbf *ul_tbf() const {return m_ul_tbf;}
52 gprs_rlcmac_dl_tbf *dl_tbf() const {return m_dl_tbf;}
53 uint32_t tlli() const {return m_tlli;}
54 void set_tlli(uint32_t tlli);
55
56 void attach_tbf(gprs_rlcmac_tbf *tbf);
57 void attach_ul_tbf(gprs_rlcmac_ul_tbf *tbf);
58 void attach_dl_tbf(gprs_rlcmac_dl_tbf *tbf);
59
60 void detach_tbf(gprs_rlcmac_tbf *tbf);
61
62 bool is_idle() const {return !m_ul_tbf && !m_dl_tbf && !m_ref;}
63
64 void* operator new(size_t num);
65 void operator delete(void* p);
66
67protected:
68 void update_status();
69 void ref();
70 void unref();
71
72private:
73 Callback * m_cb;
74 gprs_rlcmac_ul_tbf *m_ul_tbf;
75 gprs_rlcmac_dl_tbf *m_dl_tbf;
76 uint32_t m_tlli;
77 bool m_is_idle;
78 int m_ref;
79};