gsm23236.h
Go to the documentation of this file.
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <osmocom/core/linuxlist.h>
#define OSMO_NRI_BITLEN_MIN 1
#define OSMO_NRI_BITLEN_MAX 15
#define OSMO_NRI_BITLEN_DEFAULT 10
struct osmo_nri_range {
struct llist_head entry;
int16_t first;
int16_t last;
};
struct osmo_nri_ranges {
/* List of struct osmo_nri_range entries, talloc allocated from the parent struct osmo_nri_ranges. */
struct llist_head entries;
};
int osmo_nri_v_validate(int16_t nri_v, uint8_t nri_bitlen);
bool osmo_nri_v_matches_ranges(int16_t nri_v, const struct osmo_nri_ranges *nri_ranges);
int osmo_nri_v_limit_by_ranges(int16_t *nri_v, const struct osmo_nri_ranges *nri_ranges, uint32_t nri_bitlen);
int osmo_tmsi_nri_v_get(int16_t *nri_v, uint32_t tmsi, uint8_t nri_bitlen);
int osmo_tmsi_nri_v_set(uint32_t *tmsi, int16_t nri_v, uint8_t nri_bitlen);
int osmo_tmsi_nri_v_limit_by_ranges(uint32_t *tmsi, const struct osmo_nri_ranges *nri_ranges, uint8_t nri_bitlen);
int osmo_nri_range_validate(const struct osmo_nri_range *range, uint8_t nri_bitlen);
bool osmo_nri_range_overlaps_ranges(const struct osmo_nri_range *range, const struct osmo_nri_ranges *nri_ranges);
struct osmo_nri_ranges *osmo_nri_ranges_alloc(void *ctx);
void osmo_nri_ranges_free(struct osmo_nri_ranges *nri_ranges);
int osmo_nri_ranges_add(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *add);
int osmo_nri_ranges_del(struct osmo_nri_ranges *nri_ranges, const struct osmo_nri_range *del);
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);
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);
int osmo_nri_ranges_to_str_buf(char *buf, size_t buflen, const struct osmo_nri_ranges *nri_ranges);
char *osmo_nri_ranges_to_str_c(void *ctx, const struct osmo_nri_ranges *nri_ranges);
argv
argv
argc
argc
osmo_nri_ranges_free
void osmo_nri_ranges_free(struct osmo_nri_ranges *nri_ranges)
Free a struct osmo_nri_ranges.
Definition: gsm23236.c:271
osmo_nri_v_validate
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:38
osmo_nri_v_matches_ranges
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:84
osmo_nri_ranges_to_str_c
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:426
osmo_tmsi_nri_v_limit_by_ranges
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:205
osmo_nri_ranges_del
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:351
osmo_nri_range_validate
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:224
osmo_tmsi_nri_v_get
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:151
osmo_nri_ranges_vty_add
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:491
osmo_nri_v_limit_by_ranges
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:103
osmo_nri_ranges_add
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:300
osmo_nri_ranges_vty_del
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:527
osmo_nri_range_overlaps_ranges
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:243
osmo_tmsi_nri_v_set
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:180
osmo_nri_ranges_alloc
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:259
osmo_nri_ranges_to_str_buf
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:406
linuxlist.h
llist_head
osmo_nri_range
One range of NRI values.
Definition: gsm23236.h:19
osmo_nri_range::entry
struct llist_head entry
Definition: gsm23236.h:20
osmo_nri_range::first
int16_t first
First value of the NRI range, i.e.
Definition: gsm23236.h:23
osmo_nri_range::last
int16_t last
Last value of the NRI range, i.e.
Definition: gsm23236.h:25
osmo_nri_ranges
A list of struct osmo_nri_range.
Definition: gsm23236.h:35
osmo_nri_ranges::entries
struct llist_head entries
Definition: gsm23236.h:37