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