summaryrefslogtreecommitdiff
path: root/channels/sip/include/sip_utils.h
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2010-02-03 20:33:32 +0000
committerDavid Vossel <dvossel@digium.com>2010-02-03 20:33:32 +0000
commita9932363a9560dee6b5733a33d789f4ef867d8a5 (patch)
tree7c78ac93e563d00213cd2074738d8748dfce3193 /channels/sip/include/sip_utils.h
parentdbc3111652a35753225f2713352f5cb6f98a521e (diff)
-----Changes -----
New files - channels/sip/sip.h – A new header for shared #define, enum, and struct definitions. - channels/sip/include/sip_utils.h – sip util functions shared among the all the sip APIs - channels/sip/include/config_parser.h – sip config-parser API - channels/sip/config_parser.c – Contains sip.conf parsing helper functions with unit tests. - channels/sip/include/reqresp_parser.h – sip request response parser API - channels/sip/reqresp_parser.c – Contains sip request and response parsing helper functions with unit tests. New Unit Tests - sip_parse_uri_test - sip_parse_host_test - sip_parse_register_line_test Code Refactoring - All reusable #define, enum, and struct definitions were moved out of chan_sip.c into sip.h. During this process formatting changes were made to comments in both sip.h and chan_sip.c in order to better adhere to the coding guidelines. - The beginnings of three new sip APIs, sip-utils.h, config-parser.h, reqresp-parser.h using existing chan_sip.c functions. - parse_uri() and get_calleridname() were moved from chan_sip.c to request-parser.c along with unit tests for both functions. - sip_parse_host() and sip_parse_register_line() were moved from chan_sip.c to config-parser.c along with unit tests for both functions. Changes to parse_uri() -removal of the options parameter. It was never used and did not behave correctly. -additional check for [?header] field. When this field was present, the transport type was not being set correctly. ----- Overview ----- This patch is introduced with the hope that unit tests for all our sip parsing functions will be written soon. chan_sip is a huge file, and with the addition of each unit test chan_sip is going to grow larger and harder to maintain. I'm proposing we begin refactoring chan_sip, starting with the parsing functions. With each parsing function we move into a separate helper file, a unit test should accompany it. I've attempted to lay down the ground work for this change by creating two new parser helper files (config-parser.c and reqresp-parser.c) and moving all shared structs, enums, and defines from chan_sip.c into a shared sip.h file. We can't verify everything in Asterisk using unit tests, but string parsing is one area where unit tests make the most sense. By beginning to restructure the code in this way, chan_sip not only becomes less bloated, but Asterisk as a whole will become more stable. Review: https://reviewboard.asterisk.org/r/477/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@244597 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/sip/include/sip_utils.h')
-rw-r--r--channels/sip/include/sip_utils.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/channels/sip/include/sip_utils.h b/channels/sip/include/sip_utils.h
new file mode 100644
index 000000000..3a91564d1
--- /dev/null
+++ b/channels/sip/include/sip_utils.h
@@ -0,0 +1,34 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief sip utils header file
+ */
+
+#ifndef _SIP_UTILS_H
+#define _SIP_UTILS_H
+
+
+/*! \brief converts ascii port to int representation. If no
+ * pt buffer is provided or the pt has errors when being converted
+ * to an int value, the port provided as the standard is used.
+ *
+ * \retval positive numeric port
+ */
+unsigned int port_str2int(const char *pt, unsigned int standard);
+
+#endif