libosmo-sigtran  0.10.0.10-13d4
Osmocom SIGTRAN library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
sccp.c File Reference
#include <string.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/logging.h>
#include <osmocom/gsm/tlv.h>
#include <sccp/sccp.h>

Data Structures

struct  sccp_system
 
struct  sccp_data_callback
 

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)
 
int _sccp_parse_udt (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

Function Documentation

static __attribute__ ( (constructor)  )
static

References tall_sccp_ctx.

static __attribute__ ( (destructor)  )
static

References tall_sccp_ctx.

static int _sccp_handle_connection_confirm ( struct msgb *  msgb)
static
static int _sccp_handle_connection_dt1 ( struct msgb *  msgb)
static
static int _sccp_handle_connection_refused ( struct msgb *  msgb)
static
static int _sccp_handle_connection_release_complete ( struct msgb *  msgb)
static
static int _sccp_handle_connection_released ( struct msgb *  msgb)
static
static int _sccp_handle_read ( struct msgb *  msgb)
static
int _sccp_parse_connection_confirm ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)
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().

int _sccp_parse_connection_refused ( 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_released ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)
int _sccp_parse_connection_request ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)
static int _sccp_parse_err ( struct msgb *  msgb,
struct sccp_parse_result *  result 
)
static

References DSCCP.

Referenced by sccp_parse_header().

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

References DSCCP.

Referenced by sccp_parse_header().

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

References copy_address(), and DSCCP.

Referenced by _sccp_handle_read(), and sccp_parse_header().

static int _sccp_send_connection_confirm ( struct sccp_connection connection)
static
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().

static int _sccp_send_connection_it ( struct sccp_connection conn)
static
static int _sccp_send_connection_release_complete ( struct sccp_connection connection)
static
static int _sccp_send_connection_released ( struct sccp_connection conn,
int  cause 
)
static
static int _sccp_send_connection_request ( struct sccp_connection connection,
const struct sockaddr_sccp *  called,
struct msgb *  msg 
)
static
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().

static int _sccp_send_refuse ( struct sccp_source_reference *  src_ref,
int  cause,
void *  ctx 
)
static
static int assign_source_local_reference ( struct sccp_connection connection)
static
static int copy_address ( struct sccp_address *  addr,
uint8_t  offset,
struct msgb *  msgb 
)
static

References DSCCP.

Referenced by _sccp_parse_connection_request(), and _sccp_parse_udt().

static int destination_local_reference_is_free ( struct sccp_source_reference *  reference)
static
static LLIST_HEAD ( sccp_connections  )
static
static LLIST_HEAD ( sccp_callbacks  )
static
osmo_static_assert ( sizeof(struct sccp_source_reference)<=sizeof(uint32_t)  ,
enough_space   
)
int sccp_connection_close ( struct sccp_connection connection,
int  cause 
)
int sccp_connection_connect ( struct sccp_connection conn,
const struct sockaddr_sccp *  local,
struct msgb *  data 
)
int sccp_connection_force_free ( struct sccp_connection con)
int sccp_connection_free ( struct sccp_connection connection)

References DSCCP.

Referenced by sccp_connection_force_free().

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

References tall_sccp_ctx.

int sccp_connection_write ( struct sccp_connection connection,
struct msgb *  data 
)
struct msgb* sccp_create_cc ( struct sccp_source_reference *  src_ref,
struct sccp_source_reference *  dst_ref 
)
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 
)
struct msgb* sccp_create_dt1 ( struct sccp_source_reference *  dst_ref,
uint8_t *  inp_data,
uint8_t  len 
)
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().

struct msgb* sccp_create_rlsd ( struct sccp_source_reference *  src_ref,
struct sccp_source_reference *  dst_ref,
int  cause 
)
int sccp_create_sccp_addr ( struct msgb *  msg,
const struct sockaddr_sccp *  sock 
)

References len.

Referenced by sccp_create_cr(), and 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 
)
int sccp_determine_msg_type ( struct msgb *  msg)
void sccp_set_log_area ( int  log_area)

References DSCCP.

int sccp_set_read ( const struct sockaddr_sccp *  sock,
int(*)(struct msgb *, unsigned int, void *)  read_cb,
void *  context 
)
struct sccp_source_reference sccp_src_ref_from_int ( uint32_t  int_ref)
uint32_t sccp_src_ref_to_int ( struct sccp_source_reference *  ref)
int sccp_system_incoming ( struct msgb *  msgb)
int sccp_system_init ( void(*)(struct sccp_connection *conn, struct msgb *data, void *, void *)  outgoing,
void *  ctx 
)
int sccp_write ( struct msgb *  data,
const struct sockaddr_sccp *  in,
const struct sockaddr_sccp *  out,
int  class,
void *  ctx 
)

References _sccp_send_data().

static int source_local_reference_is_free ( struct sccp_source_reference *  reference)
static

Variable Documentation

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