Skip to content

Commit

Permalink
Clean up types and mispellings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adel Lahlou committed Apr 2, 2024
1 parent cf631cb commit 6149d8a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions src/apps/relay/ns_ioalib_engine_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3576,7 +3576,7 @@ void turn_report_allocation_set(void *a, turn_time_t lifetime, int refresh) {
if (!refresh)
prom_inc_allocation(get_ioa_socket_type(ss->client_socket),
get_ioa_socket_address_family(ss->client_socket),
(const char *) ss->protocolgroup);
ss->protocolgroup);
}
}
}
Expand Down Expand Up @@ -3639,26 +3639,26 @@ void turn_report_allocation_delete(void *a, SOCKET_TYPE socket_type, int family)
prom_set_finished_traffic(ss->realm_options.name, (const char *)ss->username,
(unsigned long)(ss->t_received_packets), (unsigned long)(ss->t_received_bytes),
(unsigned long)(ss->t_sent_packets), (unsigned long)(ss->t_sent_bytes),
(unsigned long)ss->t_before_ping_packets, false, (const char *) ss->protocolgroup);
(unsigned long)ss->t_before_ping_packets, false, ss->protocolgroup);
prom_set_finished_traffic(
ss->realm_options.name, (const char *)ss->username, (unsigned long)(ss->t_peer_received_packets),
(unsigned long)(ss->t_peer_received_bytes), (unsigned long)(ss->t_peer_sent_packets),
(unsigned long)(ss->t_peer_sent_bytes), 0, true, (const char *) ss->protocolgroup);
(unsigned long)(ss->t_peer_sent_bytes), 0, true, ss->protocolgroup);
} else {
// Set prometheus traffic metrics
prom_set_finished_traffic(NULL, (const char *)ss->username, (unsigned long)(ss->t_received_packets),
(unsigned long)(ss->t_received_bytes), (unsigned long)(ss->t_sent_packets),
(unsigned long)(ss->t_sent_bytes), (unsigned long)ss->t_before_ping_packets,
false, (const char *) ss->protocolgroup);
false, ss->protocolgroup);
prom_set_finished_traffic(NULL, (const char *)ss->username, (unsigned long)(ss->t_peer_received_packets),
(unsigned long)(ss->t_peer_received_bytes),
(unsigned long)(ss->t_peer_sent_packets), (unsigned long)(ss->t_peer_sent_bytes),
0, true, (const char *) ss->protocolgroup);
0, true, ss->protocolgroup);
}
turn_time_t ct = get_turn_server_time(server) - ss->start_time;
const uint32_t byte_to_kilobit = 125;
uint64_t sent_rate_kbps = ss->sent_rate / byte_to_kilobit;
prom_dec_allocation(socket_type, family, (unsigned long)ct, (unsigned long)sent_rate_kbps, (const char *) ss->protocolgroup);
prom_dec_allocation(socket_type, family, (unsigned long)ct, (unsigned long)sent_rate_kbps, ss->protocolgroup);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/apps/relay/prom_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void start_prometheus_server(void) {

// Signal change to add metrics
void prom_set_finished_traffic(const char *realm, const char *user, unsigned long rsvp, unsigned long rsvb,
unsigned long sentp, unsigned long sentb, unsigned long without_pingp, bool peer, const char* protocolgroup) {
unsigned long sentp, unsigned long sentb, unsigned long without_pingp, bool peer, const char *protocolgroup) {
if (turn_params.prometheus == 1) {

// Signal change to add protocol-group label to metrics
Expand Down Expand Up @@ -314,7 +314,7 @@ int is_ipv6_enabled(void) {
}

// Signal change to add rtt metrics
void prom_observe_rtt(prom_counter_t *counter[8], int microseconds, const char* protocolgroup) {
void prom_observe_rtt(prom_counter_t *counter[8], int microseconds, const char *protocolgroup) {
const char *label[] = { protocolgroup };
if (microseconds <= 25000) {
prom_counter_add(counter[0], 1, label);
Expand Down
2 changes: 1 addition & 1 deletion src/apps/relay/prom_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void prom_set_finished_traffic(const char *realm, const char *user, unsigned lon
unsigned long sentp, unsigned long sentb, unsigned long without_pingp, bool peer, const char *protocolgroup);

void prom_inc_allocation(SOCKET_TYPE type, int addr_family, const char *protocolgroup);
// Signal change to add protocolprotocol-group label
// Signal change to add protocol-group label
void prom_dec_allocation(SOCKET_TYPE type, int addr_family, unsigned long duration, unsigned long sent_rate_kbps, const char *protocolgroup);

int is_ipv6_enabled(void);
Expand Down
12 changes: 6 additions & 6 deletions src/server/ns_turn_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ static int good_peer_addr(turn_turnserver *server, const char *realm, ioa_addr *
allocation *get_allocation_ss(ts_ur_super_session *ss) { return &(ss->alloc); }

void set_protocolgroup(ts_ur_super_session *ss) {
char *group = strrchr((char *) ss->username, '#');
char *group = strrchr((char *)ss->username, '#');
if (group != NULL) {
strncpy((char *) ss->protocolgroup, group, MAX_PROTOCOL_GROUP_SIZE);
strncpy(ss->protocolgroup, group, MAX_PROTOCOL_GROUP_SIZE);
} else {
strncpy((char *) ss->protocolgroup, DEFAULT_PROTOCOL_GROUP, MAX_PROTOCOL_GROUP_SIZE);
strncpy(ss->protocolgroup, DEFAULT_PROTOCOL_GROUP, MAX_PROTOCOL_GROUP_SIZE);
}
}

Expand Down Expand Up @@ -2945,12 +2945,12 @@ static int inspect_binds(ts_ur_super_session *ss, turn_turnserver *server, ioa_n
#if !defined(TURN_NO_PROMETHEUS)
if (is_channel) {
if (from_client) {
prom_observe_rtt_client(diffus, (const char *) ss->protocolgroup);
prom_observe_rtt_client(diffus, ss->protocolgroup);
} else {
prom_observe_rtt_peer(diffus, (const char *) ss->protocolgroup);
prom_observe_rtt_peer(diffus, ss->protocolgroup);
}
if (tinfo->pings[from_peer].lastrttus > 0) {
prom_observe_rtt_combined(diffus + tinfo->pings[from_peer].lastrttus, (const char *) ss->protocolgroup);
prom_observe_rtt_combined(diffus + tinfo->pings[from_peer].lastrttus, ss->protocolgroup);
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/server/ns_turn_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct _ts_ur_super_session {
// Signal change to add metrics
uint64_t t_before_ping_packets;
// Signal change to add protocol-group label to metrics
uint8_t protocolgroup[MAX_PROTOCOL_GROUP_SIZE + 1];
char protocolgroup[MAX_PROTOCOL_GROUP_SIZE + 1];
};

////// Session info for statistics //////
Expand Down

0 comments on commit 6149d8a

Please sign in to comment.