From caff83e702e0f4dc5e203f9e9c0533830b9d2311 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 9 Oct 2022 13:32:09 +0300 Subject: Constify LLC/SNDCP parameters That makes it easier to track side-effects while reading the code. Related: OS#5349 Change-Id: I903f8a747a8d3b7f734dac7b0c12373ecbb90b11 --- include/osmocom/sgsn/gprs_llc.h | 2 +- include/osmocom/sgsn/gprs_sndcp.h | 4 ++-- include/osmocom/sgsn/sgsn.h | 2 +- src/sgsn/gprs_llc.c | 16 ++++++++-------- src/sgsn/gprs_sndcp.c | 21 +++++++++++---------- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/osmocom/sgsn/gprs_llc.h b/include/osmocom/sgsn/gprs_llc.h index 6cdb995be..7ba551054 100644 --- a/include/osmocom/sgsn/gprs_llc.h +++ b/include/osmocom/sgsn/gprs_llc.h @@ -271,7 +271,7 @@ static inline int gprs_llc_is_retransmit(uint16_t nu, uint16_t vur) } /* LLC low level functions */ -void gprs_llme_copy_key(struct sgsn_mm_ctx *mm, struct gprs_llc_llme *llme); +void gprs_llme_copy_key(const struct sgsn_mm_ctx *mm, struct gprs_llc_llme *llme); /* parse a GPRS LLC header, also check for invalid frames */ int gprs_llc_hdr_parse(struct gprs_llc_hdr_parsed *ghp, diff --git a/include/osmocom/sgsn/gprs_sndcp.h b/include/osmocom/sgsn/gprs_sndcp.h index 5334d92c0..ad192fe6f 100644 --- a/include/osmocom/sgsn/gprs_sndcp.h +++ b/include/osmocom/sgsn/gprs_sndcp.h @@ -68,7 +68,7 @@ int sndcp_sn_xid_req(struct gprs_llc_lle *lle, uint8_t nsapi); * Section 6.8 XID parameter negotiation) */ int sndcp_sn_xid_ind(struct gprs_llc_xid_field *xid_field_indication, struct gprs_llc_xid_field *xid_field_response, - struct gprs_llc_lle *lle); + const struct gprs_llc_lle *lle); /* Process SNDCP-XID indication * (See also: TS 144 065, Section 6.8 XID parameter negotiation) */ @@ -77,6 +77,6 @@ int sndcp_sn_xid_conf(struct gprs_llc_xid_field *xid_field_conf, struct gprs_llc_lle *lle); /* Clean up all gprs_sndcp_entities related to llme (OS#4824) */ -void gprs_sndcp_sm_deactivate_ind_by_llme(struct gprs_llc_llme *llme); +void gprs_sndcp_sm_deactivate_ind_by_llme(const struct gprs_llc_llme *llme); #endif /* INT_SNDCP_H */ diff --git a/include/osmocom/sgsn/sgsn.h b/include/osmocom/sgsn/sgsn.h index 1b34c2a5d..f0eda9833 100644 --- a/include/osmocom/sgsn/sgsn.h +++ b/include/osmocom/sgsn/sgsn.h @@ -182,7 +182,7 @@ int sgsn_mme_ran_info_req(struct sgsn_mme_ctx *mme, const struct bssgp_ran_infor /* Entry point for the SNSM-ACTIVATE.indication */ int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi); /* Entry point for the SNSM-DEACTIVATE.indication */ -int sndcp_sm_deactivate_ind(struct gprs_llc_lle *lle, uint8_t nsapi); +int sndcp_sm_deactivate_ind(const struct gprs_llc_lle *lle, uint8_t nsapi); /* Called by SNDCP when it has received/re-assembled a N-PDU */ int sgsn_rx_sndcp_ud_ind(struct gprs_ra_id *ra_id, int32_t tlli, uint8_t nsapi, struct msgb *msg, uint32_t npdu_len, uint8_t *npdu); diff --git a/src/sgsn/gprs_llc.c b/src/sgsn/gprs_llc.c index f16f200c4..fda03191f 100644 --- a/src/sgsn/gprs_llc.c +++ b/src/sgsn/gprs_llc.c @@ -51,9 +51,9 @@ const struct value_string gprs_llc_llme_state_names[] = { }; static struct gprs_llc_llme *llme_alloc(uint32_t tlli); -static int gprs_llc_tx_xid(struct gprs_llc_lle *lle, struct msgb *msg, +static int gprs_llc_tx_xid(const struct gprs_llc_lle *lle, struct msgb *msg, int command); -static int gprs_llc_tx_dm(struct gprs_llc_lle *lle); +static int gprs_llc_tx_dm(const struct gprs_llc_lle *lle); static int gprs_llc_tx_u(struct msgb *msg, uint8_t sapi, int command, enum gprs_llc_u_cmd u_cmd, int pf_bit); @@ -212,7 +212,7 @@ static int gprs_llc_process_xid_ind(uint8_t *bytes_request, int bytes_request_len, uint8_t *bytes_response, int bytes_response_maxlen, - struct gprs_llc_lle *lle) + const struct gprs_llc_lle *lle) { /* Note: This function computes the response that is sent back to the * MS when a mobile originated XID is received. The function is @@ -288,7 +288,7 @@ static int gprs_llc_process_xid_ind(uint8_t *bytes_request, /* Dispatch XID indications and responses comming from the MS */ static void rx_llc_xid(struct gprs_llc_lle *lle, - struct gprs_llc_hdr_parsed *gph) + const struct gprs_llc_hdr_parsed *gph) { uint8_t response[1024]; int response_len; @@ -681,7 +681,7 @@ int gprs_llc_tx_u(struct msgb *msg, uint8_t sapi, int command, } /* Send XID response to LLE */ -static int gprs_llc_tx_xid(struct gprs_llc_lle *lle, struct msgb *msg, +static int gprs_llc_tx_xid(const struct gprs_llc_lle *lle, struct msgb *msg, int command) { /* copy identifiers from LLE to ensure lower layers can route */ @@ -692,7 +692,7 @@ static int gprs_llc_tx_xid(struct gprs_llc_lle *lle, struct msgb *msg, return gprs_llc_tx_u(msg, lle->sapi, command, GPRS_LLC_U_XID, 1); } -static int gprs_llc_tx_dm(struct gprs_llc_lle *lle) +static int gprs_llc_tx_dm(const struct gprs_llc_lle *lle) { struct msgb *msg = msgb_alloc_headroom(4096, 1024, "LLC_DM"); @@ -705,7 +705,7 @@ static int gprs_llc_tx_dm(struct gprs_llc_lle *lle) } /* encrypt information field + FCS, if needed! */ -static int apply_gea(struct gprs_llc_lle *lle, uint16_t crypt_len, uint16_t nu, +static int apply_gea(const struct gprs_llc_lle *lle, uint16_t crypt_len, uint16_t nu, uint32_t oc, uint8_t sapi, uint8_t *fcs, uint8_t *data) { uint8_t cipher_out[GSM0464_CIPH_MAX_BLOCK]; @@ -1037,7 +1037,7 @@ int gprs_llc_rcvmsg(struct msgb *msg, struct tlv_parsed *tv) } /* Propagate crypto parameters MM -> LLME */ -void gprs_llme_copy_key(struct sgsn_mm_ctx *mm, struct gprs_llc_llme *llme) +void gprs_llme_copy_key(const struct sgsn_mm_ctx *mm, struct gprs_llc_llme *llme) { if (!mm) return; diff --git a/src/sgsn/gprs_sndcp.c b/src/sgsn/gprs_sndcp.c index 24262e4b7..fc454dbdd 100644 --- a/src/sgsn/gprs_sndcp.c +++ b/src/sgsn/gprs_sndcp.c @@ -66,7 +66,7 @@ static uint16_t calc_ip_csum(uint8_t *data, int len) } /* Calculate TCP/IP checksum */ -static uint16_t calc_tcpip_csum(const void *ctx, uint8_t *packet, int len) +static uint16_t calc_tcpip_csum(const void *ctx, const uint8_t *packet, int len) { uint8_t *buf; uint16_t csum; @@ -84,7 +84,7 @@ static uint16_t calc_tcpip_csum(const void *ctx, uint8_t *packet, int len) } /* Show some ip packet details */ -static void debug_ip_packet(uint8_t *data, int len, int dir, char *info) +static void debug_ip_packet(const uint8_t *data, int len, int dir, const char *info) { uint8_t tcp_flags; char flags_debugmsg[256]; @@ -221,7 +221,8 @@ struct defrag_queue_entry { LLIST_HEAD(gprs_sndcp_entities); /* Check if any compression parameters are set in the sgsn configuration */ -static inline int any_pcomp_or_dcomp_active(struct sgsn_instance *sgsn) { +static inline int any_pcomp_or_dcomp_active(const struct sgsn_instance *sgsn) +{ if (sgsn->cfg.pcomp_rfc1144.active || sgsn->cfg.pcomp_rfc1144.passive || sgsn->cfg.dcomp_v42bis.active || sgsn->cfg.dcomp_v42bis.passive) return true; @@ -260,7 +261,7 @@ static int defrag_enqueue(struct gprs_sndcp_entity *sne, uint8_t seg_nr, } /* return if we have all segments of this N-PDU */ -static int defrag_have_all_segments(struct gprs_sndcp_entity *sne) +static int defrag_have_all_segments(const struct gprs_sndcp_entity *sne) { uint32_t seg_needed = 0; unsigned int i; @@ -275,7 +276,7 @@ static int defrag_have_all_segments(struct gprs_sndcp_entity *sne) return 0; } -static struct defrag_queue_entry *defrag_get_seg(struct gprs_sndcp_entity *sne, +static struct defrag_queue_entry *defrag_get_seg(const struct gprs_sndcp_entity *sne, uint32_t seg_nr) { struct defrag_queue_entry *dqe; @@ -522,7 +523,7 @@ int sndcp_sm_activate_ind(struct gprs_llc_lle *lle, uint8_t nsapi) } /* Entry point for the SNSM-DEACTIVATE.indication */ -int sndcp_sm_deactivate_ind(struct gprs_llc_lle *lle, uint8_t nsapi) +int sndcp_sm_deactivate_ind(const struct gprs_llc_lle *lle, uint8_t nsapi) { struct gprs_sndcp_entity *sne; @@ -545,7 +546,7 @@ int sndcp_sm_deactivate_ind(struct gprs_llc_lle *lle, uint8_t nsapi) } /* Clean up all gprs_sndcp_entities related to llme (OS#4824) */ -void gprs_sndcp_sm_deactivate_ind_by_llme(struct gprs_llc_llme *llme) +void gprs_sndcp_sm_deactivate_ind_by_llme(const struct gprs_llc_llme *llme) { struct gprs_sndcp_entity *sne, *sne2; @@ -1057,7 +1058,7 @@ int sndcp_sn_xid_req(struct gprs_llc_lle *lle, uint8_t nsapi) /* Handle header compression entites */ static int handle_pcomp_entities(struct gprs_sndcp_comp_field *comp_field, - struct gprs_llc_lle *lle) + const struct gprs_llc_lle *lle) { /* Note: This functions also transforms the comp_field into its * echo form (strips comp values, resets propose bit etc...) @@ -1107,7 +1108,7 @@ static int handle_pcomp_entities(struct gprs_sndcp_comp_field *comp_field, /* Hanle data compression entites */ static int handle_dcomp_entities(struct gprs_sndcp_comp_field *comp_field, - struct gprs_llc_lle *lle) + const struct gprs_llc_lle *lle) { /* See note in handle_pcomp_entities() */ @@ -1149,7 +1150,7 @@ static int handle_dcomp_entities(struct gprs_sndcp_comp_field *comp_field, * (See also: TS 144 065, Section 6.8 XID parameter negotiation) */ int sndcp_sn_xid_ind(struct gprs_llc_xid_field *xid_field_indication, struct gprs_llc_xid_field *xid_field_response, - struct gprs_llc_lle *lle) + const struct gprs_llc_lle *lle) { /* Note: This function computes the SNDCP-XID response that is sent * back to the ms when a ms originated XID is received. The -- cgit v1.2.3