libosmogsm  1.9.0.155-9d73.202402222026
Osmocom GSM library
gsm23236.h
Go to the documentation of this file.
1 
5 #pragma once
6 
7 #include <stdint.h>
8 #include <stdbool.h>
9 
10 #include <osmocom/core/linuxlist.h>
11 
12 #define OSMO_NRI_BITLEN_MIN 1
13 #define OSMO_NRI_BITLEN_MAX 15
14 #define OSMO_NRI_BITLEN_DEFAULT 10
15 
20  struct llist_head entry;
21 
23  int16_t first;
25  int16_t last;
26 };
27 
36  /* List of struct osmo_nri_range entries, talloc allocated from the parent struct osmo_nri_ranges. */
37  struct llist_head entries;
38 };
39 
40 int osmo_nri_v_validate(int16_t nri_v, uint8_t nri_bitlen);
41 bool osmo_nri_v_matches_ranges(int16_t nri_v, const struct osmo_nri_ranges *nri_ranges);
42 int osmo_nri_v_limit_by_ranges(int16_t *nri_v, const struct osmo_nri_ranges *nri_ranges, uint32_t nri_bitlen);
43 
44 int osmo_tmsi_nri_v_get(int16_t *nri_v, uint32_t tmsi, uint8_t nri_bitlen);
45 int osmo_tmsi_nri_v_set(uint32_t *tmsi, int16_t nri_v, uint8_t nri_bitlen);
46 int osmo_tmsi_nri_v_limit_by_ranges(uint32_t *tmsi, const struct osmo_nri_ranges *nri_ranges, uint8_t nri_bitlen);
47 
48 int osmo_nri_range_validate(const struct osmo_nri_range *range, uint8_t nri_bitlen);
49 bool osmo_nri_range_overlaps_ranges(const struct osmo_nri_range *range, const struct osmo_nri_ranges *nri_ranges);
50 
51 struct osmo_nri_ranges *osmo_nri_ranges_alloc(void *ctx);
52 void osmo_nri_ranges_free(struct osmo_nri_ranges *nri_ranges);
53 int osmo_nri_ranges_add(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *add);
54 int osmo_nri_ranges_del(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *del);
55 int osmo_nri_ranges_vty_add(const char **message, struct osmo_nri_range *added_range,
56  struct osmo_nri_ranges *nri_ranges, int argc, const char **argv, uint8_t nri_bitlen);
57 int osmo_nri_ranges_vty_del(const char **message, struct osmo_nri_range *removed_range,
58  struct osmo_nri_ranges *nri_ranges, int argc, const char **argv);
59 int osmo_nri_ranges_to_str_buf(char *buf, size_t buflen, const struct osmo_nri_ranges *nri_ranges);
60 char *osmo_nri_ranges_to_str_c(void *ctx, const struct osmo_nri_ranges *nri_ranges);
argv
argc
void osmo_nri_ranges_free(struct osmo_nri_ranges *nri_ranges)
Free a struct osmo_nri_ranges.
Definition: gsm23236.c:267
int osmo_nri_v_validate(int16_t nri_v, uint8_t nri_bitlen)
Validate that the given NRI is valid for a given nri_bitlen range.
Definition: gsm23236.c:34
bool osmo_nri_v_matches_ranges(int16_t nri_v, const struct osmo_nri_ranges *nri_ranges)
Return true when the given NRI value appears in the list of NRI ranges.
Definition: gsm23236.c:80
char * osmo_nri_ranges_to_str_c(void *ctx, const struct osmo_nri_ranges *nri_ranges)
Compose a human readable representation of a list of NRI ranges in a talloc buffer,...
Definition: gsm23236.c:422
int osmo_tmsi_nri_v_limit_by_ranges(uint32_t *tmsi, const struct osmo_nri_ranges *nri_ranges, uint8_t nri_bitlen)
Apply osmo_nri_v_limit_by_ranges() in-place on the NRI value included in a TMSI.
Definition: gsm23236.c:201
int osmo_nri_ranges_del(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *del)
Remove a range of NRI values from a list of nri_range structs.
Definition: gsm23236.c:347
int osmo_nri_range_validate(const struct osmo_nri_range *range, uint8_t nri_bitlen)
Validate that the given NRI range is valid for a given nri_bitlen range.
Definition: gsm23236.c:220
int osmo_tmsi_nri_v_get(int16_t *nri_v, uint32_t tmsi, uint8_t nri_bitlen)
Retrieve the Network Resource Indicator bits from a TMSI or p-TMSI.
Definition: gsm23236.c:147
int osmo_nri_ranges_vty_add(const char **message, struct osmo_nri_range *added_range, struct osmo_nri_ranges *nri_ranges, int argc, const char **argv, uint8_t nri_bitlen)
VTY implementation for adding an NRI range to a list of ranges.
Definition: gsm23236.c:487
int osmo_nri_v_limit_by_ranges(int16_t *nri_v, const struct osmo_nri_ranges *nri_ranges, uint32_t nri_bitlen)
Modulo and shift the given NRI value so that it becomes a value present in a list of NRI ranges.
Definition: gsm23236.c:99
int osmo_nri_ranges_add(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *add)
Add a range of NRI values to a list of nri_range structs.
Definition: gsm23236.c:296
int osmo_nri_ranges_vty_del(const char **message, struct osmo_nri_range *removed_range, struct osmo_nri_ranges *nri_ranges, int argc, const char **argv)
VTY implementation for removing an NRI range from a list of ranges.
Definition: gsm23236.c:523
bool osmo_nri_range_overlaps_ranges(const struct osmo_nri_range *range, const struct osmo_nri_ranges *nri_ranges)
Return true when the given NRI range has at least one NRI value that appears in a list of other NRI r...
Definition: gsm23236.c:239
int osmo_tmsi_nri_v_set(uint32_t *tmsi, int16_t nri_v, uint8_t nri_bitlen)
Write Network Resource Indicator bits into a TMSI or p-TMSI.
Definition: gsm23236.c:176
struct osmo_nri_ranges * osmo_nri_ranges_alloc(void *ctx)
Allocate an empty struct osmo_nri_ranges (list of struct osmo_nri_range).
Definition: gsm23236.c:255
int osmo_nri_ranges_to_str_buf(char *buf, size_t buflen, const struct osmo_nri_ranges *nri_ranges)
Compose a human readable representation of a list of NRI ranges in a buffer, like "23....
Definition: gsm23236.c:402
One range of NRI values.
Definition: gsm23236.h:19
struct llist_head entry
Definition: gsm23236.h:20
int16_t first
First value of the NRI range, i.e.
Definition: gsm23236.h:23
int16_t last
Last value of the NRI range, i.e.
Definition: gsm23236.h:25
A list of struct osmo_nri_range.
Definition: gsm23236.h:35
struct llist_head entries
Definition: gsm23236.h:37