libosmo-sigtran 2.1.0.164-775d Osmocom SIGTRAN library

Macros | Functions
sccp_helpers.c File Reference
`#include <errno.h>`
`#include <string.h>`
`#include <stdbool.h>`
`#include <sys/socket.h>`
`#include <arpa/inet.h>`
`#include <netinet/in.h>`
`#include <osmocom/sccp/sccp_types.h>`
`#include <osmocom/sigtran/sccp_sap.h>`
`#include <osmocom/sigtran/sccp_helpers.h>`
`#include "ss7_internal.h"`
`#include "sccp_instance.h"`
`#include "sccp_internal.h"`
`#include "sccp_user.h"`

## Macros
#define | SCU_MSG_SIZE 2048
#define | SCU_MSG_HEADROOM 512

## Functions
static struct msgb * | scu_msgb_alloc (const char *name)
void | osmo_sccp_make_addr_pc_ssn (struct osmo_sccp_addr *addr, uint32_t pc, uint32_t ssn)
void | osmo_sccp_addr_set_ssn (struct osmo_sccp_addr *addr, uint32_t ssn)
int | osmo_sccp_tx_unitdata (struct osmo_sccp_user *scu, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, const uint8_t *data, unsigned int len)
int | osmo_sccp_tx_unitdata_ranap (struct osmo_sccp_user *scu, uint32_t src_point_code, uint32_t dst_point_code, const uint8_t *data, unsigned int len)
int | osmo_sccp_tx_unitdata_msg (struct osmo_sccp_user *scu, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg)
int | osmo_sccp_tx_conn_req (struct osmo_sccp_user *scu, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, const uint8_t *data, unsigned int len)
int | osmo_sccp_tx_conn_req_msg (struct osmo_sccp_user *scu, uint32_t conn_id, const struct osmo_sccp_addr *calling_addr, const struct osmo_sccp_addr *called_addr, struct msgb *msg)
int | osmo_sccp_tx_data (struct osmo_sccp_user *scu, uint32_t conn_id, const uint8_t *data, unsigned int len)
int | osmo_sccp_tx_data_msg (struct osmo_sccp_user *scu, uint32_t conn_id, struct msgb *msg)
int | osmo_sccp_tx_disconn_data (struct osmo_sccp_user *scu, uint32_t conn_id, const struct osmo_sccp_addr *resp_addr, uint32_t cause, const uint8_t *data, size_t len)
int | osmo_sccp_tx_disconn (struct osmo_sccp_user *scu, uint32_t conn_id, const struct osmo_sccp_addr *resp_addr, uint32_t cause)
int | osmo_sccp_tx_conn_resp_msg (struct osmo_sccp_user *scu, uint32_t conn_id, const struct osmo_sccp_addr *resp_addr, struct msgb *msg)
int | osmo_sccp_tx_conn_resp (struct osmo_sccp_user *scu, uint32_t conn_id, const struct osmo_sccp_addr *resp_addr, const uint8_t *data, unsigned int len)
static void | append_to_buf (char *buf, size_t size, bool *comma, const char *fmt,...)
char * | osmo_sccp_gt_dump (const struct osmo_sccp_gt *gt)
char * | osmo_sccp_addr_dump (const struct osmo_sccp_addr *addr)
static int | sccp_addr_to_str_buf (char *buf, size_t buf_len, const struct osmo_ss7_instance *ss7, const struct osmo_sccp_addr *addr, char sep_char)
int | osmo_sccp_addr_to_str_buf (char *buf, size_t buf_len, const struct osmo_ss7_instance *ss7, const struct osmo_sccp_addr *addr)
char * | osmo_sccp_addr_to_str_c (void *ctx, const struct osmo_ss7_instance *ss7, const struct osmo_sccp_addr *addr)
int | osmo_sccp_addr_to_id_buf (char *buf, size_t buf_len, const struct osmo_ss7_instance *ss7, const struct osmo_sccp_addr *addr)
| like osmo_sccp_addr_to_str_buf, but using only characters passing osmo_identifier_valid(). More...
char * | osmo_sccp_addr_to_id_c (void *ctx, const struct osmo_ss7_instance *ss7, const struct osmo_sccp_addr *addr)
char * | osmo_sccp_addr_name (const struct osmo_ss7_instance *ss7, const struct osmo_sccp_addr *addr)
int | osmo_sccp_inst_addr_to_str_buf (char *buf, size_t buf_len, const struct osmo_sccp_instance *sccp, const struct osmo_sccp_addr *addr)
char * | osmo_sccp_inst_addr_to_str_c (void *ctx, const struct osmo_sccp_instance *sccp, const struct osmo_sccp_addr *addr)
char * | osmo_sccp_inst_addr_name (const struct osmo_sccp_instance *sccp, const struct osmo_sccp_addr *addr)

## Macro Definition Documentation

## ◆ SCU_MSG_HEADROOM

#define SCU_MSG_HEADROOM 512

## ◆ SCU_MSG_SIZE

#define SCU_MSG_SIZE 2048

## Function Documentation

## ◆ append_to_buf()

static void append_to_buf | ( | char * | buf,
|  | size_t | size,
|  | bool * | comma,
|  | const char * | fmt,
|  |  | ...
| ) |  |
| static

Referenced by osmo_sccp_addr_dump(), and osmo_sccp_gt_dump().

## ◆ osmo_sccp_addr_dump()

char * osmo_sccp_addr_dump | ( | const struct osmo_sccp_addr * | addr | ) |

References append_to_buf(), osmo_sccp_addr::gt, osmo_sccp_gt::gti, osmo_sccp_addr::ip, OSMO_SCCP_ADDR_T_GT, OSMO_SCCP_ADDR_T_IPv4, OSMO_SCCP_ADDR_T_IPv6, OSMO_SCCP_ADDR_T_PC, OSMO_SCCP_ADDR_T_SSN, osmo_sccp_gt_dump(), OSMO_SCCP_GTI_NO_GT, osmo_sccp_addr::pc, osmo_sccp_addr::presence, osmo_sccp_addr::ri, osmo_sccp_addr::ssn, osmo_sccp_addr::v4, and osmo_sccp_addr::v6.

Referenced by sccp_addr_to_sua().

## ◆ osmo_sccp_addr_name()

char * osmo_sccp_addr_name | ( | const struct osmo_ss7_instance * | ss7,
|  | const struct osmo_sccp_addr * | addr
| ) |  |

References osmo_sccp_addr_to_str_buf().

Referenced by osmo_sccp_inst_addr_name(), and osmo_sccp_user_name().

## ◆ osmo_sccp_addr_set_ssn()

void osmo_sccp_addr_set_ssn | ( | struct osmo_sccp_addr * | addr,
|  | uint32_t | ssn
| ) |  |

References OSMO_SCCP_ADDR_T_SSN, osmo_sccp_addr::presence, and osmo_sccp_addr::ssn.

## ◆ osmo_sccp_addr_to_id_buf()

int osmo_sccp_addr_to_id_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_ss7_instance * | ss7,
|  | const struct osmo_sccp_addr * | addr
| ) |  |

like osmo_sccp_addr_to_str_buf, but using only characters passing osmo_identifier_valid().

Useful for FSM and CTRL IDs.

The advantage over using osmo_sccp_addr_to_str_buf() followed by osmo_identifier_sanitize_buf() is that here, the address elements are separated by ':', while osmo_identifier_sanitize_buf() would replace all characters with the same, e.g. '-'.

References sccp_addr_to_str_buf().

Referenced by osmo_sccp_addr_to_id_c().

## ◆ osmo_sccp_addr_to_id_c()

char * osmo_sccp_addr_to_id_c | ( | void * | ctx,
|  | const struct osmo_ss7_instance * | ss7,
|  | const struct osmo_sccp_addr * | addr
| ) |  |

References osmo_sccp_addr_to_id_buf().

## ◆ osmo_sccp_addr_to_str_buf()

int osmo_sccp_addr_to_str_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_ss7_instance * | ss7,
|  | const struct osmo_sccp_addr * | addr
| ) |  |

References sccp_addr_to_str_buf().

Referenced by osmo_sccp_addr_name(), osmo_sccp_addr_to_str_c(), and osmo_sccp_inst_addr_to_str_buf().

## ◆ osmo_sccp_addr_to_str_c()

char * osmo_sccp_addr_to_str_c | ( | void * | ctx,
|  | const struct osmo_ss7_instance * | ss7,
|  | const struct osmo_sccp_addr * | addr
| ) |  |

References osmo_sccp_addr_to_str_buf().

## ◆ osmo_sccp_gt_dump()

char * osmo_sccp_gt_dump | ( | const struct osmo_sccp_gt * | gt | ) |

References append_to_buf(), osmo_sccp_gt::digits, osmo_sccp_gt::gti, osmo_sccp_gt::nai, osmo_sccp_gt::npi, OSMO_SCCP_GTI_NAI_ONLY, OSMO_SCCP_GTI_NO_GT, OSMO_SCCP_GTI_TT_NPL_ENC, OSMO_SCCP_GTI_TT_NPL_ENC_NAI, OSMO_SCCP_GTI_TT_ONLY, and osmo_sccp_gt::tt.

Referenced by osmo_sccp_addr_dump(), and sccp_addr_to_str_buf().

## ◆ osmo_sccp_inst_addr_name()

char * osmo_sccp_inst_addr_name | ( | const struct osmo_sccp_instance * | sccp,
|  | const struct osmo_sccp_addr * | addr
| ) |  |

References NULL, osmo_sccp_addr_name(), and osmo_sccp_instance::ss7.

## ◆ osmo_sccp_inst_addr_to_str_buf()

int osmo_sccp_inst_addr_to_str_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_sccp_instance * | sccp,
|  | const struct osmo_sccp_addr * | addr
| ) |  |

References NULL, osmo_sccp_addr_to_str_buf(), and osmo_sccp_instance::ss7.

Referenced by osmo_sccp_inst_addr_to_str_c().

## ◆ osmo_sccp_inst_addr_to_str_c()

char * osmo_sccp_inst_addr_to_str_c | ( | void * | ctx,
|  | const struct osmo_sccp_instance * | sccp,
|  | const struct osmo_sccp_addr * | addr
| ) |  |

References osmo_sccp_inst_addr_to_str_buf().

## ◆ osmo_sccp_make_addr_pc_ssn()

void osmo_sccp_make_addr_pc_ssn | ( | struct osmo_sccp_addr * | addr,
|  | uint32_t | pc,
|  | uint32_t | ssn
| ) |  |

References OSMO_SCCP_ADDR_T_PC, OSMO_SCCP_ADDR_T_SSN, OSMO_SCCP_RI_SSN_PC, osmo_sccp_addr::pc, osmo_sccp_addr::presence, and osmo_sccp_addr::ssn.

Referenced by osmo_sccp_local_addr_by_instance(), osmo_sccp_tx_unitdata_ranap(), and osmo_sccp_user_name().

## ◆ osmo_sccp_tx_conn_req()

int osmo_sccp_tx_conn_req | ( | struct osmo_sccp_user * | scu,
|  | uint32_t | conn_id,
|  | const struct osmo_sccp_addr * | calling_addr,
|  | const struct osmo_sccp_addr * | called_addr,
|  | const uint8_t * | data,
|  | unsigned int | len
| ) |  |

References osmo_scu_connect_param::called_addr, osmo_scu_connect_param::calling_addr, osmo_scu_connect_param::conn_id, osmo_scu_prim::connect, data, len, osmo_scu_prim::oph, osmo_sccp_user_sap_down(), OSMO_SCU_PRIM_N_CONNECT, osmo_scu_connect_param::sccp_class, SCCP_SAP_USER, scu_msgb_alloc(), and osmo_scu_prim::u.

Referenced by osmo_sccp_tx_conn_req_msg().

## ◆ osmo_sccp_tx_conn_req_msg()

int osmo_sccp_tx_conn_req_msg | ( | struct osmo_sccp_user * | scu,
|  | uint32_t | conn_id,
|  | const struct osmo_sccp_addr * | calling_addr,
|  | const struct osmo_sccp_addr * | called_addr,
|  | struct msgb * | msg
| ) |  |

References osmo_sccp_tx_conn_req().

## ◆ osmo_sccp_tx_conn_resp()

int osmo_sccp_tx_conn_resp | ( | struct osmo_sccp_user * | scu,
|  | uint32_t | conn_id,
|  | const struct osmo_sccp_addr * | resp_addr,
|  | const uint8_t * | data,
|  | unsigned int | len
| ) |  |

References data, len, osmo_sccp_tx_conn_resp_msg(), and scu_msgb_alloc().

## ◆ osmo_sccp_tx_conn_resp_msg()

int osmo_sccp_tx_conn_resp_msg | ( | struct osmo_sccp_user * | scu,
|  | uint32_t | conn_id,
|  | const struct osmo_sccp_addr * | resp_addr,
|  | struct msgb * | msg
| ) |  |

References osmo_scu_connect_param::conn_id, osmo_scu_prim::connect, osmo_sccp_user::inst, LOGPSCU, osmo_scu_prim::oph, osmo_sccp_conn_id_exists(), osmo_sccp_user_sap_down(), OSMO_SCU_PRIM_N_CONNECT, osmo_scu_connect_param::responding_addr, osmo_scu_connect_param::sccp_class, SCCP_SAP_USER, and osmo_scu_prim::u.

Referenced by osmo_sccp_tx_conn_resp().

## ◆ osmo_sccp_tx_data()

int osmo_sccp_tx_data | ( | struct osmo_sccp_user * | scu,
|  | uint32_t | conn_id,
|  | const uint8_t * | data,
|  | unsigned int | len
| ) |  |

References osmo_scu_data_param::conn_id, osmo_scu_prim::data, data, osmo_sccp_user::inst, len, LOGPSCU, osmo_scu_prim::oph, osmo_sccp_conn_id_exists(), osmo_sccp_user_sap_down(), OSMO_SCU_PRIM_N_DATA, SCCP_SAP_USER, scu_msgb_alloc(), and osmo_scu_prim::u.

Referenced by osmo_sccp_tx_data_msg(), sccp_conn_opt_data_send_cache(), and xua_opt_data_length_lim().

## ◆ osmo_sccp_tx_data_msg()

int osmo_sccp_tx_data_msg | ( | struct osmo_sccp_user * | scu,
|  | uint32_t | conn_id,
|  | struct msgb * | msg
| ) |  |

References osmo_sccp_tx_data().

## ◆ osmo_sccp_tx_disconn()

int osmo_sccp_tx_disconn | ( | struct osmo_sccp_user * | scu,
|  | uint32_t | conn_id,
|  | const struct osmo_sccp_addr * | resp_addr,
|  | uint32_t | cause
| ) |  |

References NULL, and osmo_sccp_tx_disconn_data().

## ◆ osmo_sccp_tx_disconn_data()

int osmo_sccp_tx_disconn_data | ( | struct osmo_sccp_user * | scu,
|  | uint32_t | conn_id,
|  | const struct osmo_sccp_addr * | resp_addr,
|  | uint32_t | cause,
|  | const uint8_t * | data,
|  | size_t | len
| ) |  |

References osmo_scu_disconn_param::cause, osmo_scu_disconn_param::conn_id, data, osmo_scu_prim::disconnect, osmo_sccp_user::inst, len, LOGPSCU, osmo_scu_prim::oph, osmo_scu_disconn_param::originator, osmo_sccp_conn_id_exists(), OSMO_SCCP_ORIG_NS_USER, osmo_sccp_user_sap_down(), OSMO_SCU_PRIM_N_DISCONNECT, osmo_scu_disconn_param::responding_addr, SCCP_SAP_USER, scu_msgb_alloc(), and osmo_scu_prim::u.

Referenced by osmo_sccp_tx_disconn().

## ◆ osmo_sccp_tx_unitdata()

int osmo_sccp_tx_unitdata | ( | struct osmo_sccp_user * | scu,
|  | const struct osmo_sccp_addr * | calling_addr,
|  | const struct osmo_sccp_addr * | called_addr,
|  | const uint8_t * | data,
|  | unsigned int | len
| ) |  |

References osmo_scu_unitdata_param::called_addr, osmo_scu_unitdata_param::calling_addr, data, osmo_scu_unitdata_param::in_sequence_control, len, osmo_scu_prim::oph, osmo_sccp_user_sap_down(), OSMO_SCU_PRIM_N_UNITDATA, OSMO_SCU_UNITDATA_REQ_P_SEQUENCE_CONTROL_NOT_PRESENT, SCCP_SAP_USER, scu_msgb_alloc(), osmo_scu_prim::u, and osmo_scu_prim::unitdata.

Referenced by osmo_sccp_tx_unitdata_msg(), and osmo_sccp_tx_unitdata_ranap().

## ◆ osmo_sccp_tx_unitdata_msg()

int osmo_sccp_tx_unitdata_msg | ( | struct osmo_sccp_user * | scu,
|  | const struct osmo_sccp_addr * | calling_addr,
|  | const struct osmo_sccp_addr * | called_addr,
|  | struct msgb * | msg
| ) |  |

References osmo_sccp_tx_unitdata().

## ◆ osmo_sccp_tx_unitdata_ranap()

int osmo_sccp_tx_unitdata_ranap | ( | struct osmo_sccp_user * | scu,
|  | uint32_t | src_point_code,
|  | uint32_t | dst_point_code,
|  | const uint8_t * | data,
|  | unsigned int | len
| ) |  |

References data, len, osmo_sccp_make_addr_pc_ssn(), OSMO_SCCP_SSN_RANAP, and osmo_sccp_tx_unitdata().

## ◆ sccp_addr_to_str_buf()

static int sccp_addr_to_str_buf | ( | char * | buf,
|  | size_t | buf_len,
|  | const struct osmo_ss7_instance * | ss7,
|  | const struct osmo_sccp_addr * | addr,
|  | char | sep_char
| ) |  |
| static

References osmo_sccp_addr::gt, osmo_sccp_gt::gti, osmo_sccp_addr::ip, MAX_PC_STR_LEN, OSMO_SCCP_ADDR_T_GT, OSMO_SCCP_ADDR_T_IPv4, OSMO_SCCP_ADDR_T_IPv6, OSMO_SCCP_ADDR_T_PC, OSMO_SCCP_ADDR_T_SSN, osmo_sccp_gt_dump(), osmo_sccp_gti_name(), OSMO_SCCP_GTI_NO_GT, osmo_sccp_routing_ind_name(), osmo_sccp_ssn_name(), osmo_ss7_pointcode_print_buf(), osmo_sccp_addr::pc, osmo_sccp_addr::presence, osmo_sccp_addr::ri, osmo_sccp_addr::ssn, osmo_sccp_addr::v4, and osmo_sccp_addr::v6.

Referenced by osmo_sccp_addr_to_id_buf(), and osmo_sccp_addr_to_str_buf().

## ◆ scu_msgb_alloc()

static struct msgb * scu_msgb_alloc | ( | const char * | name | ) |
| static

References SCU_MSG_HEADROOM, and SCU_MSG_SIZE.

Referenced by osmo_sccp_tx_conn_req(), osmo_sccp_tx_conn_resp(), osmo_sccp_tx_data(), osmo_sccp_tx_disconn_data(), and osmo_sccp_tx_unitdata().