blob: 3225d6a3d1f0b188131cda493a6ebc2b12cd54c8 [file] [log] [blame]
Harald Weltefaea7542016-12-24 01:21:03 +01001#include <stdio.h>
2
3#include "diag_log.h"
Harald Welte84ec50f2016-12-24 10:16:00 +01004#include "protocol/diag_log_gsm.h"
5#include "protocol/diag_log_gprs_rlc.h"
6#include "protocol/diag_log_gprs_mac.h"
Harald Weltefaea7542016-12-24 01:21:03 +01007
8
9static void handle_grr_state_msg(struct log_hdr *lh, struct msgb *msg)
10{
11 struct diag_gprs_grr_state *rrs = (struct diag_gprs_grr_state *) msgb_data(msg);
12
13 printf("GRR-STATE { active=%u, state=%s }\n", rrs->active_state,
14 get_value_string(diag_gprs_grr_st_vals, rrs->grr_state));
15}
16
17static void handle_rlc_ul_abnrml_rls(struct log_hdr *lh, struct msgb *msg)
18{
19 struct gprs_rlc_ul_abnrml_rls_counts *arc;
20 arc = (struct gprs_rlc_ul_abnrml_rls_counts *) msgb_data(msg);
21
22 printf("RLC-UL-ABNRML-RLS-COUNTS { access_reject_cnt=%u, arc_retry_cnt=%u, arc_wo_retry_cnt=%u, arc_sys_info_cnt=%u }",
23 arc->access_reject_cnt, arc->arc_retry_cnt, arc->arc_wo_retry_cnt, arc->arc_sys_info_cnt);
24}
25
26static void handle_mac_sign_msg(struct log_hdr *lh, struct msgb *msg)
27{
28 struct gprs_mac_signalling_msg *msm;
29 msm = (struct gprs_mac_signalling_msg *) msgb_data(msg);
30 printf("MAC-SIGN-MSG { chan_type=%s, msg_type=%s, msg=%s }\n",
31 get_value_string(gprs_mac_chan_type_vals, msm->chan_type),
32 get_value_string(gprs_mac_msg_type_vals, msm->msg_type),
33 osmo_hexdump(msm->msg, msm->msg_len));
34}
35
36static void handle_llc_me_info(struct log_hdr *lh, struct msgb *msg)
37{
38 struct diag_gprs_llme_info *gli;
39 gli = (struct diag_gprs_llme_info *) msgb_data(msg);
40 printf("LLC-ME-INFO { state=%s, xid_version=%u, tlli_new=0x%08x, tlli_old=0x%08x, gea=%u, key=%s }\n",
41 get_value_string(diag_gprs_llme_st_vals, gli->state), gli->xid_version,
42 gli->tlli_new, gli->tlli_old, gli->enc_alg,
43 osmo_hexdump_nospc(gli->enc_key, sizeof(gli->enc_key)));
44}
45
46static void handle_llc_pdu_stats(struct log_hdr *lh, struct msgb *msg)
47{
48 struct diag_gprs_llc_stats *gls;
49 gls = (struct diag_gprs_llc_stats *) msgb_data(msg);
50 printf("LLC-PDU-STATS-ACK { sap=%u, l3pdu_tx=%u, octet_tx=%u, octet_retrans=%u, l3pdu_rx=%u, octet_rx=%u }\n",
51 gls->sapi, gls->ack_l3pdu_tx, gls->ack_octet_tx, gls->ack_l3pdu_retrans, gls->ack_l3pdu_rx, gls->ack_octet_rx);
52 printf("LLC-PDU-STATS-UNACK { sapi=%u, l3pdu_tx=%u, octet_tx=%u, l3pdu_rx=%u, octet_rx=%u }\n",
53 gls->sapi, gls->unack_l3pdu_tx, gls->unack_octet_tx, gls->unack_l3pdu_rx, gls->unack_octet_rx);
54 printf("LLC-PDU-STATS-LLPDU { tx=%u, rx=%u, fcs_err=%u, frm_rej=%u, tlli_err=%u, addr_err=%u, short_err=%u }\n",
55 gls->llpdu_tx, gls->llpdu_rx, gls->llpdu_fcs_err, gls->llpdu_frm_rej, gls->llpdu_tlli_err, gls->llpdu_addr_err, gls->llpdu_short_err);
56}
57
58static void handle_mac_state(struct log_hdr *lh, struct msgb *msg)
59{
60 struct gprs_mac_state_change *msc;
61 msc = (struct gprs_mac_state_change *) msgb_data(msg);
62 const char *name = "";
63
64 switch (msc->mac_mode) {
65 case NULL_MODE:
66 name = get_value_string(gprs_mac_null_substate_vals, msc->mac_null_fsm_state);
67 break;
68 case IDLE_MODE:
69 name = get_value_string(gprs_mac_idle_substate_vals, msc->mac_idle_fsm_state);
70 break;
71 case TRANSFER_MODE:
72 name = get_value_string(gprs_mac_transfer_substate_vals, msc->mac_transfer_fsm_state);
73 break;
74 }
75
76 printf("MAC-STATE { mode=%s, state=%s }\n",
77 get_value_string(gprs_mac_mode_vals, msc->mac_mode), name);
78}
79
80static void handle_mac_dl_tbf_est(struct log_hdr *lh, struct msgb *msg)
81{
82 struct gprs_mac_dl_tbf_est *dte;
83 dte = (struct gprs_mac_dl_tbf_est *) msgb_data(msg);
84
85 printf("MAC-DL-TBF-EST { tfi=%u, rlc_mode=%u, dl_ts_bmap=0x%x, is_egprs=%u, egprs_win_size=%u, egprs_link_qual_mode=%u, bep_period2=%u }\n",
86 dte->dl_tfi, dte->rlc_mode, dte->dl_ts_bmap, dte->is_egprs_tbf, dte->egprs_win_size, dte->egprs_link_qual_mode, dte->bep_period2);
87}
88
89static void handle_mac_ul_tbf_est(struct log_hdr *lh, struct msgb *msg)
90{
91 struct gprs_mac_ul_tbf_est *ute;
92 ute = (struct gprs_mac_ul_tbf_est *) msgb_data(msg);
93
94 printf("MAC-UL-TBF-EST { tbf_req_cause=%u, acc_granted=%u, radio_prio=%u, peak_tput=%u, ul_tfi=%u, rlc_mode=%u, ul_ts_bmap=0x%x, is_egprs=%u, egprs_win_size=%u, resegment=%u, bep_period2=%u }\n",
95 ute->tbf_req_cause, ute->acc_granted, ute->radio_prio, ute->peak_tput, ute->ul_tfi, ute->rlc_mode, ute->ul_ts_bmap, ute->is_egprs_tbf, ute->egprs_win_size, ute->resegment, ute->bep_period2);
96}
97
98static void handle_mac_dl_tbf_rel(struct log_hdr *lh, struct msgb *msg)
99{
100 struct gprs_mac_tbf_release *tr;
101 tr = (struct gprs_mac_tbf_release *) msgb_data(msg);
102
103 printf("MAC-DL-TBF-REL { tfi=%u, fail_cause=%u }\n", tr->tfi, tr->fail_cause);
104}
105
106static void handle_mac_ul_tbf_rel(struct log_hdr *lh, struct msgb *msg)
107{
108 struct gprs_mac_tbf_release *tr;
109 tr = (struct gprs_mac_tbf_release *) msgb_data(msg);
110
111 printf("MAC-DL-TBF-REL { tfi=%u, fail_cause=%u }\n", tr->tfi, tr->fail_cause);
112}
113
114static void handle_rlc_ul_evt_cnt(struct log_hdr *lh, struct msgb *msg)
115{
116 struct gprs_rlc_ul_event_counts *uec;
117 uec = (struct gprs_rlc_ul_event_counts *) msgb_data(msg);
118
119 printf("RLC-UL-EVT-CNT { llc_event_cnt=%u, mac_event_cnt=%u, pl1_event_cnt=%u, tmr_event_cnt=%u }\n",
120 uec->llc_event_cnt, uec->mac_event_cnt, uec->pl1_event_cnt, uec->tmr_event_cnt);
121}
122
123static void handle_rlc_ul_stats(struct log_hdr *lh, struct msgb *msg)
124{
125 struct gprs_rlc_ul_stats *uls;
126 uls = (struct gprs_rlc_ul_stats *) msgb_data(msg);
127
128 printf("RLC-UL-STATS { state=%s(%s), FIXME... }\n",
129 get_value_string(gprs_rlc_ul_state_vals, uls->rlc_ul_state),
130 get_value_string(gprs_rlc_ul_substate_vals, uls->rlc_ul_substate));
131}
132
133static void handle_rlc_dl_stats(struct log_hdr *lh, struct msgb *msg)
134{
135 struct gprs_rlc_dl_stats *dls;
136 dls = (struct gprs_rlc_dl_stats *) msgb_data(msg);
137
138 printf("RLC-DL-STATS { state=%s, FIXME... }\n",
139 get_value_string(gprs_rlc_dl_state_vals, dls->rlc_dl_state));
140}
141
142static void handle_rlc_rel(struct log_hdr *lh, struct msgb *msg)
143{
144 struct gprs_rlc_release_ind *rli;
145 rli = (struct gprs_rlc_release_ind *) msgb_data(msg);
146 char ud = 'D';
147
148 if (lh->code == LOG_GPRS_RLC_UL_RELEASE_IND_C)
149 ud ='U';
150
151 printf("RLC-%cL-RELEASE { tfi=%u, cause=%u }\n", ud, rli->tfi, rli->cause);
152}
153
154
155static const struct diag_log_dispatch_tbl log_tbl[] = {
156 { GSM(LOG_GPRS_LLC_ME_INFO_C), handle_llc_me_info },
157 { GSM(LOG_GPRS_LLC_PDU_STATS_C), handle_llc_pdu_stats },
158 { GSM(LOG_GPRS_GRR_STATE_C), handle_grr_state_msg },
159 { GSM(LOG_GPRS_RLC_UL_ABNRML_RLS_COUNTS_C), handle_rlc_ul_abnrml_rls },
160 { GSM(LOG_GPRS_RLC_UL_EVENT_COUNTS_C), handle_rlc_ul_evt_cnt },
161 { GSM(LOG_GPRS_RLC_UL_RELEASE_IND_C), handle_rlc_rel },
162 { GSM(LOG_GPRS_RLC_DL_RELEASE_IND_C), handle_rlc_rel },
163 { GSM(LOG_GPRS_MAC_SIGNALLING_MESSAGE_C), handle_mac_sign_msg },
164 { GSM(LOG_GPRS_MAC_STATE_C), handle_mac_state },
165 { GSM(LOG_GPRS_MAC_DL_TBF_ESTABLISH_C), handle_mac_dl_tbf_est },
166 { GSM(LOG_GPRS_MAC_UL_TBF_ESTABLISH_C), handle_mac_ul_tbf_est },
167 { GSM(LOG_GPRS_MAC_DL_TBF_RELEASE_C), handle_mac_dl_tbf_rel },
168 { GSM(LOG_GPRS_MAC_UL_TBF_RELEASE_C), handle_mac_ul_tbf_rel },
169 { GSM(LOG_GPRS_RLC_UL_STATS_C), handle_rlc_ul_stats },
170 { GSM(LOG_GPRS_RLC_DL_STATS_C), handle_rlc_dl_stats },
171};
172
173static __attribute__((constructor)) void on_dso_load_gprs(void)
174{
175 diag_log_reg_dispatch(log_tbl, ARRAY_SIZE(log_tbl));
176}