27 #define LOG_PREFIX "sigtran"
29 #include <freeradius-devel/server/base.h>
30 #include <freeradius-devel/util/debug.h>
31 #include <freeradius-devel/protocol/eap/aka-sim/dictionary.h>
32 #include <freeradius-devel/protocol/eap/aka-sim/dictionary.h>
33 #include <freeradius-devel/server/module_rlm.h>
50 if (write(fd, &txn,
sizeof(txn)) < 0) {
58 len = read(fd, &ptr,
sizeof(ptr));
64 if (len !=
sizeof(ptr)) {
65 ERROR(
"worker - ctrl_pipe (%i) data too short, expected %zu bytes, got %zi bytes",
66 fd,
sizeof(ptr), len);
71 ERROR(
"worker - ctrl_pipe (%i) response ptr (%p) does not match request (%p)", fd, ptr, txn);
101 ERROR(
"worker - ctrl_pipe (%i) read failed : %s", fd,
fr_syserror(fd_errno));
116 len = read(fd, &ptr,
sizeof(ptr));
122 if (len !=
sizeof(ptr)) {
123 ERROR(
"worker - ctrl_pipe (%i) data too short, expected %zu bytes, got %zi bytes",
124 fd,
sizeof(ptr), len);
132 if (txn->
ctx.defunct)
return;
146 int req_pipe[2] = { -1, -1 };
153 if (socketpair(AF_UNIX, SOCK_STREAM, 0, req_pipe) < 0) {
158 fr_assert((req_pipe[0] >= 0) && (req_pipe[1] >= 0));
162 txn->
request.data = &req_pipe[1];
165 ERROR(
"worker - Failed registering thread");
172 DEBUG3(
"worker - Thread register acked by osmocom thread");
181 ERROR(
"worker - Failed listening on osmocom pipe");
206 ERROR(
"worker - Failed unregistering thread");
210 DEBUG3(
"worker - Thread unregister acked by osmocom thread");
231 memcpy(&txn->
request.data, &conn_conf,
sizeof(txn->
request.data));
234 ERROR(
"worker - Failed bringing up link");
238 DEBUG3(
"worker - Link up acked by osmocom thread");
254 if (!*conn || !(*conn)->
mtp3_link)
return 0;
261 ERROR(
"worker - Failed taking down the link");
265 DEBUG3(
"worker - Link down acked by osmocom thread");
276 txn->
ctx.defunct =
true;
298 for (vec = res->
vector; vec; vec = vec->
next) {
305 RDEBUG2(
"SIM auth vector %i", i);
309 TALLOC_FREE(vec->sim.rand);
315 TALLOC_FREE(vec->sim.sres);
321 TALLOC_FREE(vec->sim.kc);
336 RDEBUG2(
"UMTS auth vector %i", i);
340 TALLOC_FREE(vec->umts.rand);
346 TALLOC_FREE(vec->umts.xres);
352 TALLOC_FREE(vec->umts.ck);
358 TALLOC_FREE(vec->umts.ik);
364 TALLOC_FREE(vec->umts.authn);
423 ERROR(
"Failed retrieving version");
443 REDEBUG(
"Failed retrieving IMSI");
447 len = talloc_array_length(imsi) - 1;
448 if ((len != 16) && (len != 15)) {
449 REDEBUG(
"IMSI must be 15 or 16 digits got %zu digits", len);
454 REDEBUG(
"Failed converting ASCII to BCD");
461 RDEBUG3(
"Sending MAPv%u request with IMSI \"%pV\" (TBCD %pV)",
468 if (write(fd, &txn,
sizeof(txn)) < 0) {
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
fr_dcursor_eval_t void const * uctx
#define fr_event_fd_insert(...)
@ FR_EVENT_FILTER_IO
Combined filter for read/write functions/.
void unlang_interpret_mark_runnable(request_t *request)
Mark a request as resumable.
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_xres
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_sres
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_ik
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_autn
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_kc
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_ck
HIDDEN fr_dict_attr_t const * attr_eap_aka_sim_rand
#define REXDENT()
Exdent (unindent) R* messages by one level.
#define RDEBUG_ENABLED3
True if request debug level 1-3 messages are enabled.
#define RINDENT()
Indent R* messages by one level.
int fr_event_fd_delete(fr_event_list_t *el, int fd, fr_event_filter_t filter)
Remove a file descriptor from the event loop.
Stores all information relating to an event list.
void * rctx
Resume ctx that a module previously set.
Temporary structure to hold arguments for module calls.
int fr_pair_value_memdup_buffer(fr_pair_t *vp, uint8_t const *src, bool tainted)
Copy data from a talloced buffer into an "octets" data type.
fr_pair_t * fr_pair_afrom_da(TALLOC_CTX *ctx, fr_dict_attr_t const *da)
Dynamically allocate a new attribute and assign a fr_dict_attr_t.
int fr_pair_append(fr_pair_list_t *list, fr_pair_t *to_add)
Add a VP to the end of the list.
#define RDEBUG_ENABLED2()
#define RETURN_MODULE_RCODE(_rcode)
rlm_rcode_t
Return codes indicating the result of the module call.
@ RLM_MODULE_OK
The module is OK, continue.
@ RLM_MODULE_FAIL
Module failed, don't reply.
@ RLM_MODULE_NOTFOUND
User not found.
@ RLM_MODULE_NOOP
Module succeeded without doing anything.
#define tmpl_aexpand(_ctx, _out, _request, _vpt, _escape, _escape_ctx)
Expand a tmpl to a C type, allocing a new buffer to hold the string.
int sigtran_ascii_to_tbcd(TALLOC_CTX *ctx, uint8_t **out, char const *digits)
Declarations for various sigtran functions.
@ SIGTRAN_VECTOR_TYPE_UMTS_QUINTUPLETS
RAND, XRES, CK, IK, AUTN.
@ SIGTRAN_VECTOR_TYPE_SIM_TRIPLETS
RAND, SRES, Kc.
@ SIGTRAN_REQUEST_THREAD_REGISTER
New worker thread to register.
@ SIGTRAN_REQUEST_MAP_SEND_AUTH_INFO
Request auth info.
@ SIGTRAN_REQUEST_LINK_DOWN
Take down a link.
@ SIGTRAN_REQUEST_THREAD_UNREGISTER
Worker thread to unregister.
@ SIGTRAN_REQUEST_LINK_UP
Bring up a link.
@ SIGTRAN_RESPONSE_OK
Request succeeded.
@ SIGTRAN_RESPONSE_NOOP
Request did nothing.
@ SIGTRAN_RESPONSE_FAIL
Request failed.
@ SIGTRAN_RESPONSE_NOTFOUND
User or device Not found.
uint8_t * imsi
BCD encoded IMSI.
struct sigtran_transaction::@173 response
sigtran_vector_type_t type
Type of vector returned.
sigtran_conn_t const * conn
Connection to send request on.
uint8_t version
Application context version.
struct sigtran_transaction::@172 request
struct sigtran_transaction::@174 ctx
struct mtp_link * mtp3_link
sigtran_vector_t * vector
Linked list of vectors.
sigtran_vector_t * next
Next vector in list.
Represents a connection to a remote SS7 entity.
Configures a M3UA/MTP3/SCCP stack.
MAP send auth info request.
MAP send auth info response.
Request and response from the event loop.
Authentication vector returned by HLR.
unlang_action_t unlang_module_yield(request_t *request, module_method_t resume, unlang_module_signal_t signal, fr_signal_t sigmask, void *rctx)
Yield a request back to the interpreter from within a module.
int sigtran_client_thread_register(fr_event_list_t *el)
Called by a new thread to register a new req_pipe.
unlang_action_t sigtran_client_map_send_auth_info(rlm_rcode_t *p_result, rlm_sigtran_t const *inst, request_t *request, sigtran_conn_t const *conn, int fd)
Create a MAP_SEND_AUTH_INFO request.
static unlang_action_t sigtran_client_map_resume(rlm_rcode_t *p_result, module_ctx_t const *mctx, request_t *request)
int sigtran_client_link_up(sigtran_conn_t const **out, sigtran_conn_conf_t const *conn_conf)
Create a new connection.
int sigtran_client_thread_unregister(fr_event_list_t *el, int req_pipe_fd)
Signal that libosmo should unregister the other side of the pipe.
int sigtran_client_link_down(sigtran_conn_t const **conn)
Destroy a connection.
static void _sigtran_pipe_error(UNUSED fr_event_list_t *el, int fd, UNUSED int flags, int fd_errno, UNUSED void *uctx)
This should never happen.
static void _sigtran_pipe_read(UNUSED fr_event_list_t *el, int fd, UNUSED int flags, UNUSED void *uctx)
Drain any data we received.
static void sigtran_client_signal(module_ctx_t const *mctx, UNUSED request_t *request, UNUSED fr_signal_t action)
int sigtran_client_do_transaction(int fd, sigtran_transaction_t *txn)
static int sigtran_client_do_ctrl_transaction(sigtran_transaction_t *txn)
static pthread_mutex_t ctrl_pipe_mutex
MEM(pair_append_request(&vp, attr_eap_aka_sim_identity) >=0)
eap_aka_sim_process_conf_t * inst
Stores an attribute, a value and various bits of other data.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
static fr_event_list_t * el
#define fr_box_strvalue_buffer(_val)
#define fr_box_octets_buffer(_val)
static size_t char ** out