HTP  0.3
htp_urlencoded.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  * Copyright 2009-2010 Open Information Security Foundation
00003  * Copyright 2010-2011 Qualys, Inc.
00004  *
00005  * Licensed to You under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  ***************************************************************************/
00017 
00023 #ifndef _HTP_URLENCODED_H
00024 #define _HTP_URLENCODED_H
00025 
00026 typedef struct htp_urlenp_t htp_urlenp_t;
00027 typedef struct htp_urlen_param_t htp_urlen_param_t;
00028 
00029 #include "htp.h"
00030 
00031 #define HTP_URLENP_DEFAULT_PARAMS_SIZE  32
00032 
00033 #define HTP_URLENP_STATE_KEY            1
00034 #define HTP_URLENP_STATE_VALUE          2
00035 
00036 #define HTP_URLENCODED_MIME_TYPE        "application/x-www-form-urlencoded"
00037 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00046 struct htp_urlenp_t {
00048     htp_tx_t *tx;
00049     
00053     unsigned char argument_separator;
00054 
00056     int decode_url_encoding;        
00057 
00059     table_t *params;
00060 
00061     // Private fields; these are used during the parsing process only
00062     int _state;
00063     int _complete;
00064     bstr *_name;
00065     bstr_builder_t *_bb;
00066 };
00067 
00071 struct htp_urlen_param_t {
00073     bstr *name;
00074     
00076     bstr *value;
00077 };
00078 
00079 htp_urlenp_t *htp_urlenp_create(htp_tx_t *tx);
00080 void htp_urlenp_destroy(htp_urlenp_t **urlenp);
00081 
00082 void htp_urlenp_set_argument_separator(htp_urlenp_t *urlenp, unsigned char argument_separator);         
00083 void htp_urlenp_set_decode_url_encoding(htp_urlenp_t *urlenp, int decode_url_encoding);
00084          
00085 int  htp_urlenp_parse_partial(htp_urlenp_t *urlenp, unsigned char *data, size_t len);
00086 int  htp_urlenp_parse_complete(htp_urlenp_t *urlenp, unsigned char *data, size_t len);
00087 int  htp_urlenp_finalize(htp_urlenp_t *urlenp);
00088 
00089  int htp_ch_urlencoded_callback_request_line(htp_connp_t *connp);
00090  int htp_ch_urlencoded_callback_request_headers(htp_connp_t *connp);
00091 
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095 
00096 #endif  /* _HTP_URLENCODED_H */
00097