Commit 8dfa0882 authored by Erwan Croze's avatar Erwan Croze 👋🏻

Add a data user on tport struct

parent 6c9540d4
......@@ -374,6 +374,12 @@ TPORT_DLL int tport_keepalive(tport_t *tp, su_addrinfo_t const *ai,
TPORT_DLL float tport_get_packet_count_rate(tport_t *tp);
TPORT_DLL void tport_reset_packet_count_rate(tport_t *tp);
/** Set Data in tport */
TPORT_DLL void tport_set_user_data(tport_t *self, void* data);
/** Get Data from tport */
TPORT_DLL void* tport_get_user_data(tport_t *self);
/* ---------------------------------------------------------------------- */
/* SigComp-related functions */
......
......@@ -4681,7 +4681,7 @@ tport_t *tport_by_name(tport_t const *tp, tp_name_t const *tpn)
nocomp = self;
continue;
}
if (family == AF_INET && tpn->tpn_host && strcmp(tpn->tpn_host, "127.0.0.1") == 0 && ntohl(tp->tp_addr->su_sin.sin_addr.s_addr) == INADDR_LOOPBACK) {
SU_DEBUG_7(("tport: default primary changed to AF_INET loopback\n"));
default_primary = tp;
......@@ -4692,7 +4692,7 @@ tport_t *tport_by_name(tport_t const *tp, tp_name_t const *tpn)
if (!default_primary) {
default_primary=tp;
}
secondary=tport_by_name_from_primary(tp,tpn);
if (secondary) {
......@@ -5173,3 +5173,14 @@ float tport_get_packet_count_rate(tport_t *tp) {
void tport_reset_packet_count_rate(tport_t *tp) {
tp->tp_dos_stats.packet_count_rate = 0;
}
/** Set Data in tport */
void tport_set_user_data(tport_t *self, void* data) {
self->tp_user_data = data;
}
/** Get Data from tport */
void* tport_get_user_data(tport_t *self) {
return self->tp_user_data;
}
......@@ -120,8 +120,8 @@ typedef struct {
unsigned tpp_sdwn_error:1; /**< If true, shutdown is error. */
unsigned tpp_stun_server:1; /**< If true, use stun server */
unsigned tpp_pong2ping:1; /**< If true, respond with pong to ping */
unsigned :0;
......@@ -246,12 +246,15 @@ struct tport_s {
uint64_t sent_msgs, sent_errors, sent_bytes, sent_on_line;
uint64_t recv_msgs, recv_errors, recv_bytes, recv_on_line;
} tp_stats;
struct {
uint64_t recv_msg_count_since_last_check;
double last_check_recv_msg_check_time;
double packet_count_rate;
} tp_dos_stats;
/* ==== User Data ========================================================*/
void *tp_user_data; /**< Pointer of user data */
};
/** @internal Primary structure */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment