void Pgw::handle_downlink_udata(Packet pkt, UdpClient &sgw_s5_client) { uint64_t imsi; uint32_t s5_uteid_dl; string ue_ip_addr; bool res; ue_ip_addr = g_nw.get_dst_ip_addr(pkt); imsi = get_imsi(0, 0, ue_ip_addr); if (imsi == 0) { TRACE(cout << "pgw_handledownlinkudata:" << " :zero imsi " << pkt.gtp_hdr.teid << " " << pkt.len << ": " << imsi << endl;) return;
void Sgw::handle_modify_bearer(struct sockaddr_in src_sock_addr, Packet pkt) { uint64_t imsi; uint32_t s1_uteid_dl; uint32_t s11_cteid_mme; uint8_t eps_bearer_id; string enodeb_ip_addr; int enodeb_port; bool res; imsi = get_imsi(11, pkt.gtp_hdr.teid); if (imsi == 0) { TRACE(cout << "sgw_handlemodifybearer:" << " :zero imsi " << pkt.gtp_hdr.teid << " " << pkt.len << ": " << imsi << endl;)
void Sgw::handle_modify_bearer(struct sockaddr_in src_sock_addr, Packet pkt) { uint64_t imsi; uint32_t s1_uteid_dl; uint32_t s11_cteid_mme; uint8_t eps_bearer_id; string enodeb_ip_addr; int enodeb_port; bool res; //cout<<" In "<<pkt.gtp_hdr.teid; imsi = get_imsi(11, pkt.gtp_hdr.teid); if (imsi == 0) { //Added by trisahl s11_cteid_mme = pkt.gtp_hdr.teid; res = true; pkt.clear_pkt(); pkt.append_item(res); cout<<"\n Handled modify:"<<s11_cteid_mme<<endl; pkt.prepend_gtp_hdr(2, 2, pkt.len, s11_cteid_mme); s11_server.snd(src_sock_addr, pkt); return; //Added done by trisahl TRACE(cout << "sgw_handlemodifybearer:" << " :zero imsi " << pkt.gtp_hdr.teid << " " << pkt.len << ": " << imsi << endl;)
static int dcca_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act) { struct msg * m; struct avp_hdr * val_app_id = NULL, * val_rt = NULL, * val_rn = NULL, * val_io = NULL, * val_oo = NULL, *val_imsi = NULL; struct avp *groupedavp = NULL, *groupedavp2 = NULL; union avp_value validity_time, total_octets, result_code, rating_group; struct avp * a = NULL, * aa = NULL; int input_octets = 0, output_octets = 0; char* imsi = NULL; LOG_N("CCR processor"); TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act); if (msg == NULL) return EINVAL; // // Read AVPs from request // // CHECK_FCT( dcca_read_avps_from_message(*msg) ); // Read AVPs CHECK_FCT( dcca_cb_read(msg, dcca_dict.Auth_Application_Id, &val_app_id) ); CHECK_FCT( dcca_cb_read(msg, dcca_dict.CC_Request_Type, &val_rt) ); CHECK_FCT( dcca_cb_read(msg, dcca_dict.CC_Request_Number, &val_rn) ); // Read IMSI CHECK_FCT( get_imsi(*msg, &a) ); if (a) { CHECK_FCT( fd_msg_avp_hdr( a, &val_imsi ) ); int len = val_imsi->avp_value->os.len; imsi = malloc(len * sizeof(char)); int i; for (i = 0; i < len; i++) { imsi[i] = val_imsi->avp_value->os.data[i]; } imsi[len] = 0; } // Read Input / Output Octets CHECK_FCT( fd_msg_search_avp ( *msg, dcca_dict.Multiple_Services_Credit_Control, &a) ); if (a) { CHECK_FCT( avp_search_child ( a, dcca_dict.Used_Service_Unit, &a) ); if (a) { CHECK_FCT( avp_search_child ( a, dcca_dict.CC_Input_Octets, &aa) ); if (aa) { CHECK_FCT( fd_msg_avp_hdr( aa, &val_io ) ); input_octets = val_io->avp_value->i32; } CHECK_FCT( avp_search_child ( a, dcca_dict.CC_Output_Octets, &aa) ); if (aa) { CHECK_FCT( fd_msg_avp_hdr( aa, &val_oo ) ); output_octets = val_oo->avp_value->i32; } } } LOG_N("IMSI: %s", imsi); LOG_N("IN: %i", input_octets); LOG_N("OUT: %i", output_octets); // Create response message CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, 0 ) ); m = *msg; CHECK_FCT( fd_msg_rescode_set( m, "DIAMETER_SUCCESS", NULL, NULL, 1 ) ); // Put params to response CHECK_FCT( dcca_cb_put(m, dcca_dict.Auth_Application_Id, val_app_id) ); CHECK_FCT( dcca_cb_put(m, dcca_dict.CC_Request_Type, val_rt) ); CHECK_FCT( dcca_cb_put(m, dcca_dict.CC_Request_Number, val_rn) ); // Multiple Services CC Group total_octets.i64 = rest_api_vsca(imsi, input_octets, output_octets); CHECK_FCT( fd_msg_avp_new ( dcca_dict.Multiple_Services_Credit_Control, 0, &groupedavp ) ); // Granted Service Unit CHECK_FCT( fd_msg_avp_new ( dcca_dict.Granted_Service_Unit, 0, &groupedavp2 ) ); CHECK_FCT( dcca_cb_put_value_to_avp(groupedavp2, dcca_dict.CC_Total_Octets, &total_octets) ); CHECK_FCT( fd_msg_avp_add( groupedavp, MSG_BRW_LAST_CHILD, groupedavp2 ) ); // Result code result_code.i32 = 2001; CHECK_FCT( dcca_cb_put_value_to_avp(groupedavp, dcca_dict.Result_Code, &result_code) ); // Rating group rating_group.i32 = 1001; CHECK_FCT( dcca_cb_put_value_to_avp(groupedavp, dcca_dict.Rating_Group, &rating_group) ); // Validity Time validity_time.i32 = 60; CHECK_FCT( dcca_cb_put_value_to_avp(groupedavp, dcca_dict.Validity_Time, &validity_time) ); CHECK_FCT( fd_msg_avp_add( m, MSG_BRW_LAST_CHILD, groupedavp ) ); // Send the answer *act = DISP_ACT_SEND; return 0; }