update it
This commit is contained in:
parent
0ddd1224b0
commit
eae045594e
|
@ -82,7 +82,7 @@ static void * s6a_stats(void * arg)
|
|||
/* entry point */
|
||||
int s6a_app_init(int mode)
|
||||
{
|
||||
d_trace_level(&_s6a_app, 1);
|
||||
d_trace_level(&_s6a_app, 0);
|
||||
|
||||
/* Configure Application Mode(MME, HSS) */
|
||||
s6a_config->mode = mode;
|
||||
|
|
|
@ -84,7 +84,7 @@ extern struct dict_object *s6a_ula_flags;
|
|||
extern struct dict_object *s6a_subscription_data;
|
||||
extern struct dict_object *s6a_req_eutran_auth_info;
|
||||
extern struct dict_object *s6a_number_of_requested_vectors;
|
||||
extern struct dict_object *s6a_immediate_response_pref;
|
||||
extern struct dict_object *s6a_immediate_response_preferred;
|
||||
extern struct dict_object *s6a_authentication_info;
|
||||
extern struct dict_object *s6a_re_synchronization_info;
|
||||
extern struct dict_object *s6a_service_selection;
|
||||
|
|
|
@ -35,7 +35,7 @@ struct dict_object *s6a_ula_flags = NULL;
|
|||
struct dict_object *s6a_subscription_data = NULL;
|
||||
struct dict_object *s6a_req_eutran_auth_info = NULL;
|
||||
struct dict_object *s6a_number_of_requested_vectors = NULL;
|
||||
struct dict_object *s6a_immediate_response_pref = NULL;
|
||||
struct dict_object *s6a_immediate_response_preferred = NULL;
|
||||
struct dict_object *s6a_authentication_info = NULL;
|
||||
struct dict_object *s6a_re_synchronization_info = NULL;
|
||||
struct dict_object *s6a_service_selection = NULL;
|
||||
|
@ -173,7 +173,7 @@ int s6a_dict_init(void)
|
|||
&s6a_number_of_requested_vectors, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
|
||||
AVP_BY_NAME_ALL_VENDORS, "Immediate-Response-Preferred",
|
||||
&s6a_immediate_response_pref, ENOENT));
|
||||
&s6a_immediate_response_preferred, ENOENT));
|
||||
CHECK_FCT(fd_dict_search(fd_g_config->cnf_dict, DICT_AVP,
|
||||
AVP_BY_NAME_ALL_VENDORS, "Authentication-Info",
|
||||
&s6a_authentication_info, ENOENT));
|
||||
|
|
15
main.c
15
main.c
|
@ -10,6 +10,7 @@
|
|||
#include "symtbl.h"
|
||||
|
||||
/* Server */
|
||||
#include "s6a_auth_info.h"
|
||||
#include "cellwire.h"
|
||||
|
||||
extern char g_compile_time[];
|
||||
|
@ -51,8 +52,18 @@ static int check_signal(int signum)
|
|||
}
|
||||
case SIGUSR1:
|
||||
{
|
||||
status_t s6_send_auth_req();
|
||||
s6_send_auth_req();
|
||||
s6a_auth_info_req_t air;
|
||||
memset(&air, 0, sizeof(s6a_auth_info_req_t));
|
||||
|
||||
#define TEST_IMSI "01045238277"
|
||||
air.imsi_len = strlen(TEST_IMSI);
|
||||
strcpy((char*)air.imsi, TEST_IMSI);
|
||||
air.visited_plmn_id.mcc = 1;
|
||||
air.visited_plmn_id.mnc = 1;
|
||||
air.visited_plmn_id.mnc_len = 2;
|
||||
air.auth_info.num_of_eutran_vector = 1;
|
||||
air.auth_info.immediate_response_preferred = 1;
|
||||
s6a_send_auth_info_req(&air);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -5,14 +5,14 @@ noinst_LTLIBRARIES = libcellwire.la
|
|||
libcellwire_la_SOURCES = \
|
||||
cellwire.h common.h event.h context.h \
|
||||
s1ap_build.h s1ap_conv.h s1ap_path.h \
|
||||
s6_path.h \
|
||||
s6_auth_info.h \
|
||||
sm.h
|
||||
|
||||
|
||||
nodist_libcellwire_la_SOURCES = \
|
||||
init.c event.c context.c \
|
||||
init.c common.c event.c context.c \
|
||||
s1ap_build.c s1ap_conv.c s1ap_path.c \
|
||||
s6a_auth.c \
|
||||
s6a_auth_info.c \
|
||||
mme_sm.c enb_s1_sm.c
|
||||
|
||||
libcellwire_la_DEPENDENCIES = \
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#define TRACE_MODULE _s1conv
|
||||
|
||||
#include "core_debug.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "s1ap_conv.h"
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_uint8_to_octet_string(
|
||||
|
@ -34,10 +36,6 @@ CORE_DECLARE(void) s1ap_conv_uint32_to_octet_string(
|
|||
octet_string->buf[0] = uint32;
|
||||
}
|
||||
|
||||
#define S1AP_CONV_DECIMAL100(x) (((x) / 100) % 10)
|
||||
#define S1AP_CONV_DECIMAL10(x) (((x) / 10) % 10)
|
||||
#define S1AP_CONV_DECIMAL1(x) ((x) % 10)
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_plmn_id_to_tbcd_string(
|
||||
plmn_id_t *plmn_id, S1ap_TBCD_STRING_t *tbcd_string)
|
||||
|
||||
|
@ -45,17 +43,7 @@ CORE_DECLARE(void) s1ap_conv_plmn_id_to_tbcd_string(
|
|||
tbcd_string->size = 3;
|
||||
tbcd_string->buf = core_calloc(tbcd_string->size, sizeof(c_uint8_t));
|
||||
|
||||
tbcd_string->buf[0] = (S1AP_CONV_DECIMAL10(plmn_id->mcc) << 4) |
|
||||
S1AP_CONV_DECIMAL100(plmn_id->mcc);
|
||||
|
||||
if (plmn_id->mnc_len == 2)
|
||||
tbcd_string->buf[1] = (0xf << 4);
|
||||
else
|
||||
tbcd_string->buf[1] = (S1AP_CONV_DECIMAL100(plmn_id->mnc) << 4);
|
||||
tbcd_string->buf[1] |= S1AP_CONV_DECIMAL1(plmn_id->mcc);
|
||||
|
||||
tbcd_string->buf[2] = (S1AP_CONV_DECIMAL1(plmn_id->mnc) << 4) |
|
||||
S1AP_CONV_DECIMAL10(plmn_id->mnc);
|
||||
encode_plmn_id(tbcd_string->buf, plmn_id);
|
||||
}
|
||||
|
||||
CORE_DECLARE(void) s1ap_conv_macro_enb_id_to_bit_string(
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
#ifndef _S6A_AUTH_H__
|
||||
#define _S6A_AUTH_H__
|
||||
|
||||
#include "core_errno.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define MAX_IMSI_BCD_DIGITS_LEN 15
|
||||
|
||||
#define MAX_EPS_AUTH_VECTORS 1
|
||||
#define AUTS_LENGTH 14
|
||||
|
||||
#define RAND_LENGTH_BITS (128)
|
||||
#define RAND_LENGTH_OCTETS (RAND_LENGTH_BITS/8)
|
||||
#define XRES_LENGTH_MIN (4)
|
||||
#define XRES_LENGTH_MAX (16)
|
||||
#define KASME_LENGTH_BITS (256)
|
||||
#define KASME_LENGTH_OCTETS (KASME_LENGTH_BITS/8)
|
||||
#define AUTN_LENGTH_BITS (128)
|
||||
#define AUTN_LENGTH_OCTETS (AUTN_LENGTH_BITS/8)
|
||||
|
||||
typedef struct {
|
||||
c_uint8_t size;
|
||||
c_uint8_t data[XRES_LENGTH_MAX];
|
||||
} res_t;
|
||||
|
||||
typedef struct eutran_vector_s {
|
||||
c_uint8_t rand[RAND_LENGTH_OCTETS];
|
||||
res_t xres;
|
||||
c_uint8_t autn[AUTN_LENGTH_OCTETS];
|
||||
c_uint8_t kasme[KASME_LENGTH_OCTETS];
|
||||
} eutran_vector_t;
|
||||
|
||||
typedef struct _authentication_info_s {
|
||||
c_uint8_t nb_of_vectors;
|
||||
eutran_vector_t eutran_vector[MAX_EPS_AUTH_VECTORS];
|
||||
} authentication_info_t;
|
||||
|
||||
typedef struct _s6a_auth_info_req_s {
|
||||
char imsi[MAX_IMSI_BCD_DIGITS_LEN + 1];
|
||||
c_uint8_t imsi_len;
|
||||
plmn_id_t visited_plmn_id;
|
||||
c_uint8_t num_of_vectors;
|
||||
|
||||
unsigned re_synchronization:1;
|
||||
c_uint8_t auts[AUTS_LENGTH];
|
||||
} s6a_auth_info_req_t;
|
||||
|
||||
typedef struct _s6a_auth_info_ans_s {
|
||||
char imsi[MAX_IMSI_BCD_DIGITS_LEN + 1];
|
||||
c_uint8_t imsi_len;
|
||||
|
||||
authentication_info_t auth_info;
|
||||
} s6a_auth_info_ans_t;
|
||||
|
||||
CORE_DECLARE(int) s6_send_auth_info_req();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
#include "core_debug.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include "s6a_app.h"
|
||||
#include "s6a_auth.h"
|
||||
#include "s6a_auth_info.h"
|
||||
|
||||
struct sess_state {
|
||||
c_int32_t randval; /* a random value to store in Test-AVP */
|
||||
|
@ -13,10 +15,11 @@ struct sess_state {
|
|||
static void s6a_aia_cb(void *data, struct msg **msg);
|
||||
|
||||
/* Cb called when an answer is received */
|
||||
int s6_send_auth_req()
|
||||
int s6a_send_auth_info_req(s6a_auth_info_req_t *air)
|
||||
{
|
||||
struct msg *req = NULL;
|
||||
struct avp *avp;
|
||||
struct avp *avpch;
|
||||
union avp_value val;
|
||||
struct sess_state *mi = NULL, *svg;
|
||||
struct session *sess = NULL;
|
||||
|
@ -37,6 +40,15 @@ int s6_send_auth_req()
|
|||
CONSTSTRLEN(S6A_APP_SID_OPT)) == 0, goto out,);
|
||||
d_assert(fd_msg_sess_get(fd_g_config->cnf_dict, req, &sess, NULL) == 0,
|
||||
goto out, );
|
||||
|
||||
/* Set the Auth-Session-Statee AVP if needed*/
|
||||
d_assert(fd_msg_avp_new(s6a_auth_session_state, 0, &avp) == 0, goto out,);
|
||||
val.i32 = 1;
|
||||
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
|
||||
|
||||
/* Set Origin-Host & Origin-Realm */
|
||||
d_assert(fd_msg_add_origin(req, 0) == 0, goto out, );
|
||||
|
||||
/* Set the Destination-Realm AVP */
|
||||
d_assert(fd_msg_avp_new(s6a_destination_realm, 0, &avp) == 0, goto out,);
|
||||
|
@ -45,30 +57,40 @@ int s6_send_auth_req()
|
|||
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
|
||||
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out, );
|
||||
|
||||
/* Set Origin-Host & Origin-Realm */
|
||||
d_assert(fd_msg_add_origin(req, 0) == 0, goto out, );
|
||||
|
||||
/* Set the User-Name AVP if needed*/
|
||||
#define S6A_USER_NAME "01045238277"
|
||||
d_assert(fd_msg_avp_new(s6a_user_name, 0, &avp) == 0, goto out,);
|
||||
val.os.data = (unsigned char *)(S6A_USER_NAME);
|
||||
val.os.len = strlen(S6A_USER_NAME);
|
||||
val.os.data = air->imsi;
|
||||
val.os.len = air->imsi_len;
|
||||
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out, );
|
||||
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
|
||||
|
||||
/* Set the Auth-Session-Statee AVP if needed*/
|
||||
d_assert(fd_msg_avp_new(s6a_auth_session_state, 0, &avp) == 0, goto out,);
|
||||
val.i32 = 1;
|
||||
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
|
||||
/* Add the Authentication-Info */
|
||||
d_assert(fd_msg_avp_new(s6a_req_eutran_auth_info, 0, &avp) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_new(s6a_number_of_requested_vectors, 0,
|
||||
&avpch) == 0, goto out,);
|
||||
val.u32 = air->auth_info.num_of_eutran_vector;
|
||||
d_assert(fd_msg_avp_setvalue (avpch, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_add (avp, MSG_BRW_LAST_CHILD, avpch) == 0, goto out,);
|
||||
|
||||
d_assert(fd_msg_avp_new(s6a_immediate_response_preferred, 0,
|
||||
&avpch) == 0, goto out,);
|
||||
val.u32 = air->auth_info.immediate_response_preferred;
|
||||
d_assert(fd_msg_avp_setvalue(avpch, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_add(avp, MSG_BRW_LAST_CHILD, avpch) == 0, goto out,);
|
||||
|
||||
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
|
||||
|
||||
/* Set the Visited-PLMN-Id AVP if needed*/
|
||||
c_uint8_t plmn[3] = { 0x00, 0xf1, 0x10 };
|
||||
d_assert(fd_msg_avp_new(s6a_visited_plmn_id, 0, &avp) == 0, goto out,);
|
||||
val.os.data = plmn;
|
||||
val.os.len = 3;
|
||||
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
|
||||
{
|
||||
c_uint8_t data[3] = {0, };
|
||||
encode_plmn_id(data, &air->visited_plmn_id);
|
||||
|
||||
d_assert(fd_msg_avp_new(s6a_visited_plmn_id, 0, &avp) == 0, goto out,);
|
||||
val.os.data = data;
|
||||
val.os.len = 3;
|
||||
d_assert(fd_msg_avp_setvalue(avp, &val) == 0, goto out,);
|
||||
d_assert(fd_msg_avp_add(req, MSG_BRW_LAST_CHILD, avp) == 0, goto out,);
|
||||
}
|
||||
|
||||
d_assert(clock_gettime(CLOCK_REALTIME, &mi->ts) == 0, goto out,);
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef _S6A_AUTH_H__
|
||||
#define _S6A_AUTH_H__
|
||||
|
||||
#include "core_errno.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define MAX_IMSI_BCD_DIGITS_LEN 15
|
||||
|
||||
#define MAX_EUTRAN_VECTORS 1
|
||||
|
||||
#define MAX_RAND_LEN (128/8)
|
||||
#define MAX_XRES_LEN 16
|
||||
#define MAX_KASME_LEN (256/8)
|
||||
#define MAX_AUTN_LEN (128/8)
|
||||
|
||||
typedef struct _s6a_eutran_vector_t {
|
||||
c_uint8_t rand[MAX_RAND_LEN];
|
||||
c_uint8_t xres[MAX_XRES_LEN];
|
||||
c_uint8_t xres_len;
|
||||
c_uint8_t autn[MAX_AUTN_LEN];
|
||||
c_uint8_t kasme[MAX_KASME_LEN];
|
||||
} s6a_eutran_vector_t;
|
||||
|
||||
typedef struct _s6a_auth_info_t {
|
||||
c_uint8_t num_of_eutran_vector;
|
||||
s6a_eutran_vector_t s6a_eutran_vector[MAX_EUTRAN_VECTORS];
|
||||
|
||||
c_uint8_t immediate_response_preferred;
|
||||
} s6a_auth_info_t;
|
||||
|
||||
typedef struct _s6a_auth_info_req_t {
|
||||
c_uint8_t imsi[MAX_IMSI_BCD_DIGITS_LEN+1];
|
||||
c_uint8_t imsi_len;
|
||||
|
||||
plmn_id_t visited_plmn_id;
|
||||
|
||||
s6a_auth_info_t auth_info;
|
||||
} s6a_auth_info_req_t;
|
||||
|
||||
typedef struct _s6a_auth_info_ans_t {
|
||||
s6a_auth_info_t auth_info;
|
||||
} s6a_auth_info_ans_t;
|
||||
|
||||
CORE_DECLARE(int) s6a_send_auth_info_req(s6a_auth_info_req_t *air);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue