WIP: Implement packet access procedure FSM

Change-Id: I1dcaa593c6805873ef38511d4d562515b52c1f92
pespin/packet-access-procedure
Pau Espin 2023-06-22 18:46:47 +02:00
parent 3211489649
commit e2537fb2d4
4 changed files with 82 additions and 0 deletions

View File

@ -10,6 +10,7 @@ noinst_HEADERS = \
gps.h \
sysinfo.h \
osmocom_data.h \
pkt_acc_proc_fsm.h \
utils.h \
sap_proto.h \
sap_fsm.h \

View File

@ -0,0 +1,31 @@
/* Packet Access Procedure FSM */
#pragma once
#include <osmocom/core/fsm.h>
struct osmocom_ms;
enum apn_fsm_states {
PKT_ACC_PROC_ST_IDLE,
PKT_ACC_PROC_ST_ACTIVE,
};
enum pkt_acc_proc_fsm_events {
APN_EV_GPRS_ALLOWED, /* data: bool *allowed */
APN_EV_GMM_ATTACHED,
APN_EV_GMM_DETACHED,
APN_EV_RX_SM_ACT_PDP_CTX_REJ, /* data: enum gsm48_gsm_cause *cause */
APN_EV_RX_SM_ACT_PDP_CTX_ACC,
APN_EV_RX_SM_DEACT_PDP_CTX_ACC,
};
struct pkt_acc_proc_fsm_ctx {
struct osmo_fsm_inst *fi;
struct osmocom_ms *ms;
uint8_t chan_req;
};
int pkt_acc_proc_fsm_ctx_init(struct pkt_acc_proc_fsm_ctx *ctx, struct osmocom_ms *ms);
void pkt_acc_proc_fsm_ctx_release(struct pkt_acc_proc_fsm_ctx *ctx);
int pkt_acc_proc_start(struct pkt_acc_proc_fsm_ctx *ctx, uint8_t chan_req);

View File

@ -24,6 +24,7 @@ liblayer23_a_SOURCES = \
logging.c \
ms.c \
networks.c \
pkt_acc_proc_fsm.c \
sap_fsm.c \
sap_proto.c \
sap_interface.c \

View File

@ -0,0 +1,49 @@
/* Packet Access Procedure FSM
* (C) 2023 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/lienses/>.
*
*/
#include <stdbool.h>
/* gsm48_rr.c:
* gsm48_rr_est_req()
* gsm48_rr_chan_req()
* gsm48_rr_tx_rand_acc()
*/
int pkt_acc_proc_start(struct pkt_acc_proc_fsm_ctx *ctx, uint8_t chan_req)
{
struct gsm322_cellsel *cs = &ms->cellsel;
struct gsm48_rrlayer *rr = &ms->rrlayer;
OSMO_ASSERT(rr->state == GSM48_RR_ST_IDLE);
if (!cs->sel_si.si1 || !cs->sel_si.si13)
return -EAGAIN;
if (!cs->sel_si.gprs.supported)
return -ENOTSUP;
rr->cr_ra = chan_req;
memset(&rr->cr_hist[0], 0x00, sizeof(rr->cr_hist));
LOGP(DRR, LOGL_NOTICE, "Sending CHANNEL REQUEST (0x%02x)\n", rr->cr_ra);
l1ctl_tx_rach_req(ms, RSL_CHAN_RACH, 0x00, rr->cr_ra, 0,
cs->ccch_mode == CCCH_MODE_COMBINED);
rr->state = GSM48_RR_ST_CONN_PEND;
}