Module: kamailio
Branch: master
Commit: 368661cc15251af4cbf295d1f5fad5a42d1b647b
URL: https://github.com/kamailio/kamailio/commit/368661cc15251af4cbf295d1f5fad5a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-04-05T08:10:11+02:00
core: parser/sdp - function to find sdp line with start EoL check option
---
Modified: src/core/parser/sdp/sdp_helpr_funcs.c
Modified: src/core/parser/sdp/sdp_helpr_funcs.h
---
Diff: https://github.com/kamailio/kamailio/commit/368661cc15251af4cbf295d1f5fad5a…
Patch: https://github.com/kamailio/kamailio/commit/368661cc15251af4cbf295d1f5fad5a…
---
diff --git a/src/core/parser/sdp/sdp_helpr_funcs.c b/src/core/parser/sdp/sdp_helpr_funcs.c
index d5cb359b40f..a5dffd9c398 100644
--- a/src/core/parser/sdp/sdp_helpr_funcs.c
+++ b/src/core/parser/sdp/sdp_helpr_funcs.c
@@ -733,9 +733,10 @@ int extract_sess_version(str *oline, str *sess_version)
/*
* Auxiliary for some functions.
+ * - smode: if 1, pstart is pointing inside msg body
* Returns pointer to first character of found line, or NULL if no such line.
*/
-char *find_sdp_line(char *pstart, char *plimit, char linechar)
+char *find_sdp_line_start(char *pstart, char *plimit, char linechar, int smode)
{
static char linehead[3] = "x=";
char *cp, *cp1;
@@ -749,11 +750,14 @@ char *find_sdp_line(char *pstart, char *plimit, char linechar)
if(cp1 == NULL)
return NULL;
/*
- * As it is body, we assume it has previous line and we can
- * lookup previous character.
+ * smode==1 means it is msg body, thus it has previous line and it can
+ * lookup previous character even when cp1==pstart.
*/
- if(cp1[-1] == '\n' || cp1[-1] == '\r')
- return cp1;
+ if(cp1 > pstart || smode == 1) {
+ if(cp1[-1] == '\n' || cp1[-1] == '\r') {
+ return cp1;
+ }
+ }
/*
* Having such data, but not at line beginning.
* Skip them and reiterate. ser_memmem() will find next
@@ -765,6 +769,14 @@ char *find_sdp_line(char *pstart, char *plimit, char linechar)
}
}
+/*
+ * Auxiliary for some functions - expect pstart to point inside SIP message body.
+ * Returns pointer to first character of found line, or NULL if no such line.
+ */
+char *find_sdp_line(char *pstart, char *plimit, char linechar)
+{
+ return find_sdp_line_start(pstart, plimit, linechar, 1);
+}
/* This function assumes pstart points to a line of requested type. */
char *find_next_sdp_line(
diff --git a/src/core/parser/sdp/sdp_helpr_funcs.h b/src/core/parser/sdp/sdp_helpr_funcs.h
index e8ce6f7e60a..20d3ebd882d 100644
--- a/src/core/parser/sdp/sdp_helpr_funcs.h
+++ b/src/core/parser/sdp/sdp_helpr_funcs.h
@@ -65,6 +65,7 @@ int extract_accept_wrapped_types(str *body, str *accept_wrapped_types);
int extract_max_size(str *body, str *max_size);
int extract_path(str *body, str *path);
+char *find_sdp_line_start(char *pstart, char *plimit, char linechar, int smode);
char *find_sdp_line(char *p, char *plimit, char linechar);
char *find_next_sdp_line(char *p, char *plimit, char linechar, char *defptr);
#### 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:
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
This patch introduces a new "time" field for JSON logging to stderr. The CEE format already includes this field, but the Kamailio-specific format doesn't. If you need timestamps in your structured logs, but don't want to use the CEE format due to its limitations, this patch'd give you the best of both worlds.
I know this comes a little out of the blue, so any feedback is welcome.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3795
-- Commit Summary --
* core: dprint - include time in stderr json log
-- File Changes --
M src/core/dprint.c (44)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3795.patchhttps://github.com/kamailio/kamailio/pull/3795.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3795
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/3795(a)github.com>