Module: kamailio
Branch: master
Commit: 0f240dbccff6dfbacb45dded7d1db202b7e4ea46
URL:
https://github.com/kamailio/kamailio/commit/0f240dbccff6dfbacb45dded7d1db20…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-11-11T12:19:57+01:00
core: socket - added agname field to bind structure
- action/async group name
---
Modified: src/core/cfg.lex
Modified: src/core/cfg.y
Modified: src/core/ip_addr.h
Modified: src/core/socket_info.c
---
Diff:
https://github.com/kamailio/kamailio/commit/0f240dbccff6dfbacb45dded7d1db20…
Patch:
https://github.com/kamailio/kamailio/commit/0f240dbccff6dfbacb45dded7d1db20…
---
diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index c3e57fe8bf0..a557f62754f 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -310,6 +310,7 @@ LISTEN listen
ADVERTISE advertise|ADVERTISE
VIRTUAL virtual
STRNAME name|NAME
+AGNAME agname|AGNAME
ALIAS alias
DOMAIN domain
SR_AUTO_ALIASES auto_aliases
@@ -770,6 +771,7 @@ IMPORTFILE "import_file"
<INITIAL>{ADVERTISE} { count(); yylval.strval=yytext; return ADVERTISE; }
<INITIAL>{VIRTUAL} { count(); yylval.strval=yytext; return VIRTUAL; }
<INITIAL>{STRNAME} { count(); yylval.strval=yytext; return STRNAME; }
+<INITIAL>{AGNAME} { count(); yylval.strval=yytext; return AGNAME; }
<INITIAL>{ALIAS} { count(); yylval.strval=yytext; return ALIAS; }
<INITIAL>{DOMAIN} { count(); yylval.strval=yytext; return DOMAIN; }
<INITIAL>{SR_AUTO_ALIASES} { count(); yylval.strval=yytext;
diff --git a/src/core/cfg.y b/src/core/cfg.y
index afb07b415dd..1033e61cb19 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -334,6 +334,7 @@ extern char *default_routename;
%token ADVERTISE
%token VIRTUAL
%token STRNAME
+%token AGNAME
%token ALIAS
%token SR_AUTO_ALIASES
%token DOMAIN
@@ -879,6 +880,11 @@ socket_lattr:
tmp_sa.useaddr.len = strlen(tmp_sa.useaddr.s);
tmp_sa.useport = $7;
}
+ | AGNAME EQUAL STRING {
+ tmp_sa.agname.s = $3;
+ tmp_sa.agname.len = strlen(tmp_sa.agname.s);
+ }
+ | AGNAME EQUAL error { yyerror("string value expected"); }
| WORKERS EQUAL NUMBER { tmp_sa.workers=$3; }
| WORKERS EQUAL error { yyerror("number expected"); }
| VIRTUAL EQUAL NUMBER { if($3!=0) { tmp_sa.sflags |= SI_IS_VIRTUAL; } }
diff --git a/src/core/ip_addr.h b/src/core/ip_addr.h
index e475986d1a2..4a266391190 100644
--- a/src/core/ip_addr.h
+++ b/src/core/ip_addr.h
@@ -131,6 +131,14 @@ typedef struct advertise_info
str sock_str; /* Socket proto, ip, and port as string */
} advertise_info_t;
+#define KSR_AGROUP_NAME_SIZE 64
+
+typedef struct action_group
+{
+ char agname[KSR_AGROUP_NAME_SIZE]; /* name of action group */
+ void *agptr;
+} action_group_t;
+
typedef struct socket_info
{
int socket;
@@ -153,6 +161,7 @@ typedef struct socket_info
int workers_tcpidx; /* index of workers in tcp children array */
str sockname; /* socket name given in config listen value */
struct advertise_info useinfo; /* details to be used in SIP msg */
+ action_group_t agroup; /* action group attributes */
#ifdef USE_MCAST
str mcast; /* name of interface that should join multicast group*/
#endif /* USE_MCAST */
@@ -170,6 +179,7 @@ typedef struct socket_attrs
str sockname;
int workers;
int sflags;
+ str agname;
} socket_attrs_t;
/* send flags */
diff --git a/src/core/socket_info.c b/src/core/socket_info.c
index 80f72870e79..35b85d6be7f 100644
--- a/src/core/socket_info.c
+++ b/src/core/socket_info.c
@@ -1274,7 +1274,19 @@ int add_listen_socket(socket_attrs_t *sa)
newsi = add_listen_socket_info(sa->bindaddr.s, &addr_l, sa->bindport,
sa->bindproto, sa->useproto, sa->useaddr.s, sa->useport,
sa->sockname.s, sa->sflags);
- return (newsi != NULL) ? 0 : -1;
+ if(newsi == NULL) {
+ return -1;
+ }
+ if(sa->agname.len > 0) {
+ if(sa->agname.len >= KSR_AGROUP_NAME_SIZE - 1) {
+ LM_ERR("action group too long (%.*s / %d)\n", sa->agname.len,
+ sa->agname.s, sa->agname.len);
+ return -1;
+ }
+ memcpy(newsi->agroup.agname, sa->agname.s, sa->agname.len);
+ newsi->agroup.agname[sa->agname.len] = '\0';
+ }
+ return 0;
}
/* binding on a range of ports */
@@ -1292,6 +1304,15 @@ int add_listen_socket(socket_attrs_t *sa)
if(newsi == NULL) {
return -1;
}
+ if(sa->agname.len > 0) {
+ if(sa->agname.len >= KSR_AGROUP_NAME_SIZE - 1) {
+ LM_ERR("action group too long (%.*s / %d)\n", sa->agname.len,
+ sa->agname.s, sa->agname.len);
+ return -1;
+ }
+ memcpy(newsi->agroup.agname, sa->agname.s, sa->agname.len);
+ newsi->agroup.agname[sa->agname.len] = '\0';
+ }
}
return 0;
}