Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
wsp_headers.h
Go to the documentation of this file.
1 /* ====================================================================
2  * The Kannel Software License, Version 1.0
3  *
4  * Copyright (c) 2001-2016 Kannel Group
5  * Copyright (c) 1998-2001 WapIT Ltd.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Kannel Group (http://www.kannel.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Kannel" and "Kannel Group" must not be used to
28  * endorse or promote products derived from this software without
29  * prior written permission. For written permission, please
30  * contact org@kannel.org.
31  *
32  * 5. Products derived from this software may not be called "Kannel",
33  * nor may "Kannel" appear in their name, without prior written
34  * permission of the Kannel Group.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE KANNEL GROUP OR ITS CONTRIBUTORS
40  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
41  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
42  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
45  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
46  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Kannel Group. For more information on
51  * the Kannel Group, please see <http://www.kannel.org/>.
52  *
53  * Portions of this software are based upon software originally written at
54  * WapIT Ltd., Helsinki, Finland for the Kannel project.
55  */
56 
57 /*
58  * wsp_headers.h - WSP PDU headers implementation header
59  *
60  * Kalle Marjola <rpr@wapit.com>
61  */
62 
63 #ifndef WSP_HEADERS_H
64 #define WSP_HEADERS_H
65 
66 #include "gwlib/gwlib.h"
67 
68 #define WSP_FIELD_VALUE_NUL_STRING 1
69 #define WSP_FIELD_VALUE_ENCODED 2
70 #define WSP_FIELD_VALUE_DATA 3
71 #define WSP_FIELD_VALUE_NONE 4 /* secondary_field_value only */
72 
73 /* The value defined as Quote in 8.4.2.1 */
74 #define WSP_QUOTE 127
75 
76 /* Largest value that will fit in a Short-integer encoding */
77 #define MAX_SHORT_INTEGER 127
78 
79 /* Marker values used in the encoding */
80 #define BASIC_AUTHENTICATION 128
81 #define ABSOLUTE_TIME 128
82 #define RELATIVE_TIME 129
83 #define BYTE_RANGE 128
84 #define SUFFIX_BYTE_RANGE 129
85 
86 /* Use this value for Expires headers if we can't parse the expiration
87  * date. It's about one day after the start of the epoch. We don't
88  * use the exact start of the epoch because some clients have trouble
89  * with that. */
90 #define LONG_AGO_VALUE 100000
91 
92 /* LIST is a comma-separated list such as is described in the "#rule"
93  * entry of RFC2616 section 2.1. */
94 #define LIST 1
95 /* BROKEN_LIST is a list of "challenge" or "credentials" elements
96  * such as described in RFC2617. I call it broken because the
97  * parameters are separated with commas, instead of with semicolons
98  * like everywhere else in HTTP. Parsing is more difficult because
99  * commas are also used to separate list elements. */
100 #define BROKEN_LIST 2
101 
102 #define TABLE_SIZE(table) ((long)(sizeof(table) / sizeof(table[0])))
103 
104 struct parameter
105 {
108 };
109 typedef struct parameter Parameter;
110 
111 typedef int header_pack_func_t(Octstr *packed, Octstr *value);
112 
114 {
115  /* The WSP_HEADER_* enumeration value for this header */
116  int header;
118  /* True if this header type allows multiple elements per
119  * header on the HTTP side. */
121 };
122 
123 /* All WSP packing/unpacking routines that are exported for use within
124  * external modules, ie. MMS encoding/decoding.
125  */
126 int wsp_field_value(ParseContext *context, int *well_known_value);
129 void parm_destroy_item(void *parm);
131 /* unpacking */
133 Octstr *wsp_unpack_version_value(long value);
136 void wsp_unpack_well_known_field(List *unpacked, int field_type,
139 /* packing */
140 void wsp_pack_integer_value(Octstr *packed, unsigned long integer);
141 int wsp_pack_date(Octstr *packet, Octstr *value);
143 int wsp_pack_text(Octstr *packet, Octstr *value);
144 int wsp_pack_quoted_text(Octstr *packed, Octstr *text);
147 int wsp_pack_constrained_value(Octstr *packed, Octstr *text, long value);
148 void wsp_pack_value(Octstr *packed, Octstr *encoded);
149 void wsp_pack_parameters(Octstr *packed, List *parms);
150 int wsp_pack_list(Octstr *packed, long fieldnum, List *elements, int i);
151 void wsp_pack_short_integer(Octstr *packed, unsigned long integer);
152 void wsp_pack_separate_content_type(Octstr *packed, List *headers);
157  Octstr *fieldname, Octstr *value);
158 void wsp_pack_long_integer(Octstr *packed, unsigned long integer);
159 
160 /* Return an HTTPHeader linked list which must be freed by the caller
161  * (see http.h for details of HTTPHeaders). Cannot fail.
162  * The second argument is true if the headers will have a leading
163  * Content-Type field. Some WSP PDUs encode Content-Type separately
164  * this way for historical reasons.
165  */
167 
168 /* Take a List of headers, encode them according to the WSP spec,
169  * and return the encoded headers as an Octstr.
170  * The second argument is true if the encoded headers should have
171  * a leading content-type field. See the note for wsp_headers_unpack. */
172 Octstr *wsp_headers_pack(List *headers, int separate_content_type, int wsp_version);
173 
174 #endif
int wsp_pack_list(Octstr *packed, long fieldnum, List *elements, int i)
Definition: wsp_headers.c:2869
Octstr * key
Definition: wsp_headers.h:106
void parm_destroy_item(void *parm)
Definition: wsp_headers.c:1515
void wsp_unpack_app_header(List *unpacked, ParseContext *context)
Definition: wsp_headers.c:1311
Definition: parse.c:65
void wsp_pack_separate_content_type(Octstr *packed, List *headers)
Definition: wsp_headers.c:2851
int wsp_pack_integer_string(Octstr *packet, Octstr *value)
Definition: wsp_headers.c:1815
void wsp_skip_field_value(ParseContext *context)
Definition: wsp_headers.c:138
void wsp_pack_long_integer(Octstr *packed, unsigned long integer)
Definition: wsp_headers.c:1776
Octstr * value
Definition: wsp_headers.h:107
int wsp_pack_text(Octstr *packet, Octstr *value)
Definition: wsp_headers.c:1615
int allows_list
Definition: wsp_headers.h:120
void wsp_pack_parameters(Octstr *packed, List *parms)
Definition: wsp_headers.c:1973
Octstr * wsp_headers_pack(List *headers, int separate_content_type, int wsp_version)
Definition: wsp_headers.c:2963
void wsp_unpack_all_parameters(ParseContext *context, Octstr *decoded)
Definition: wsp_headers.c:443
int header_pack_func_t(Octstr *packed, Octstr *value)
Definition: wsp_headers.h:111
int wsp_secondary_field_value(ParseContext *context, long *result)
Definition: wsp_headers.c:183
int wsp_pack_quoted_text(Octstr *packed, Octstr *text)
Definition: wsp_headers.c:1627
void wsp_pack_short_integer(Octstr *packed, unsigned long integer)
Definition: wsp_headers.c:1800
int wsp_pack_content_type(Octstr *packet, Octstr *value)
Definition: wsp_headers.c:2626
char * text
Definition: smsc_cimd2.c:921
int wsp_pack_application_header(Octstr *packed, Octstr *fieldname, Octstr *value)
Definition: wsp_headers.c:2938
void wsp_pack_integer_value(Octstr *packed, unsigned long integer)
Definition: wsp_headers.c:1807
List * wsp_headers_unpack(Octstr *headers, int content_type)
Definition: wsp_headers.c:1331
Definition: seewbmp.c:154
List * wsp_strip_parameters(Octstr *value)
Definition: wsp_headers.c:1553
const char * content_type
Definition: fakewap.c:249
int wsp_pack_date(Octstr *packet, Octstr *value)
Definition: wsp_headers.c:2186
void wsp_pack_value(Octstr *packed, Octstr *encoded)
Definition: wsp_headers.c:1761
header_pack_func_t * func
Definition: wsp_headers.h:117
Definition: octstr.c:118
int wsp_pack_version_value(Octstr *packet, Octstr *value)
Definition: wsp_headers.c:1848
Octstr * wsp_unpack_version_value(long value)
Definition: wsp_headers.c:291
int wsp_pack_constrained_value(Octstr *packed, Octstr *text, long value)
Definition: wsp_headers.c:1879
Octstr * wsp_unpack_integer_value(ParseContext *context)
Definition: wsp_headers.c:214
Octstr * wsp_unpack_accept_general_form(ParseContext *context)
Definition: wsp_headers.c:513
int wsp_field_value(ParseContext *context, int *well_known_value)
Definition: wsp_headers.c:107
Definition: list.c:102
Octstr * wsp_unpack_date_value(ParseContext *context)
Definition: wsp_headers.c:492
Octstr * wsp_unpack_accept_charset_general_form(ParseContext *context)
Definition: wsp_headers.c:557
int wsp_pack_retry_after(Octstr *packet, Octstr *value)
Definition: wsp_headers.c:2727
void wsp_unpack_well_known_field(List *unpacked, int field_type, ParseContext *context)
Definition: wsp_headers.c:1030
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.