[Serdev] to tag
Maxim Sobolev
sobomax at FreeBSD.org
Sat Jan 3 19:09:53 UTC 2004
Hi,
Few comments:
1. To header is parsed automagically in all cases just after receiving a
message, so that you can skip parse_headers(_msg, HDR_TO, ...) part.
2. -1 return value means an error, 0 should be returned if you want to
return "false".
3. There is already a function which populates str parameter with To
tag, so that this function can be simplified to:
#include "../../parser/parse_to.h"
int does_to_tag_exist(struct sip_msg* _msg, char* _s1, char* _s2)
{
str to_tag;
if (get_to_tag(_msg, &to_tag) == -1) {
LOG(L_ERR, "ERROR: does_to_tag_exist: can't get To tag\n");
return -1;
}
return (to_tag.len == 0) ? 0 : 1;
}
-Maxim
Juha Heinanen wrote:
> i wrote sometime ago the following simple function to check is request
> has to tag. perhaps it could be included in some module.
>
> -- juha
>
> /* Checks if message has To tag
> */
> int does_to_tag_exist(struct sip_msg* _msg, char* _s1, char* _s2)
> {
> str to_tag;
>
> if ((_msg->to == NULL) || (parse_headers(_msg, HDR_TO, 0) == -1)) {
> LOG(L_ERR, "tag_match(): Error while parsing To header\n");
> return -1;
> }
>
> to_tag = get_to(_msg)->tag_value;
>
> if (to_tag.len == 0) {
> return -1;
> } else {
> return 1;
> }
> }
>
> _______________________________________________
> Serdev mailing list
> serdev at lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serdev
>
>
>
More information about the Serdev
mailing list