Module: kamailio
Branch: master
Commit: 7162dc0a7368f61e3b32231a2ad00e72ee29d82e
URL: https://github.com/kamailio/kamailio/commit/7162dc0a7368f61e3b32231a2ad00e7…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-01-12T17:02:11+01:00
ctl: float/double values are stored over a long long int instead of int
- cope with larger values than MAX_INT/1000, supporint now
up to MAX_LLONG/1000
---
Modified: src/modules/ctl/binrpc.h
---
Diff: https://github.com/kamailio/kamailio/commit/7162dc0a7368f61e3b32231a2ad00e7…
Patch: https://github.com/kamailio/kamailio/commit/7162dc0a7368f61e3b32231a2ad00e7…
---
diff --git a/src/modules/ctl/binrpc.h b/src/modules/ctl/binrpc.h
index cb7204fffd..bb34cd3be5 100644
--- a/src/modules/ctl/binrpc.h
+++ b/src/modules/ctl/binrpc.h
@@ -205,6 +205,31 @@ inline static int binrpc_add_tag(struct binrpc_pkt* pkt, int type, int end)
+/* writes a minimal long long, returns the new offset and sets
+ * len to the number of bytes written (<=8)
+ * to check for oveflow use: returned_value-p != *len
+ * (Note: if *len==0 using the test above succeeds even if p>=end)
+ */
+inline static unsigned char* binrpc_write_llong( unsigned char* p,
+ unsigned char* end,
+ long long i, int *len)
+{
+ int size;
+ unsigned long long u;
+
+ u = (unsigned long long)i;
+
+ for (size=8; size && ((u & (0xffull<<56))==0); u<<=8, size--);
+ *len=size;
+ for(; (p<end) && (size); p++, size--){
+ *p=(unsigned char)(u>>56);
+ u<<=8;
+ }
+ return p;
+}
+
+
+
/* writes a minimal int, returns the new offset and sets
* len to the number of bytes written (<=4)
* to check for oveflow use: returned_value-p != *len
@@ -330,6 +355,23 @@ inline static int binrpc_hdr_change_len(unsigned char* hdr, int hdr_len,
}
+/* int format: size TYPE <val> */
+inline static int binrpc_add_llong_type(struct binrpc_pkt* pkt, long long i, int type)
+{
+
+ unsigned char* p;
+ int size;
+
+ p=binrpc_write_llong(pkt->crt+1, pkt->end, i, &size);
+ if ((pkt->crt>=pkt->end) || ((int)(p-pkt->crt-1)!=size))
+ goto error_len;
+ *(pkt->crt)=(size<<4) | type;
+ pkt->crt=p;
+ return 0;
+error_len:
+ return E_BINRPC_OVERFLOW;
+}
+
/* int format: size BINRPC_T_INT <val> */
inline static int binrpc_add_int_type(struct binrpc_pkt* pkt, int i, int type)
@@ -351,9 +393,9 @@ inline static int binrpc_add_int_type(struct binrpc_pkt* pkt, int i, int type)
/* double format: FIXME: for now a hack: fixed point represented in
- * an int (=> max 3 decimals, < MAX_INT/1000) */
+ * a long long (=> max 3 decimals, < MAX_LLONG/1000) */
#define binrpc_add_double_type(pkt, f, type)\
- binrpc_add_int_type((pkt), (int)((f)*1000), (type))
+ binrpc_add_llong_type((pkt), (long long)((f)*1000), (type))
@@ -516,6 +558,35 @@ static inline int binrpc_addfault( struct binrpc_pkt* pkt,
/* parsing incoming messages */
+static inline unsigned char* binrpc_read_llong( long long* i,
+ int len,
+ unsigned char* s,
+ unsigned char* end,
+ int *err
+ )
+{
+ unsigned char* start;
+ unsigned long long u;
+
+ start=s;
+ *i=0;
+ u = 0;
+ *err=0;
+ for(;len>0; len--, s++){
+ if (s>=end){
+ *err=E_BINRPC_MORE_DATA;
+ *i = (long long)u;
+ return start;
+ }
+ u<<=8;
+ u|=*s;
+ };
+ *i = (long long)u;
+ return s;
+}
+
+
+
static inline unsigned char* binrpc_read_int( int* i,
int len,
unsigned char* s,
@@ -638,8 +709,8 @@ inline static unsigned char* binrpc_read_record(struct binrpc_parse_ctx* ctx,
int end_tag;
int tmp;
unsigned char* p;
- int i;
-
+ long long ll;
+
p=buf;
end_tag=0;
*err=0;
@@ -758,10 +829,10 @@ inline static unsigned char* binrpc_read_record(struct binrpc_parse_ctx* ctx,
}
break;
case BINRPC_T_DOUBLE: /* FIXME: hack: represented as fixed point
- inside an int */
+ inside an long long */
if (ctx->in_struct && smode==0) goto error_record;
- p=binrpc_read_int(&i, len, p, end, err);
- v->u.fval=((double)i)/1000;
+ p=binrpc_read_llong(&ll, len, p, end, err);
+ v->u.fval=((double)ll)/1000;
break;
default:
if (ctx->in_struct){
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x ] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [x] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
- It is allowed to use '@' within a username and/or a password for MySQL.
Database as a Service providers like e.g. Microsoft Azure use
these in usernames by default.
The existing URI parser always treated the '@' as a separator between
username:password and host:port/db parts of the URI.
The parser now checks how many '@' characters are present in the URI
and only treats the last occurence as separator for the host:port/db
part.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1346
-- Commit Summary --
* module_db_mysql: Allow '@' in username/password for db_url URIs
-- File Changes --
M src/modules/db_mysql/my_uri.c (35)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1346.patchhttps://github.com/kamailio/kamailio/pull/1346.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1346
Hi All,
I’m trying to update the cookbook to document PR #2985, but it looks like I need edit access on the wiki? My username is “rhys”. Can someone give me access?
Thanks!
Rhys Hanrahan | Chief Information Officer
e: rhys(a)nexusone.com.au<mailto:rhys@nexusone.com.au>
[www.nexusone.com.au]<http://www.nexusone.com.au/> [signature_214001646] <http://www.fusiontech.com.au/>
NEXUS ONE | FUSION TECHNOLOGY SOLUTIONS
p: 1800 NEXUS1 (1800 639 871) or 1800 565 845 | a: Suite 12.03 Level 12, 227 Elizabeth Street, Sydney NSW 2000
www.nexusone.com.au<http://www.nexusone.com.au/> | www.fusiontech.com.au<http://www.fusiontech.com.au/>
The information in this email and any accompanying attachments may contain; a. Confidential information of Fusion Technology Solutions Pty Ltd, Nexus One Pty Ltd or third parties; b. Legally privileged information of Fusion Technology Solutions Pty Ltd, Nexus One Pty Ltd or third parties; and or c. Copyright material Fusion Technology Solutions Pty Ltd, Nexus One Pty Ltd or third parties. If you have received this email in error, please notify the sender immediately and delete this message. Fusion Technology Solutions Pty Ltd, Nexus One Pty Ltd does not accept any responsibility for loss or damage arising from the use or distribution of this email.
Please consider the environment before printing this email.
<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for bug reports.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment).
-->
### Description
gethostname not accurate in kubernetes
<!--
Explain what you did, what you expected to happen, and what actually happened.
-->
### Troubleshooting
#### Reproduction
<!--
If the issue can be reproduced, describe how it can be done.
-->
on a recent test with kamailio in kubernetes, found that gethostname can return only the hostname and not the fqdn. this depends on the kind of object is used (deployment/statefulset)
### Possible Solutions
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix.
-->
the below patch fixed the issues i was having
```
diff --git a/src/modules/ipops/ipops_pv.c b/src/modules/ipops/ipops_pv.c
index 5f77aa9..f65b4dd 100644
--- a/src/modules/ipops/ipops_pv.c
+++ b/src/modules/ipops/ipops_pv.c
@@ -455,6 +455,11 @@
if (gethostname(hbuf, 512)<0) {
LM_WARN("gethostname failed - host pvs will be null\n");
return -1;
+ } else {
+ struct hostent* h;
+ if((h = gethostbyname(hbuf)) != NULL) {
+ memcpy(hbuf, h->h_name, 512);
+ }
}
hlen = strlen(hbuf);
```
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
latest master
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->
```
buster & centos7
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2119