msuraev has submitted this change. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/29678 )
Change subject: Constify LLC/SNDCP parameters ......................................................................
Constify LLC/SNDCP parameters
That makes it easier to track side-effects while reading the code.
Related: OS#5349 Change-Id: I903f8a747a8d3b7f734dac7b0c12373ecbb90b11 --- M include/osmocom/sgsn/gprs_llc.h M include/osmocom/sgsn/gprs_sndcp.h M include/osmocom/sgsn/sgsn.h M src/sgsn/gprs_llc.c M src/sgsn/gprs_sndcp.c 5 files changed, 23 insertions(+), 22 deletions(-)
Approvals: Jenkins Builder: Verified msuraev: Looks good to me, approved laforge: Looks good to me, but someone else must approve keith: Looks good to me, but someone else must approve
diff --git a/include/osmocom/sgsn/gprs_llc.h b/include/osmocom/sgsn/gprs_llc.h index 6cdb995..7ba5510 100644 --- a/include/osmocom/sgsn/gprs_llc.h +++ b/include/osmocom/sgsn/gprs_llc.h @@ -271,7 +271,7 @@ }
/* 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 5334d92..ad192fe 100644 --- a/include/osmocom/sgsn/gprs_sndcp.h +++ b/include/osmocom/sgsn/gprs_sndcp.h @@ -68,7 +68,7 @@ * 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 @@ 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 1b34c2a..f0eda98 100644 --- a/include/osmocom/sgsn/sgsn.h +++ b/include/osmocom/sgsn/sgsn.h @@ -182,7 +182,7 @@ /* 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 f16f200..fda0319 100644 --- a/src/sgsn/gprs_llc.c +++ b/src/sgsn/gprs_llc.c @@ -51,9 +51,9 @@ };
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 @@ 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 @@
/* 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 @@ }
/* 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 @@ 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 @@ }
/* 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 @@ }
/* 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 24262e4..fc454db 100644 --- a/src/sgsn/gprs_sndcp.c +++ b/src/sgsn/gprs_sndcp.c @@ -66,7 +66,7 @@ }
/* 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 @@ }
/* 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 @@ 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 @@ }
/* 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 @@ 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 @@ }
/* 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 @@ }
/* 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 @@
/* 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 @@
/* 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 @@ * (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