Module: kamailio
Branch: master
Commit: 56ea88ef9a0628d7ca644f31840101ffe573e5c3
URL:
https://github.com/kamailio/kamailio/commit/56ea88ef9a0628d7ca644f31840101f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-05-16T12:49:17+02:00
outbound: pass recv info struct by address
- fix performance inefficiency for passing large structs by value
---
Modified: src/modules/outbound/api.h
Modified: src/modules/outbound/outbound_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/56ea88ef9a0628d7ca644f31840101f…
Patch:
https://github.com/kamailio/kamailio/commit/56ea88ef9a0628d7ca644f31840101f…
---
diff --git a/src/modules/outbound/api.h b/src/modules/outbound/api.h
index 6e65e44e17..ae2b3b3615 100644
--- a/src/modules/outbound/api.h
+++ b/src/modules/outbound/api.h
@@ -30,7 +30,7 @@
#include "../../core/str.h"
#include "../../core/sr_module.h"
-typedef int (*encode_flow_token_t)(str *, struct receive_info);
+typedef int (*encode_flow_token_t)(str *, struct receive_info *);
typedef int (*decode_flow_token_t)(struct sip_msg *, struct receive_info **, str);
typedef int (*use_outbound_t)(struct sip_msg *);
diff --git a/src/modules/outbound/outbound_mod.c b/src/modules/outbound/outbound_mod.c
index 788376541c..82d18a3eca 100644
--- a/src/modules/outbound/outbound_mod.c
+++ b/src/modules/outbound/outbound_mod.c
@@ -156,7 +156,7 @@ static void destroy(void)
static unsigned char unenc_flow_token[UNENC_FLOW_TOKEN_MAX_LENGTH];
static unsigned char hmac_sha1[EVP_MAX_MD_SIZE];
-int encode_flow_token(str *flow_token, struct receive_info rcv)
+int encode_flow_token(str *flow_token, struct receive_info *rcv)
{
int pos = FLOW_TOKEN_START_POS, i;
@@ -168,19 +168,19 @@ int encode_flow_token(str *flow_token, struct receive_info rcv)
/* Encode protocol information */
unenc_flow_token[pos++] =
- (rcv.dst_ip.af == AF_INET6 ? 0x80 : 0x00) | rcv.proto;
+ (rcv->dst_ip.af == AF_INET6 ? 0x80 : 0x00) | rcv->proto;
/* Encode destination address */
- for (i = 0; i < (rcv.dst_ip.af == AF_INET6 ? 16 : 4); i++)
- unenc_flow_token[pos++] = rcv.dst_ip.u.addr[i];
- unenc_flow_token[pos++] = (rcv.dst_port >> 8) & 0xff;
- unenc_flow_token[pos++] = rcv.dst_port & 0xff;
+ for (i = 0; i < (rcv->dst_ip.af == AF_INET6 ? 16 : 4); i++)
+ unenc_flow_token[pos++] = rcv->dst_ip.u.addr[i];
+ unenc_flow_token[pos++] = (rcv->dst_port >> 8) & 0xff;
+ unenc_flow_token[pos++] = rcv->dst_port & 0xff;
/* Encode source address */
- for (i = 0; i < (rcv.src_ip.af == AF_INET6 ? 16 : 4); i++)
- unenc_flow_token[pos++] = rcv.src_ip.u.addr[i];
- unenc_flow_token[pos++] = (rcv.src_port >> 8) & 0xff;
- unenc_flow_token[pos++] = rcv.src_port & 0xff;
+ for (i = 0; i < (rcv->src_ip.af == AF_INET6 ? 16 : 4); i++)
+ unenc_flow_token[pos++] = rcv->src_ip.u.addr[i];
+ unenc_flow_token[pos++] = (rcv->src_port >> 8) & 0xff;
+ unenc_flow_token[pos++] = rcv->src_port & 0xff;
/* HMAC-SHA1 the calculated flow-token, truncate to 80 bits, and
prepend onto the flow-token */