aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@fh-muenster.de>2024-05-10 22:39:48 +0200
committerMichael Tuexen <tuexen@fh-muenster.de>2024-05-10 22:39:48 +0200
commit4308e5e6f510db4b6fcfffdc753cb8bddaaf4b5c (patch)
tree9da656a80eb95efa5f871ea2ce7540a21675ed47
parent45cf3ba8c4adc67a9fb4a192ec6f1f761fc7b677 (diff)
downloadusrsctp-4308e5e6f510db4b6fcfffdc753cb8bddaaf4b5c.tar.gz
Use time_t where appropriate
-rwxr-xr-xusrsctplib/netinet/sctp_header.h2
-rwxr-xr-xusrsctplib/netinet/sctp_input.c4
-rwxr-xr-xusrsctplib/netinet/sctp_output.c2
-rwxr-xr-xusrsctplib/netinet/sctp_pcb.c16
-rwxr-xr-xusrsctplib/netinet/sctp_pcb.h12
-rwxr-xr-xusrsctplib/netinet/sctputil.c5
6 files changed, 21 insertions, 20 deletions
diff --git a/usrsctplib/netinet/sctp_header.h b/usrsctplib/netinet/sctp_header.h
index 78206581..7a5ab643 100755
--- a/usrsctplib/netinet/sctp_header.h
+++ b/usrsctplib/netinet/sctp_header.h
@@ -93,7 +93,7 @@ struct sctp_supported_addr_param {
/* heartbeat info parameter */
struct sctp_heartbeat_info_param {
struct sctp_paramhdr ph;
- uint32_t time_value_1;
+ time_t time_value_1;
uint32_t time_value_2;
uint32_t random_value1;
uint32_t random_value2;
diff --git a/usrsctplib/netinet/sctp_input.c b/usrsctplib/netinet/sctp_input.c
index a7f7afc0..a3c1476f 100755
--- a/usrsctplib/netinet/sctp_input.c
+++ b/usrsctplib/netinet/sctp_input.c
@@ -2635,7 +2635,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
}
ep = &(*inp_p)->sctp_ep;
/* which cookie is it? */
- if ((cookie->time_entered.tv_sec < (long)ep->time_of_secret_change) &&
+ if ((cookie->time_entered.tv_sec < ep->time_of_secret_change) &&
(ep->current_secret_number != ep->last_secret_number)) {
/* it's the old cookie */
(void)sctp_hmac_m(SCTP_HMAC,
@@ -2658,7 +2658,7 @@ sctp_handle_cookie_echo(struct mbuf *m, int iphlen, int offset,
/* compare the received digest with the computed digest */
if (timingsafe_bcmp(calc_sig, sig, SCTP_SIGNATURE_SIZE) != 0) {
/* try the old cookie? */
- if ((cookie->time_entered.tv_sec == (long)ep->time_of_secret_change) &&
+ if ((cookie->time_entered.tv_sec == ep->time_of_secret_change) &&
(ep->current_secret_number != ep->last_secret_number)) {
/* compute digest with old */
(void)sctp_hmac_m(SCTP_HMAC,
diff --git a/usrsctplib/netinet/sctp_output.c b/usrsctplib/netinet/sctp_output.c
index 2bb80076..33a6e169 100755
--- a/usrsctplib/netinet/sctp_output.c
+++ b/usrsctplib/netinet/sctp_output.c
@@ -12194,7 +12194,7 @@ sctp_send_hb(struct sctp_tcb *stcb, struct sctp_nets *net,int so_locked)
/* Fill out hb parameter */
hb->heartbeat.hb_info.ph.param_type = htons(SCTP_HEARTBEAT_INFO);
hb->heartbeat.hb_info.ph.param_length = htons(sizeof(struct sctp_heartbeat_info_param));
- hb->heartbeat.hb_info.time_value_1 = (uint32_t)now.tv_sec;
+ hb->heartbeat.hb_info.time_value_1 = now.tv_sec;
hb->heartbeat.hb_info.time_value_2 = now.tv_usec;
/* Did our user request this one, put it in */
hb->heartbeat.hb_info.addr_family = (uint8_t)net->ro._l_addr.sa.sa_family;
diff --git a/usrsctplib/netinet/sctp_pcb.c b/usrsctplib/netinet/sctp_pcb.c
index f4429e75..cedb8ee0 100755
--- a/usrsctplib/netinet/sctp_pcb.c
+++ b/usrsctplib/netinet/sctp_pcb.c
@@ -2996,7 +2996,7 @@ sctp_inpcb_alloc(struct socket *so, uint32_t vrf_id)
/* Setup the initial secret */
(void)SCTP_GETTIME_TIMEVAL(&time);
- m->time_of_secret_change = (unsigned int)time.tv_sec;
+ m->time_of_secret_change = time.tv_sec;
for (i = 0; i < SCTP_NUMBER_OF_SECRETS; i++) {
m->secret_key[0][i] = sctp_select_initial_TSN(m);
@@ -5303,7 +5303,7 @@ sctp_del_remote_addr(struct sctp_tcb *stcb, struct sockaddr *remaddr)
}
static bool
-sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport, uint32_t now)
+sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport, time_t now)
{
struct sctpvtaghead *chain;
struct sctp_tagblock *twait_block;
@@ -5325,7 +5325,7 @@ sctp_is_in_timewait(uint32_t tag, uint16_t lport, uint16_t rport, uint32_t now)
}
static void
-sctp_set_vtag_block(struct sctp_timewait *vtag_block, uint32_t time,
+sctp_set_vtag_block(struct sctp_timewait *vtag_block, time_t time,
uint32_t tag, uint16_t lport, uint16_t rport)
{
vtag_block->tv_sec_at_expire = time;
@@ -5340,13 +5340,13 @@ sctp_add_vtag_to_timewait(uint32_t tag, uint16_t lport, uint16_t rport)
struct sctpvtaghead *chain;
struct sctp_tagblock *twait_block;
struct timeval now;
- uint32_t time;
+ time_t time;
int i;
bool set;
SCTP_INP_INFO_WLOCK_ASSERT();
(void)SCTP_GETTIME_TIMEVAL(&now);
- time = (uint32_t)now.tv_sec + SCTP_BASE_SYSCTL(sctp_vtag_time_wait);
+ time = now.tv_sec + SCTP_BASE_SYSCTL(sctp_vtag_time_wait);
chain = &SCTP_BASE_INFO(vtag_timewait)[(tag % SCTP_STACK_VTAG_HASH_SIZE)];
set = false;
LIST_FOREACH(twait_block, chain, sctp_nxt_tagblock) {
@@ -5358,7 +5358,7 @@ sctp_add_vtag_to_timewait(uint32_t tag, uint16_t lport, uint16_t rport)
continue;
}
if ((twait_block->vtag_block[i].v_tag != 0) &&
- (twait_block->vtag_block[i].tv_sec_at_expire < (uint32_t)now.tv_sec)) {
+ (twait_block->vtag_block[i].tv_sec_at_expire < now.tv_sec)) {
if (set) {
/* Audit expires this guy */
sctp_set_vtag_block(twait_block->vtag_block + i, 0, 0, 0, 0);
@@ -5621,7 +5621,9 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
SOCKBUF_LOCK(&so->so_rcv);
so->so_state &= ~(SS_ISCONNECTING |
SS_ISDISCONNECTING |
+#if !(defined(__FreeBSD__) && !defined(__Userspace__))
SS_ISCONFIRMING |
+#endif
SS_ISCONNECTED);
so->so_state |= SS_ISDISCONNECTED;
#if defined(__APPLE__) && !defined(__Userspace__)
@@ -7758,7 +7760,7 @@ sctp_is_vtag_good(uint32_t tag, uint16_t lport, uint16_t rport, struct timeval *
return (false);
}
}
- return (!sctp_is_in_timewait(tag, lport, rport, (uint32_t)now->tv_sec));
+ return (!sctp_is_in_timewait(tag, lport, rport, now->tv_sec));
}
static void
diff --git a/usrsctplib/netinet/sctp_pcb.h b/usrsctplib/netinet/sctp_pcb.h
index 5298afc2..0fc70c56 100755
--- a/usrsctplib/netinet/sctp_pcb.h
+++ b/usrsctplib/netinet/sctp_pcb.h
@@ -131,10 +131,10 @@ struct sctp_block_entry {
};
struct sctp_timewait {
- uint32_t tv_sec_at_expire; /* the seconds from boot to expire */
- uint32_t v_tag; /* the vtag that can not be reused */
- uint16_t lport; /* the local port used in vtag */
- uint16_t rport; /* the remote port used in vtag */
+ time_t tv_sec_at_expire; /* the seconds from boot to expire */
+ uint32_t v_tag; /* the vtag that can not be reused */
+ uint16_t lport; /* the local port used in vtag */
+ uint16_t rport; /* the remote port used in vtag */
};
struct sctp_tagblock {
@@ -347,8 +347,8 @@ struct sctp_base_info {
* access /dev/random.
*/
struct sctp_pcb {
- unsigned int time_of_secret_change; /* number of seconds from
- * timeval.tv_sec */
+ time_t time_of_secret_change; /* number of seconds from
+ * timeval.tv_sec */
uint32_t secret_key[SCTP_HOW_MANY_SECRETS][SCTP_NUMBER_OF_SECRETS];
unsigned int size_of_a_cookie;
diff --git a/usrsctplib/netinet/sctputil.c b/usrsctplib/netinet/sctputil.c
index 4a1518f7..4c833e29 100755
--- a/usrsctplib/netinet/sctputil.c
+++ b/usrsctplib/netinet/sctputil.c
@@ -1830,8 +1830,7 @@ sctp_timeout_handler(void *t)
goto out_decr;
}
tmr->stopped_from = 0xa002;
- SCTPDBG(SCTP_DEBUG_TIMER2, "Timer type %d goes off: inp=%p, stcb=%p, net=%p.\n",
- type, inp, stcb, net);
+ SCTPDBG(SCTP_DEBUG_TIMER2, "Timer type %d goes off.\n", type);
if (!SCTP_OS_TIMER_ACTIVE(&tmr->timer)) {
SCTPDBG(SCTP_DEBUG_TIMER2,
"Timer type %d handler exiting due to not being active.\n",
@@ -2022,7 +2021,7 @@ sctp_timeout_handler(void *t)
type, inp, stcb, net));
SCTP_STAT_INCR(sctps_timosecret);
(void)SCTP_GETTIME_TIMEVAL(&tv);
- inp->sctp_ep.time_of_secret_change = (unsigned int)tv.tv_sec;
+ inp->sctp_ep.time_of_secret_change = tv.tv_sec;
inp->sctp_ep.last_secret_number =
inp->sctp_ep.current_secret_number;
inp->sctp_ep.current_secret_number++;