blob: 3a8a2e17bdbe65a02a152b58052cf26e8d277138 [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
Jacob Erlbeck53670862015-05-12 17:54:33 +020027#include "cxx_linuxlist.h"
Jacob Erlbecke04e0b02015-05-06 18:30:48 +020028#include <stdint.h>
29#include <stddef.h>
30
31class GprsMs {
32public:
33 struct Callback {
34 virtual void ms_idle(class GprsMs *) = 0;
35 virtual void ms_active(class GprsMs *) = 0;
36 };
37
38 class Guard {
39 public:
40 Guard(GprsMs *ms);
41 ~Guard();
42
43 private:
44 GprsMs * const m_ms;
45 };
46
47 GprsMs(uint32_t tlli);
48 ~GprsMs();
49
50 void set_callback(Callback *cb) {m_cb = cb;}
51
52 gprs_rlcmac_ul_tbf *ul_tbf() const {return m_ul_tbf;}
53 gprs_rlcmac_dl_tbf *dl_tbf() const {return m_dl_tbf;}
54 uint32_t tlli() const {return m_tlli;}
55 void set_tlli(uint32_t tlli);
56
57 void attach_tbf(gprs_rlcmac_tbf *tbf);
58 void attach_ul_tbf(gprs_rlcmac_ul_tbf *tbf);
59 void attach_dl_tbf(gprs_rlcmac_dl_tbf *tbf);
60
61 void detach_tbf(gprs_rlcmac_tbf *tbf);
62
63 bool is_idle() const {return !m_ul_tbf && !m_dl_tbf && !m_ref;}
64
65 void* operator new(size_t num);
66 void operator delete(void* p);
67
Jacob Erlbeck53670862015-05-12 17:54:33 +020068 LListHead<GprsMs>& list() {return this->m_list;}
69 const LListHead<GprsMs>& list() const {return this->m_list;}
70
Jacob Erlbecke04e0b02015-05-06 18:30:48 +020071protected:
72 void update_status();
73 void ref();
74 void unref();
75
76private:
77 Callback * m_cb;
78 gprs_rlcmac_ul_tbf *m_ul_tbf;
79 gprs_rlcmac_dl_tbf *m_dl_tbf;
80 uint32_t m_tlli;
81 bool m_is_idle;
82 int m_ref;
Jacob Erlbeck53670862015-05-12 17:54:33 +020083 LListHead<GprsMs> m_list;
Jacob Erlbecke04e0b02015-05-06 18:30:48 +020084};