/src/opensips/parser/parse_supported.h
Line | Count | Source |
1 | | /* |
2 | | * Supported parser. |
3 | | * |
4 | | * Copyright (C) 2006 Andreas Granig <agranig@linguin.org> |
5 | | * |
6 | | * This file is part of opensips, a free SIP server. |
7 | | * |
8 | | * opensips is free software; you can redistribute it and/or modify |
9 | | * it under the terms of the GNU General Public License as published by |
10 | | * the Free Software Foundation; either version 2 of the License, or |
11 | | * (at your option) any later version |
12 | | * |
13 | | * opensips is distributed in the hope that it will be useful, |
14 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | | * GNU General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU General Public License |
19 | | * along with this program; if not, write to the Free Software |
20 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | | * |
22 | | * |
23 | | * History: |
24 | | * ------- |
25 | | * 2006-03-02 parse_supported() parses and cumulates all SUPPORTED |
26 | | * headers (bogdan) |
27 | | */ |
28 | | |
29 | | #ifndef PARSE_SUPPORTED_H |
30 | | #define PARSE_SUPPORTED_H |
31 | | |
32 | | #include "msg_parser.h" |
33 | | #include "../mem/mem.h" |
34 | | |
35 | | |
36 | | #define F_SUPPORTED_PATH (1 << 0) |
37 | | #define F_SUPPORTED_100REL (1 << 1) |
38 | | #define F_SUPPORTED_TIMER (1 << 2) |
39 | | #define F_SUPPORTED_EVENTLIST (1 << 3) |
40 | | #define F_SUPPORTED_GRUU (1 << 4) |
41 | | |
42 | | #define SUPPORTED_PATH_STR "path" |
43 | | #define SUPPORTED_PATH_LEN (sizeof(SUPPORTED_PATH_STR)-1) |
44 | | |
45 | | /* RFC 3262 */ |
46 | | #define SUPPORTED_100REL_STR "100rel" |
47 | | #define SUPPORTED_100REL_LEN (sizeof(SUPPORTED_100REL_STR)-1) |
48 | | |
49 | | /* RFC 4028 */ |
50 | | #define SUPPORTED_TIMER_STR "timer" |
51 | | #define SUPPORTED_TIMER_LEN (sizeof(SUPPORTED_TIMER_STR)-1) |
52 | | |
53 | | /* RFC 4662 - RLS */ |
54 | | #define SUPPORTED_EVENTLIST_STR "eventlist" |
55 | | #define SUPPORTED_EVENTLIST_LEN (sizeof(SUPPORTED_EVENTLIST_STR)-1) |
56 | | |
57 | | |
58 | | #define get_supported(p_msg) \ |
59 | | ((p_msg)->supported ? ((struct supported_body*)(p_msg)->supported->parsed)->supported_all : 0) |
60 | | |
61 | | |
62 | | struct supported_body { |
63 | | unsigned int supported; /* supported mask for the current hdr */ |
64 | | unsigned int supported_all; /* supported mask for the all "supported" hdr |
65 | | * - it's set only for the first hdr in |
66 | | * sibling list*/ |
67 | | }; |
68 | | |
69 | | |
70 | | /* |
71 | | * Parse all Supported headers. |
72 | | */ |
73 | | int parse_supported( struct sip_msg *msg); |
74 | | int parse_supported_body(str *body, unsigned int *sup); |
75 | | |
76 | | |
77 | | static inline void free_supported(struct supported_body **sb) |
78 | 0 | { |
79 | 0 | if (sb && *sb) { |
80 | 0 | pkg_free(*sb); |
81 | 0 | *sb = 0; |
82 | 0 | } |
83 | 0 | } |
84 | | |
85 | | #endif /* PARSE_SUPPORTED_H */ |