Skip to content

Commit

Permalink
Merge branch 'carstenbock-presence_add_reginfo'
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan-iancu committed Apr 18, 2024
2 parents b7f471f + fbf5e0b commit ecb9543
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/presence/utils_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int a_to_i (char *s,int len)

int send_error_reply(struct sip_msg* msg, int reply_code, str reply_str)
{
if(reply_code== BAD_EVENT_CODE)
if(reply_code== BAD_EVENT_CODE && EvList != NULL)
{
str hdr_append;
char buffer[256];
Expand Down
24 changes: 16 additions & 8 deletions modules/presence/utils_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static inline int uandd_to_uri(str user, str domain, str *out)
{
int size;

if(out==0)
if(out==0 || (user.len+domain.len==0))
return -1;

size = user.len + domain.len+7;
Expand All @@ -53,19 +53,27 @@ static inline int uandd_to_uri(str user, str domain, str *out)
LM_ERR("no more memory\n");
return -1;
}
strcpy(out->s,"sip:");
out->len = 4;
if( user.len != 0)
{

if (domain.len != 0) {
strcpy(out->s,"sip:");
out->len = 4;
if( user.len != 0) {
memcpy(out->s+out->len, user.s, user.len);
out->len += user.len;
out->s[out->len++] = '@';
}
memcpy(out->s + out->len, domain.s, domain.len);
out->len += domain.len;
} else {
strcpy(out->s,"tel:");
out->len = 4;
memcpy(out->s+out->len, user.s, user.len);
out->len += user.len;
out->s[out->len++] = '@';
}

memcpy(out->s + out->len, domain.s, domain.len);
out->len += domain.len;
out->s[out->len] = '\0';


return 0;
}

Expand Down
6 changes: 6 additions & 0 deletions parser/parse_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
#define REFER_STR "refer"
#define REFER_STR_LEN 5

#define REG_STR "reg"
#define REG_STR_LEN 3


static inline char* skip_token(char* _b, int _l)
{
Expand Down Expand Up @@ -144,6 +147,9 @@ int event_parser(char* _s, int _l, event_t* _e)
} else if ((_e->text.len == REFER_STR_LEN) &&
!strncasecmp(REFER_STR, tmp.s, _e->text.len)) {
_e->parsed = EVENT_REFER;
} else if ((_e->text.len == REG_STR_LEN) &&
!strncasecmp(REG_STR, tmp.s, _e->text.len)) {
_e->parsed = EVENT_REG;
} else {
_e->parsed = EVENT_OTHER;
}
Expand Down
1 change: 1 addition & 0 deletions parser/parse_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#define EVENT_LINE_SEIZE 9
#define EVENT_AS_FEATURE 10
#define EVENT_REFER 11
#define EVENT_REG 12

typedef struct event {
str text; /* Original string representation */
Expand Down

0 comments on commit ecb9543

Please sign in to comment.