Skip to content

Commit

Permalink
sipsess/listen: improve glare handling (#1071)
Browse files Browse the repository at this point in the history
This implements the UAS behavior exactly as RFC 3261 section 14.2 states
that it MUST be.
  • Loading branch information
maximilianfridrich authored Feb 27, 2024
1 parent a35d110 commit 7d1467c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/sipsess/listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <re_msg.h>
#include <re_sip.h>
#include <re_sipsess.h>
#include <re_sys.h>
#include "sipsess.h"


Expand Down Expand Up @@ -250,11 +251,18 @@ static void target_refresh_handler(struct sipsess_sock *sock,

if ((is_invite && sess->st)
|| (sdp && sess->neg_state == SDP_NEG_LOCAL_OFFER)) {
(void)sip_treplyf(NULL, NULL, sip, msg, false,
500, "Server Internal Error",
"Retry-After: 5\r\n"
"Content-Length: 0\r\n"
"\r\n");
if (!sess->established) {
uint32_t wait = rand_u16() % 11;
(void)sip_treplyf(NULL, NULL, sip, msg, false,
500, "Server Internal Error",
"Retry-After: %u\r\n"
"Content-Length: 0\r\n"
"\r\n", wait);
}
else {
(void)sip_treply(NULL, sip, msg, 491,
"Request Pending");
}
return;
}

Expand Down

0 comments on commit 7d1467c

Please sign in to comment.