Module: kamailio Branch: master Commit: 753a60bf538985a54f8b9eafb98b7ce86b616a63 URL: https://github.com/kamailio/kamailio/commit/753a60bf538985a54f8b9eafb98b7ce8...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2023-09-01T21:08:07+02:00
core: parser for overflow control parameters in via header
- RFC7339
---
Modified: src/core/parser/parse_via.c Modified: src/core/parser/parse_via.h
---
Diff: https://github.com/kamailio/kamailio/commit/753a60bf538985a54f8b9eafb98b7ce8... Patch: https://github.com/kamailio/kamailio/commit/753a60bf538985a54f8b9eafb98b7ce8...
---
diff --git a/src/core/parser/parse_via.c b/src/core/parser/parse_via.c index 9452ce51132..921911f1d17 100644 --- a/src/core/parser/parse_via.c +++ b/src/core/parser/parse_via.c @@ -2817,3 +2817,40 @@ int parse_via_header(struct sip_msg *msg, int n, struct via_body **q) } else return -1; } + + +/* + * Parse/link Via overload-control parameters + */ +int parse_via_oc(struct sip_msg *msg, struct via_body *vbp, via_oc_t *ocp) +{ + via_param_t *vp; + + if(vbp == NULL || ocp == NULL) { + return -1; + } + memset(ocp, 0, sizeof(via_oc_t)); + + for(vp = vbp->param_lst; vp != NULL; vp = vp->next) { + if(vp->name.len == 2 && strncasecmp(vp->name.s, "oc", 2) == 0) { + ocp->oc = 1; + } else if(vp->name.len == 7 + && strncasecmp(vp->name.s, "oc-algo", 7) == 0) { + if(vp->value.len > 0) { + ocp->algo.len = vp->value.len; + ocp->algo.s = vp->value.s; + } + } else if(vp->name.len == 11 + && strncasecmp(vp->name.s, "oc-validity", 11) == 0) { + if(vp->value.len > 0) { + str2ulong(&vp->value, &ocp->validity); + } + } else if(vp->name.len == 6 + && strncasecmp(vp->name.s, "oc-seq", 6) == 0) { + if(vp->value.len > 0) { + str2int(&vp->value, &ocp->seq); + } + } + } + return 0; +} diff --git a/src/core/parser/parse_via.h b/src/core/parser/parse_via.h index 4cd17ca3e19..bd0a4ffbb14 100644 --- a/src/core/parser/parse_via.h +++ b/src/core/parser/parse_via.h @@ -66,6 +66,15 @@ typedef struct via_param } via_param_t;
+/* RFC7339 - overload control */ +typedef struct via_oc +{ + int oc; + str algo; + unsigned long validity; + unsigned int seq; +} via_oc_t; + /* Format: name/version/transport host:port;params comment */ /* WARNING: keep in sync with tm/sip_msg.c via_body_cloner */ typedef struct via_body @@ -123,5 +132,9 @@ void free_via_list(struct via_body *vb); */ int parse_via_header(struct sip_msg *msg, int n, struct via_body **q);
+/* + * Parse/link Via overload-control parameters + */ +int parse_via_oc(struct sip_msg *msg, struct via_body *vbp, via_oc_t *ocp);
#endif /* PARSE_VIA_H */