aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/rsl.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-04-24 14:26:17 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-04-24 14:34:10 +0700
commit19bd4f818d30754130f25e15dcef6697c6320d74 (patch)
treead11a58f96ec826464e5402f0aeb2b03a8bdd9e2 /src/common/rsl.c
parentd16b69f29e2e09efdebb2bff60b98c62c7b717b5 (diff)
common/rsl.c: fix unaligned pointers in rsl_add_rtp_stats()
Found using clang-8: rsl.c:1646:7: warning: taking address of packed member 'packets_sent' of class or structure 'ipa_stats' may result in an unaligned pointer value rsl.c:1646:28: warning: taking address of packed member 'octets_sent' of class or structure 'ipa_stats' may result in an unaligned pointer value rsl.c:1647:7: warning: taking address of packed member 'packets_recv' of class or structure 'ipa_stats' may result in an unaligned pointer value rsl.c:1647:28: warning: taking address of packed member 'octets_recv' of class or structure 'ipa_stats' may result in an unaligned pointer value rsl.c:1648:7: warning: taking address of packed member 'packets_lost' of class or structure 'ipa_stats' may result in an unaligned pointer value rsl.c:1648:28: warning: taking address of packed member 'arrival_jitter' of class or structure 'ipa_stats' may result in an unaligned pointer value Change-Id: Ifba33cfd8edeccc99a21c7d076db7119c29d4f40
Diffstat (limited to 'src/common/rsl.c')
-rw-r--r--src/common/rsl.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 8f5d6890..c2a7db62 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -1627,33 +1627,33 @@ static int rsl_rx_sacch_inf_mod(struct msgb *msg)
*/
static void rsl_add_rtp_stats(struct gsm_lchan *lchan, struct msgb *msg)
{
- struct ipa_stats {
- uint32_t packets_sent;
- uint32_t octets_sent;
- uint32_t packets_recv;
- uint32_t octets_recv;
- uint32_t packets_lost;
- uint32_t arrival_jitter;
- uint32_t avg_tx_delay;
- } __attribute__((packed));
+ uint32_t packets_sent, octets_sent;
+ uint32_t packets_recv, octets_recv;
+ uint32_t packets_lost;
+ uint32_t arrival_jitter;
- struct ipa_stats stats;
+ msgb_tv_put(msg, RSL_IE_IPAC_CONN_STAT, sizeof(uint32_t) * 7);
- memset(&stats, 0, sizeof(stats));
-
- if (lchan->abis_ip.rtp_socket)
+ if (lchan->abis_ip.rtp_socket) {
osmo_rtp_socket_stats(lchan->abis_ip.rtp_socket,
- &stats.packets_sent, &stats.octets_sent,
- &stats.packets_recv, &stats.octets_recv,
- &stats.packets_lost, &stats.arrival_jitter);
- /* convert to network byte order */
- stats.packets_sent = htonl(stats.packets_sent);
- stats.octets_sent = htonl(stats.octets_sent);
- stats.packets_recv = htonl(stats.packets_recv);
- stats.octets_recv = htonl(stats.octets_recv);
- stats.packets_lost = htonl(stats.packets_lost);
-
- msgb_tlv_put(msg, RSL_IE_IPAC_CONN_STAT, sizeof(stats), (uint8_t *) &stats);
+ &packets_sent, &octets_sent,
+ &packets_recv, &octets_recv,
+ &packets_lost, &arrival_jitter);
+
+ /* msgb_put_u32() uses osmo_store32be(),
+ * so we don't need to call htonl(). */
+ msgb_put_u32(msg, packets_sent);
+ msgb_put_u32(msg, octets_sent);
+ msgb_put_u32(msg, packets_recv);
+ msgb_put_u32(msg, octets_recv);
+ msgb_put_u32(msg, packets_lost);
+ msgb_put_u32(msg, arrival_jitter);
+ /* FIXME: AVG Tx delay is always 0 */
+ msgb_put_u32(msg, 0);
+ } else {
+ msgb_put(msg, sizeof(uint32_t) * 7);
+ memset(msg->tail, 0x00, sizeof(uint32_t) * 7);
+ }
}
int rsl_tx_ipac_dlcx_ind(struct gsm_lchan *lchan, uint8_t cause)