libosmo-sigtran  1.9.0.1-797d
Osmocom SIGTRAN library
sccp.c File Reference
#include <errno.h>
#include <string.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/endian.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/sccp/sccp_types.h>
#include <osmocom/sccp/sccp.h>

Data Structures

struct  sccp_system
 
struct  sccp_data_callback
 
struct  udt_offsets
 

Macros

#define SCCP_MSG_SIZE   4096
 
#define SCCP_MSG_HEADROOM   128
 

Functions

static LLIST_HEAD (sccp_connections)
 
static LLIST_HEAD (sccp_callbacks)
 
static struct sccp_data_callback_find_ssn (uint8_t ssn)
 
static void _send_msg (struct sccp_connection *conn, struct msgb *msg, void *ctx)
 
static int copy_address (struct sccp_address *addr, uint8_t offset, struct msgb *msgb)
 
static int _sccp_parse_optional_data (const int offset, struct msgb *msgb, struct sccp_optional_data *data)
 
int _sccp_parse_connection_request (struct msgb *msgb, struct sccp_parse_result *result)
 
int _sccp_parse_connection_released (struct msgb *msgb, struct sccp_parse_result *result)
 
int _sccp_parse_connection_refused (struct msgb *msgb, struct sccp_parse_result *result)
 
int _sccp_parse_connection_confirm (struct msgb *msgb, struct sccp_parse_result *result)
 
int _sccp_parse_connection_release_complete (struct msgb *msgb, struct sccp_parse_result *result)
 
int _sccp_parse_connection_dt1 (struct msgb *msgb, struct sccp_parse_result *result)
 
static int _sccp_parse_unitdata (struct msgb *msgb, struct sccp_parse_result *result, const struct udt_offsets *offs)
 
int _sccp_parse_udt (struct msgb *msgb, struct sccp_parse_result *result)
 
int _sccp_parse_udts (struct msgb *msgb, struct sccp_parse_result *result)
 
static int _sccp_parse_xudt (struct msgb *msgb, struct sccp_parse_result *result)
 
static int _sccp_parse_xudts (struct msgb *msgb, struct sccp_parse_result *result)
 
static int _sccp_parse_it (struct msgb *msgb, struct sccp_parse_result *result)
 
static int _sccp_parse_err (struct msgb *msgb, struct sccp_parse_result *result)
 
int sccp_create_sccp_addr (struct msgb *msg, const struct sockaddr_sccp *sock)
 
struct msgb * sccp_create_udt (int class, const struct sockaddr_sccp *in, const struct sockaddr_sccp *out, uint8_t *in_data, int len)
 
static int _sccp_send_data (int class, const struct sockaddr_sccp *in, const struct sockaddr_sccp *out, struct msgb *payload, void *ctx)
 
static int _sccp_handle_read (struct msgb *msgb)
 
static int source_local_reference_is_free (struct sccp_source_reference *reference)
 
static int destination_local_reference_is_free (struct sccp_source_reference *reference)
 
static int assign_source_local_reference (struct sccp_connection *connection)
 
static void _sccp_set_connection_state (struct sccp_connection *connection, int new_state)
 
struct msgb * sccp_create_refuse (struct sccp_source_reference *src_ref, int cause, uint8_t *inp, int length)
 
static int _sccp_send_refuse (struct sccp_source_reference *src_ref, int cause, void *ctx)
 
struct msgb * sccp_create_cc (struct sccp_source_reference *src_ref, struct sccp_source_reference *dst_ref)
 
static int _sccp_send_connection_confirm (struct sccp_connection *connection)
 
struct msgb * sccp_create_cr (const struct sccp_source_reference *src_ref, const struct sockaddr_sccp *called, const uint8_t *l3_data, size_t l3_length)
 
static int _sccp_send_connection_request (struct sccp_connection *connection, const struct sockaddr_sccp *called, struct msgb *msg)
 
struct msgb * sccp_create_dt1 (struct sccp_source_reference *dst_ref, uint8_t *inp_data, uint8_t len)
 
static int _sccp_send_connection_data (struct sccp_connection *conn, struct msgb *_data)
 
static int _sccp_send_connection_it (struct sccp_connection *conn)
 
struct msgb * sccp_create_rlsd (struct sccp_source_reference *src_ref, struct sccp_source_reference *dst_ref, int cause)
 
static int _sccp_send_connection_released (struct sccp_connection *conn, int cause)
 
static int _sccp_handle_connection_request (struct msgb *msgb, void *ctx)
 
static int _sccp_handle_connection_release_complete (struct msgb *msgb)
 
static int _sccp_handle_connection_dt1 (struct msgb *msgb)
 
static int _sccp_send_connection_release_complete (struct sccp_connection *connection)
 
static int _sccp_handle_connection_released (struct msgb *msgb)
 
static int _sccp_handle_connection_refused (struct msgb *msgb)
 
static int _sccp_handle_connection_confirm (struct msgb *msgb)
 
int sccp_system_init (void(*outgoing)(struct sccp_connection *conn, struct msgb *data, void *, void *), void *ctx)
 
int sccp_system_incoming (struct msgb *msgb)
 
int sccp_system_incoming_ctx (struct msgb *msgb, void *ctx)
 
int sccp_connection_write (struct sccp_connection *connection, struct msgb *data)
 
int sccp_connection_send_it (struct sccp_connection *connection)
 
int sccp_connection_close (struct sccp_connection *connection, int cause)
 
int sccp_connection_free (struct sccp_connection *connection)
 
int sccp_connection_force_free (struct sccp_connection *con)
 
struct sccp_connectionsccp_connection_socket (void)
 
int sccp_connection_connect (struct sccp_connection *conn, const struct sockaddr_sccp *local, struct msgb *data)
 
int sccp_connection_set_incoming (const struct sockaddr_sccp *sock, int(*accept_cb)(struct sccp_connection *, void *), void *context)
 
int sccp_write (struct msgb *data, const struct sockaddr_sccp *in, const struct sockaddr_sccp *out, int class, void *ctx)
 
int sccp_set_read (const struct sockaddr_sccp *sock, int(*read_cb)(struct msgb *, unsigned int, void *), void *context)
 
 osmo_static_assert (sizeof(struct sccp_source_reference)<=sizeof(uint32_t), enough_space)
 
uint32_t sccp_src_ref_to_int (struct sccp_source_reference *ref)
 
struct sccp_source_reference sccp_src_ref_from_int (uint32_t int_ref)
 
int sccp_determine_msg_type (struct msgb *msg)
 
int sccp_parse_header (struct msgb *msg, struct sccp_parse_result *result)
 
static __attribute__ ((constructor))
 
static __attribute__ ((destructor))
 
void sccp_set_log_area (int log_area)
 

Variables

static int DSCCP = 0
 
static void * tall_sccp_ctx
 
const struct sockaddr_sccp sccp_ssn_bssap
 
static struct sccp_system sccp_system
 

Macro Definition Documentation

◆ SCCP_MSG_HEADROOM

◆ SCCP_MSG_SIZE

Function Documentation

◆ __attribute__() [1/2]

static __attribute__ ( (constructor)  )
static

References tall_sccp_ctx.

◆ __attribute__() [2/2]

static __attribute__ ( (destructor)  )
static

References tall_sccp_ctx.

◆ _find_ssn()

◆ _sccp_handle_connection_confirm()

static int _sccp_handle_connection_confirm ( struct msgb *  msgb)
static

◆ _sccp_handle_connection_dt1()

static int _sccp_handle_connection_dt1 ( struct msgb *  msgb)
static

◆ _sccp_handle_connection_refused()

static int _sccp_handle_connection_refused ( struct msgb *  msgb)
static

◆ _sccp_handle_connection_release_complete()

static int _sccp_handle_connection_release_complete ( struct msgb *  msgb)
static

◆ _sccp_handle_connection_released()

static int _sccp_handle_connection_released ( struct msgb *  msgb)
static

◆ _sccp_handle_connection_request()

◆ _sccp_handle_read()

static int _sccp_handle_read ( struct msgb *  msgb)
static

◆ _sccp_parse_connection_confirm()

int _sccp_parse_connection_confirm ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)

◆ _sccp_parse_connection_dt1()

int _sccp_parse_connection_dt1 ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)

References DSCCP.

Referenced by _sccp_handle_connection_dt1(), and sccp_parse_header().

◆ _sccp_parse_connection_refused()

int _sccp_parse_connection_refused ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)

◆ _sccp_parse_connection_release_complete()

int _sccp_parse_connection_release_complete ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)

◆ _sccp_parse_connection_released()

int _sccp_parse_connection_released ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)

◆ _sccp_parse_connection_request()

int _sccp_parse_connection_request ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)

◆ _sccp_parse_err()

static int _sccp_parse_err ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)
static

References DSCCP.

Referenced by sccp_parse_header().

◆ _sccp_parse_it()

static int _sccp_parse_it ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)
static

References DSCCP.

Referenced by sccp_parse_header().

◆ _sccp_parse_optional_data()

static int _sccp_parse_optional_data ( const int  offset,
struct msgb *  msgb,
struct sccp_optional_data *  data 
)
static

◆ _sccp_parse_udt()

int _sccp_parse_udt ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)

◆ _sccp_parse_udts()

int _sccp_parse_udts ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)

◆ _sccp_parse_unitdata()

static int _sccp_parse_unitdata ( struct msgb *  msgb,
struct sccp_parse_result *  result,
const struct udt_offsets offs 
)
static

◆ _sccp_parse_xudt()

static int _sccp_parse_xudt ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)
static

◆ _sccp_parse_xudts()

static int _sccp_parse_xudts ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)
static

◆ _sccp_send_connection_confirm()

static int _sccp_send_connection_confirm ( struct sccp_connection connection)
static

◆ _sccp_send_connection_data()

static int _sccp_send_connection_data ( struct sccp_connection conn,
struct msgb *  _data 
)
static

References _send_msg(), DSCCP, and sccp_create_dt1().

Referenced by sccp_connection_write().

◆ _sccp_send_connection_it()

static int _sccp_send_connection_it ( struct sccp_connection conn)
static

◆ _sccp_send_connection_release_complete()

static int _sccp_send_connection_release_complete ( struct sccp_connection connection)
static

◆ _sccp_send_connection_released()

static int _sccp_send_connection_released ( struct sccp_connection conn,
int  cause 
)
static

◆ _sccp_send_connection_request()

static int _sccp_send_connection_request ( struct sccp_connection connection,
const struct sockaddr_sccp *  called,
struct msgb *  msg 
)
static

◆ _sccp_send_data()

static int _sccp_send_data ( int  class,
const struct sockaddr_sccp *  in,
const struct sockaddr_sccp *  out,
struct msgb *  payload,
void *  ctx 
)
static

References _send_msg(), and sccp_create_udt().

Referenced by sccp_write().

◆ _sccp_send_refuse()

static int _sccp_send_refuse ( struct sccp_source_reference *  src_ref,
int  cause,
void *  ctx 
)
static

◆ _sccp_set_connection_state()

◆ _send_msg()

◆ assign_source_local_reference()

static int assign_source_local_reference ( struct sccp_connection connection)
static

◆ copy_address()

static int copy_address ( struct sccp_address *  addr,
uint8_t  offset,
struct msgb *  msgb 
)
static

◆ destination_local_reference_is_free()

static int destination_local_reference_is_free ( struct sccp_source_reference *  reference)
static

◆ LLIST_HEAD() [1/2]

static LLIST_HEAD ( sccp_connections  )
static

◆ LLIST_HEAD() [2/2]

static LLIST_HEAD ( sccp_callbacks  )
static

◆ osmo_static_assert()

osmo_static_assert ( sizeof(struct sccp_source_reference)<=sizeof(uint32_t)  ,
enough_space   
)

Referenced by sccp_set_read().

◆ sccp_connection_close()

int sccp_connection_close ( struct sccp_connection connection,
int  cause 
)

◆ sccp_connection_connect()

int sccp_connection_connect ( struct sccp_connection conn,
const struct sockaddr_sccp *  local,
struct msgb *  data 
)

◆ sccp_connection_force_free()

int sccp_connection_force_free ( struct sccp_connection con)

◆ sccp_connection_free()

int sccp_connection_free ( struct sccp_connection connection)

References DSCCP.

Referenced by sccp_connection_force_free().

◆ sccp_connection_send_it()

int sccp_connection_send_it ( struct sccp_connection connection)

◆ sccp_connection_set_incoming()

int sccp_connection_set_incoming ( const struct sockaddr_sccp *  sock,
int(*)(struct sccp_connection *, void *)  accept_cb,
void *  context 
)

◆ sccp_connection_socket()

struct sccp_connection* sccp_connection_socket ( void  )

References tall_sccp_ctx.

◆ sccp_connection_write()

int sccp_connection_write ( struct sccp_connection connection,
struct msgb *  data 
)

◆ sccp_create_cc()

struct msgb* sccp_create_cc ( struct sccp_source_reference *  src_ref,
struct sccp_source_reference *  dst_ref 
)

◆ sccp_create_cr()

struct msgb* sccp_create_cr ( const struct sccp_source_reference *  src_ref,
const struct sockaddr_sccp *  called,
const uint8_t *  l3_data,
size_t  l3_length 
)

◆ sccp_create_dt1()

struct msgb* sccp_create_dt1 ( struct sccp_source_reference *  dst_ref,
uint8_t *  inp_data,
uint8_t  len 
)

◆ sccp_create_refuse()

struct msgb* sccp_create_refuse ( struct sccp_source_reference *  src_ref,
int  cause,
uint8_t *  inp,
int  length 
)

References data, DSCCP, SCCP_MSG_HEADROOM, and SCCP_MSG_SIZE.

Referenced by _sccp_send_refuse().

◆ sccp_create_rlsd()

struct msgb* sccp_create_rlsd ( struct sccp_source_reference *  src_ref,
struct sccp_source_reference *  dst_ref,
int  cause 
)

◆ sccp_create_sccp_addr()

int sccp_create_sccp_addr ( struct msgb *  msg,
const struct sockaddr_sccp *  sock 
)

References len.

Referenced by sccp_create_cr(), and sccp_create_udt().

◆ sccp_create_udt()

struct msgb* sccp_create_udt ( int  class,
const struct sockaddr_sccp *  in,
const struct sockaddr_sccp *  out,
uint8_t *  in_data,
int  len 
)

◆ sccp_determine_msg_type()

int sccp_determine_msg_type ( struct msgb *  msg)

◆ sccp_parse_header()

◆ sccp_set_log_area()

void sccp_set_log_area ( int  log_area)

References DSCCP.

◆ sccp_set_read()

int sccp_set_read ( const struct sockaddr_sccp *  sock,
int(*)(struct msgb *, unsigned int, void *)  read_cb,
void *  context 
)

◆ sccp_src_ref_from_int()

struct sccp_source_reference sccp_src_ref_from_int ( uint32_t  int_ref)

◆ sccp_src_ref_to_int()

uint32_t sccp_src_ref_to_int ( struct sccp_source_reference *  ref)

◆ sccp_system_incoming()

int sccp_system_incoming ( struct msgb *  msgb)

◆ sccp_system_incoming_ctx()

◆ sccp_system_init()

int sccp_system_init ( void(*)(struct sccp_connection *conn, struct msgb *data, void *, void *)  outgoing,
void *  ctx 
)

◆ sccp_write()

int sccp_write ( struct msgb *  data,
const struct sockaddr_sccp *  in,
const struct sockaddr_sccp *  out,
int  class,
void *  ctx 
)

References _sccp_send_data().

◆ source_local_reference_is_free()

static int source_local_reference_is_free ( struct sccp_source_reference *  reference)
static

Variable Documentation

◆ DSCCP

◆ sccp_ssn_bssap

const struct sockaddr_sccp sccp_ssn_bssap
Initial value:
= {
.sccp_family = 0,
.sccp_ssn = SCCP_SSN_BSSAP,
}

◆ sccp_system

struct sccp_system sccp_system
static
Initial value:
= {
.write_data = NULL,
}

◆ tall_sccp_ctx