diff options
author | Benny Prijono <bennylp@teluu.com> | 2006-10-08 13:56:07 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2006-10-08 13:56:07 +0000 |
commit | 50a7a792f0de6a09525fdfedfbca05038344c873 (patch) | |
tree | 5b2f493f670490ce0979fcf2b472fec4cedeb4a6 | |
parent | 36413704c1ff24a8e38e0fcf47c9a9c87621e71a (diff) |
Added pjlib-util/config.h and pjlib-util/types.h to put
together common settings, and updated Doxygen documentation
for PJLIB-UTIL.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@754 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r-- | pjlib-util/build/pjlib_util.dsp | 29 | ||||
-rw-r--r-- | pjlib-util/docs/doxygen.cfg | 4 | ||||
-rw-r--r-- | pjlib-util/docs/footer.html | 11 | ||||
-rw-r--r-- | pjlib-util/docs/header.html | 9 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util.h | 14 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/config.h | 208 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/dns.h | 29 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/errno.h | 9 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/getopt.h | 15 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/md5.h | 18 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/resolver.h | 128 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/scanner.h | 21 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/string.h | 11 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/stun.h | 77 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/types.h | 63 | ||||
-rw-r--r-- | pjlib-util/include/pjlib-util/xml.h | 4 | ||||
-rw-r--r-- | pjlib-util/src/pjlib-util/dns.c | 2 | ||||
-rw-r--r-- | pjlib-util/src/pjlib-util/resolver.c | 2 |
18 files changed, 462 insertions, 192 deletions
diff --git a/pjlib-util/build/pjlib_util.dsp b/pjlib-util/build/pjlib_util.dsp index a8722e69..3941a623 100644 --- a/pjlib-util/build/pjlib_util.dsp +++ b/pjlib-util/build/pjlib_util.dsp @@ -88,24 +88,10 @@ LIB32=link.exe -lib # Begin Source File
SOURCE="..\src\pjlib-util\dns.c"
-
-!IF "$(CFG)" == "pjlib_util - Win32 Release"
-
-!ELSEIF "$(CFG)" == "pjlib_util - Win32 Debug"
-
-!ENDIF
-
# End Source File
# Begin Source File
SOURCE="..\src\pjlib-util\dns_dump.c"
-
-!IF "$(CFG)" == "pjlib_util - Win32 Release"
-
-!ELSEIF "$(CFG)" == "pjlib_util - Win32 Debug"
-
-!ENDIF
-
# End Source File
# Begin Source File
@@ -122,13 +108,6 @@ SOURCE="..\src\pjlib-util\md5.c" # Begin Source File
SOURCE="..\src\pjlib-util\resolver.c"
-
-!IF "$(CFG)" == "pjlib_util - Win32 Release"
-
-!ELSEIF "$(CFG)" == "pjlib_util - Win32 Debug"
-
-!ENDIF
-
# End Source File
# Begin Source File
@@ -170,6 +149,10 @@ SOURCE="..\src\pjlib-util\xml.c" # PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
+SOURCE="..\include\pjlib-util\config.h"
+# End Source File
+# Begin Source File
+
SOURCE="..\include\pjlib-util\dns.h"
# End Source File
# Begin Source File
@@ -214,6 +197,10 @@ SOURCE="..\include\pjlib-util\stun.h" # End Source File
# Begin Source File
+SOURCE="..\include\pjlib-util\types.h"
+# End Source File
+# Begin Source File
+
SOURCE="..\include\pjlib-util\xml.h"
# End Source File
# End Group
diff --git a/pjlib-util/docs/doxygen.cfg b/pjlib-util/docs/doxygen.cfg index 6a55f3bc..23cd696e 100644 --- a/pjlib-util/docs/doxygen.cfg +++ b/pjlib-util/docs/doxygen.cfg @@ -17,7 +17,7 @@ # The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
-PROJECT_NAME = PJLIB-UTIL
+PROJECT_NAME = "PJLIB-UTIL Reference"
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
@@ -494,7 +494,7 @@ HTML_OUTPUT = html # each generated HTML page (for example: .htm,.php,.asp). If it is left blank
# doxygen will generate files with .html extension.
-HTML_FILE_EXTENSION = .html
+HTML_FILE_EXTENSION = .htm
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
diff --git a/pjlib-util/docs/footer.html b/pjlib-util/docs/footer.html index 96451a47..636d39c6 100644 --- a/pjlib-util/docs/footer.html +++ b/pjlib-util/docs/footer.html @@ -1,4 +1,11 @@ -</TD></TR>
-</TABLE>
+<p> </p>
+<hr><center>
+PJLIB-UTIL Open Source, small footprint, and portable asynchronous/caching DNS resolver, text scanner, STUN client, and XML library<br>
+(C)2001-2006 Benny Prijono
+</center>
+
+
+<!--#include virtual="/footer.html" -->
+
</BODY>
</HTML>
diff --git a/pjlib-util/docs/header.html b/pjlib-util/docs/header.html index 75451330..5517dc34 100644 --- a/pjlib-util/docs/header.html +++ b/pjlib-util/docs/header.html @@ -1,10 +1,9 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
-<title>PJLIB Documentation</title>
-<link href="doxygen.css" rel="stylesheet" type="text/css">
+<title>$title</title>
+<link href="/style/style.css" rel="stylesheet" type="text/css">
</head><body>
-<A HREF="/"><-- HOME</A><HR>
+ <!--#include virtual="/header.html" -->
+ <p><A HREF="/">Home</A> --> <A HREF="/docs.htm">Documentations</A> --> PJLIB Reference</p>
-<TABLE border="0">
- <TR><TD width="600" align="left">
diff --git a/pjlib-util/include/pjlib-util.h b/pjlib-util/include/pjlib-util.h index 3ac8c50b..e5f72ab7 100644 --- a/pjlib-util/include/pjlib-util.h +++ b/pjlib-util/include/pjlib-util.h @@ -19,6 +19,11 @@ #ifndef __PJLIB_UTIL_H__ #define __PJLIB_UTIL_H__ +/** + * @file pjlib-util.h + * @brief pjlib-util.h + */ + #include <pjlib-util/dns.h> #include <pjlib-util/errno.h> #include <pjlib-util/getopt.h> @@ -29,6 +34,11 @@ #include <pjlib-util/xml.h> +/** + * @addtogroup PJLIB_UTIL + * @{ + */ + PJ_BEGIN_DECL /** @@ -39,6 +49,10 @@ PJ_BEGIN_DECL PJ_DECL(pj_status_t) pjlib_util_init(void); +/** + * @} + */ + PJ_END_DECL diff --git a/pjlib-util/include/pjlib-util/config.h b/pjlib-util/include/pjlib-util/config.h new file mode 100644 index 00000000..f49b5eec --- /dev/null +++ b/pjlib-util/include/pjlib-util/config.h @@ -0,0 +1,208 @@ +/* $Id$ */ +/* + * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJLIB_UTIL_CONFIG_H__ +#define __PJLIB_UTIL_CONFIG_H__ + + +/** + * @file config.h + * @brief Compile time settings + */ + +/** + * @defgroup PJLIB_UTIL_CONFIG PJLIB-UTIL Configuration + * @ingroup PJLIB_UTIL + * @{ + */ + + +/* ************************************************************************** + * DNS CONFIGURATION + */ + +/** + * This constant specifies the maximum names to keep in the temporary name + * table when performing name compression scheme when duplicating DNS packet + * (the #pj_dns_packet_dup() function). + * + * Generally name compression is desired, since it saves some memory (see + * PJ_DNS_RESOLVER_RES_BUF_SIZE setting). However it comes at the expense of + * a little processing overhead to perform name scanning and also a little + * bit more stack usage (8 bytes per entry on 32bit platform). + * + * Default: 16 + */ +#ifndef PJ_DNS_MAX_NAMES_IN_NAMETABLE +# define PJ_DNS_MAX_NAMES_IN_NAMETABLE 16 +#endif + + +/* ************************************************************************** + * RESOLVER CONFIGURATION + */ + + +/** + * Maximum numbers of DNS nameservers that can be configured in resolver. + */ +#ifndef PJ_DNS_RESOLVER_MAX_NS +# define PJ_DNS_RESOLVER_MAX_NS 16 +#endif + + +/** + * Default retransmission delay, in miliseconds. The combination of + * retransmission delay and count determines the query timeout. + * + * Default: 2000 (2 seconds, according to RFC 1035) + */ +#ifndef PJ_DNS_RESOLVER_QUERY_RETRANSMIT_DELAY +# define PJ_DNS_RESOLVER_QUERY_RETRANSMIT_DELAY 2000 +#endif + + +/** + * Maximum number of transmissions before timeout is declared for + * the query. + * + * Default: 5 + */ +#ifndef PJ_DNS_RESOLVER_QUERY_RETRANSMIT_COUNT +# define PJ_DNS_RESOLVER_QUERY_RETRANSMIT_COUNT 5 +#endif + + +/** + * Maximum life-time of DNS response in the resolver response cache, + * in seconds. If the value is zero, then DNS response caching will be + * disabled. + * + * Default is 300 seconds (5 minutes). + * + * @see PJ_DNS_RESOLVER_INVALID_TTL + */ +#ifndef PJ_DNS_RESOLVER_MAX_TTL +# define PJ_DNS_RESOLVER_MAX_TTL (5*60) +#endif + +/** + * The life-time of invalid DNS response in the resolver response cache. + * An invalid DNS response is a response which RCODE is non-zero and + * response without any answer section. These responses can be put in + * the cache too to minimize message round-trip. + * + * Default: 60 (one minute). + * + * @see PJ_DNS_RESOLVER_MAX_TTL + */ +#ifndef PJ_DNS_RESOLVER_INVALID_TTL +# define PJ_DNS_RESOLVER_INVALID_TTL 60 +#endif + +/** + * The interval on which nameservers which are known to be good to be + * probed again to determine whether they are still good. Note that + * this applies to both active nameserver (the one currently being used) + * and idle nameservers (good nameservers that are not currently selected). + * The probing to query the "goodness" of nameservers involves sending + * the same query to multiple servers, so it's probably not a good idea + * to send this probing too often. + * + * Default: 600 (ten minutes) + * + * @see PJ_DNS_RESOLVER_BAD_NS_TTL + */ +#ifndef PJ_DNS_RESOLVER_GOOD_NS_TTL +# define PJ_DNS_RESOLVER_GOOD_NS_TTL (10*60) +#endif + +/** + * The interval on which nameservers which known to be bad to be probed + * again to determine whether it is still bad. + * + * Default: 60 (one minute) + * + * @see PJ_DNS_RESOLVER_GOOD_NS_TTL + */ +#ifndef PJ_DNS_RESOLVER_BAD_NS_TTL +# define PJ_DNS_RESOLVER_BAD_NS_TTL (1*60) +#endif + + +/** + * Maximum size of UDP packet. RFC 1035 states that maximum size of + * DNS packet carried over UDP is 512 bytes. + * + * Default: 512 byes + */ +#ifndef PJ_DNS_RESOLVER_MAX_UDP_SIZE +# define PJ_DNS_RESOLVER_MAX_UDP_SIZE 512 +#endif + + +/** + * Size of memory pool allocated for each individual DNS response cache. + * This value here should be more or less the same as maximum UDP packet + * size (PJ_DNS_RESOLVER_MAX_UDP_SIZE), since the DNS replicator function + * (#pj_dns_packet_dup()) is also capable of performing name compressions. + * + * Default: 512 (as a broad guidance, 400 is good for 4 SRV entries). + */ +#ifndef PJ_DNS_RESOLVER_RES_BUF_SIZE +# define PJ_DNS_RESOLVER_RES_BUF_SIZE 512 +#endif + + + +/* ************************************************************************** + * SCANNER CONFIGURATION + */ + + +/** + * Macro PJ_SCANNER_USE_BITWISE is defined and non-zero (by default yes) + * will enable the use of bitwise for character input specification (cis). + * This would save several kilobytes of .bss memory in the SIP parser. + */ +#ifndef PJ_SCANNER_USE_BITWISE +# define PJ_SCANNER_USE_BITWISE 1 +#endif + + + +/* ************************************************************************** + * STUN CLIENT CONFIGURATION + */ + +/** + * Maximum number of attributes in the STUN packet. + * + * Default: 16 + */ +#ifndef PJ_STUN_MAX_ATTR +# define PJ_STUN_MAX_ATTR 16 +#endif + + +/** + * @} + */ + +#endif /* __PJLIB_UTIL_CONFIG_H__ */ + diff --git a/pjlib-util/include/pjlib-util/dns.h b/pjlib-util/include/pjlib-util/dns.h index d431b0da..6793cab2 100644 --- a/pjlib-util/include/pjlib-util/dns.h +++ b/pjlib-util/include/pjlib-util/dns.h @@ -24,15 +24,19 @@ * @file dns.h * @brief Low level DNS message parsing and packetization. */ -#include <pj/types.h> +#include <pjlib-util/types.h> PJ_BEGIN_DECL +/** + * @defgroup PJ_DNS DNS and Asynchronous DNS Resolver + * @ingroup PJLIB_UTIL + */ /** - * @defgroup PJ_DNS Low-level DNS message parsing and packetization - * @ingroup PJ + * @defgroup PJ_DNS_PARSING Low-level DNS Message Parsing and Packetization + * @ingroup PJ_DNS * @{ * * This module provides low-level services to parse and packetize DNS queries @@ -199,23 +203,6 @@ typedef enum pj_dns_rcode /** - * This constant specifies the maximum names to keep in the temporary name - * table when performing name compression scheme when duplicating DNS packet - * (the #pj_dns_packet_dup() function). - * - * Generally name compression is desired, since it saves some memory (see - * PJ_DNS_RESOLVER_RES_BUF_SIZE setting). However it comes at the expense of - * a little processing overhead to perform name scanning and also a little - * bit more stack usage (8 bytes per entry on 32bit platform). - * - * Default: 16 - */ -#ifndef PJ_DNS_MAX_NAMES_IN_NAMETABLE -# define PJ_DNS_MAX_NAMES_IN_NAMETABLE 16 -#endif - - -/** * This structure describes a DNS query record. */ typedef struct pj_dns_parsed_query @@ -344,7 +331,7 @@ PJ_DECL(pj_status_t) pj_dns_parse_packet(pj_pool_t *pool, * * @param pool The pool to allocate memory for the duplicated packet. * @param p The DNS packet to be cloned. - * @p_dst Pointer to store the cloned DNS packet. + * @param p_dst Pointer to store the cloned DNS packet. */ PJ_DECL(void) pj_dns_packet_dup(pj_pool_t *pool, const pj_dns_parsed_packet*p, diff --git a/pjlib-util/include/pjlib-util/errno.h b/pjlib-util/include/pjlib-util/errno.h index 589fcb63..b49f6b37 100644 --- a/pjlib-util/include/pjlib-util/errno.h +++ b/pjlib-util/include/pjlib-util/errno.h @@ -22,6 +22,11 @@ #include <pj/errno.h> +/** + * @defgroup PJLIB_UTIL_ERROR PJLIB-UTIL Error Codes + * @ingroup PJLIB_UTIL + * @{ + */ /** * Start of error code relative to PJ_ERRNO_START_USER. @@ -240,4 +245,8 @@ #define PJLIB_UTIL_EDNS_NOTZONE PJ_STATUS_FROM_DNS_RCODE(10)/* 320060 */ +/** + * @} + */ + #endif /* __PJLIB_UTIL_ERRNO_H__ */ diff --git a/pjlib-util/include/pjlib-util/getopt.h b/pjlib-util/include/pjlib-util/getopt.h index 013a7ab5..4b48f9db 100644 --- a/pjlib-util/include/pjlib-util/getopt.h +++ b/pjlib-util/include/pjlib-util/getopt.h @@ -22,6 +22,17 @@ #ifndef __PJ_GETOPT_H__ #define __PJ_GETOPT_H__ 1 +/** + * @file getopt.h + * @brief Compile time settings + */ + +/** + * @defgroup PJLIB_UTIL_GETOPT Getopt + * @ingroup PJLIB_UTIL + * @{ + */ + #ifdef __cplusplus extern "C" { #endif @@ -127,5 +138,9 @@ int pj_getopt_long_only (int argc, char *const *argv, } #endif +/** + * @} + */ + #endif /* pj_getopt.h */ diff --git a/pjlib-util/include/pjlib-util/md5.h b/pjlib-util/include/pjlib-util/md5.h index 92c55fc8..39e22d62 100644 --- a/pjlib-util/include/pjlib-util/md5.h +++ b/pjlib-util/include/pjlib-util/md5.h @@ -19,10 +19,22 @@ #ifndef __PJLIB_UTIL_MD5_H__ #define __PJLIB_UTIL_MD5_H__ +/** + * @file md5.h + * @brief MD5 Functions + */ + #include <pj/types.h> PJ_BEGIN_DECL +/** + * @defgroup PJLIB_UTIL_MD5 MD5 Functions + * @ingroup PJLIB_UTIL + * @{ + */ + + /** MD5 context. */ typedef struct pj_md5_context { @@ -50,6 +62,12 @@ PJ_DECL(void) pj_md5_update( pj_md5_context *pms, */ PJ_DECL(void) pj_md5_final(pj_md5_context *pms, pj_uint8_t digest[16]); + +/** + * @} + */ + PJ_END_DECL + #endif /* __PJLIB_UTIL_MD5_H__ */ diff --git a/pjlib-util/include/pjlib-util/resolver.h b/pjlib-util/include/pjlib-util/resolver.h index 471b5717..56043319 100644 --- a/pjlib-util/include/pjlib-util/resolver.h +++ b/pjlib-util/include/pjlib-util/resolver.h @@ -30,8 +30,8 @@ PJ_BEGIN_DECL /** - * @defgroup PJ_DNS_RESOLVER Asynchronous DNS Server Resolution - * @ingroup PJLIB_UTIL + * @defgroup PJ_DNS_RESOLVER DNS Asynchronous/Caching Resolution Engine + * @ingroup PJ_DNS * @{ * * This module manages the host/server resolution by performing asynchronous @@ -132,7 +132,8 @@ PJ_BEGIN_DECL * enties will be created in the response cache. * * Note that a single response entry will occupy about 600-700 bytes of - * pool memory. + * pool memory (the PJ_DNS_RESOLVER_RES_BUF_SIZE value plus internal + * structure). * * Application can work around this problem by doing one of these: * - disable caching by setting PJ_DNS_RESOLVER_MAX_TTL and @@ -148,125 +149,14 @@ PJ_BEGIN_DECL * * The PJLIB-UTIL resolver was built from the information in the following * standards: - * - RFC 1035: "Domain names - implementation and specification" - * - RFC 2782: "A DNS RR for specifying the location of services (DNS SRV)" + * - <A HREF="http://www.faqs.org/rfcs/rfc1035.html"> + * RFC 1035: "Domain names - implementation and specification"</A> + * - <A HREF="http://www.faqs.org/rfcs/rfc2782.html"> + * RFC 2782: "A DNS RR for specifying the location of services (DNS SRV)" + * </A> */ -/* - * CONFIGURATIONS - */ - -/** - * Maximum numbers of DNS nameservers that can be configured in resolver. - */ -#ifndef PJ_DNS_RESOLVER_MAX_NS -# define PJ_DNS_RESOLVER_MAX_NS 16 -#endif - - -/** - * Default retransmission delay, in miliseconds. The combination of - * retransmission delay and count determines the query timeout. - * - * Default: 2000 (2 seconds, according to RFC 1035) - */ -#ifndef PJ_DNS_RESOLVER_QUERY_RETRANSMIT_DELAY -# define PJ_DNS_RESOLVER_QUERY_RETRANSMIT_DELAY 2000 -#endif - - -/** - * Maximum number of transmissions before timeout is declared for - * the query. - * - * Default: 2 - */ -#ifndef PJ_DNS_RESOLVER_QUERY_RETRANSMIT_COUNT -# define PJ_DNS_RESOLVER_QUERY_RETRANSMIT_COUNT 5 -#endif - - -/** - * Maximum life-time of DNS response in the resolver response cache, - * in seconds. If the value is zero, then DNS response caching will be - * disabled. - * - * Default is 300 seconds (5 minutes). - * - * @see PJ_DNS_RESOLVER_INVALID_TTL - */ -#ifndef PJ_DNS_RESOLVER_MAX_TTL -# define PJ_DNS_RESOLVER_MAX_TTL (5*60) -#endif - -/** - * The life-time of invalid DNS response in the resolver response cache. - * An invalid DNS response is a response without an answer. These - * responses can be put in the cache too to minimize message round-trip. - * - * Default: 0 (which means, invalid DNS response will not be cached). - * - * @see PJ_DNS_RESOLVER_MAX_TTL - */ -#ifndef PJ_DNS_RESOLVER_INVALID_TTL -# define PJ_DNS_RESOLVER_INVALID_TTL 60 -#endif - -/** - * The interval on which nameservers which are known to be good to be - * probed again to determine whether they are still good. Note that - * this applies to both active nameserver (the one currently being used) - * and idle nameservers (good nameservers that are not currently selected). - * The probing to query the "goodness" of nameservers involves sending - * the same query to multiple servers, so it's probably not a good idea - * to send this probing too often. - * - * Default: 600 (ten minutes) - * - * @see PJ_DNS_RESOLVER_BAD_NS_TTL - */ -#ifndef PJ_DNS_RESOLVER_GOOD_NS_TTL -# define PJ_DNS_RESOLVER_GOOD_NS_TTL (10*60) -#endif - -/** - * The interval on which nameservers which known to be bad to be probed - * again to determine whether it is still bad. - * - * Default: 600 (ten minutes) - * - * @see PJ_DNS_RESOLVER_GOOD_NS_TTL - */ -#ifndef PJ_DNS_RESOLVER_BAD_NS_TTL -# define PJ_DNS_RESOLVER_BAD_NS_TTL (1*60) -#endif - - -/** - * Maximum size of UDP packet. RFC 1035 states that maximum size of - * DNS packet carried over UDP is 512 bytes. - * - * Default: 512 byes - */ -#ifndef PJ_DNS_RESOLVER_MAX_UDP_SIZE -# define PJ_DNS_RESOLVER_MAX_UDP_SIZE 512 -#endif - - -/** - * Size of memory pool allocated for each individual DNS response cache. - * This value here should be more or less the same as maximum UDP packet - * size (PJ_DNS_RESOLVER_MAX_UDP_SIZE), since the DNS replicator function - * (#pj_dns_packet_dup()) is also capable of performing name compressions. - * - * Default: 512 (as a broad guidance, 400 is good for 4 SRV entries). - */ -#ifndef PJ_DNS_RESOLVER_RES_BUF_SIZE -# define PJ_DNS_RESOLVER_RES_BUF_SIZE 512 -#endif - - /** * Opaque data type for DNS resolver object. diff --git a/pjlib-util/include/pjlib-util/scanner.h b/pjlib-util/include/pjlib-util/scanner.h index e5e8ee41..b9812eca 100644 --- a/pjlib-util/include/pjlib-util/scanner.h +++ b/pjlib-util/include/pjlib-util/scanner.h @@ -24,25 +24,16 @@ * @brief Text Scanning. */ -#include <pj/types.h> - -/** - * Macro PJ_SCANNER_USE_BITWISE is defined and non-zero (by default yes) - * will enable the use of bitwise for character input specification (cis). - * This would save several kilobytes of .bss memory in the SIP parser. - */ -#ifndef PJ_SCANNER_USE_BITWISE -# define PJ_SCANNER_USE_BITWISE 1 -#endif - +#include <pjlib-util/types.h> PJ_BEGIN_DECL /** - * @defgroup PJ_SCAN Text Scanning - * @ingroup PJ_MISC - * @brief - * Text scanning utility. + * @defgroup PJ_SCAN Fast Text Scanning + * @ingroup PJLIB_UTIL + * @brief Text scanning utility. + * + * This module describes a fast text scanning functions. * * @{ */ diff --git a/pjlib-util/include/pjlib-util/string.h b/pjlib-util/include/pjlib-util/string.h index 617e6bd7..fac49494 100644 --- a/pjlib-util/include/pjlib-util/string.h +++ b/pjlib-util/include/pjlib-util/string.h @@ -27,6 +27,12 @@ #include <pj/types.h> #include <pjlib-util/scanner.h> +/** + * @defgroup PJLIB_UTIL_STRING String Escaping Utilities + * @ingroup PJLIB_UTIL + * @{ + */ + PJ_BEGIN_DECL /** @@ -87,4 +93,9 @@ PJ_DECL(pj_ssize_t) pj_strncpy2_escape(char *dst, const pj_str_t *src, PJ_END_DECL + +/** + * @} + */ + #endif /* __PJLIB_UTIL_STRING_H__ */ diff --git a/pjlib-util/include/pjlib-util/stun.h b/pjlib-util/include/pjlib-util/stun.h index 0a431039..e317877c 100644 --- a/pjlib-util/include/pjlib-util/stun.h +++ b/pjlib-util/include/pjlib-util/stun.h @@ -19,13 +19,25 @@ #ifndef __PJ_STUN_H__ #define __PJ_STUN_H__ -#include <pj/types.h> +/** + * @file stun.h + * @brief STUN client. + */ + +#include <pjlib-util/types.h> #include <pj/sock.h> -PJ_BEGIN_DECL +/** + * @defgroup PJLIB_UTIL_STUN_CLIENT Mini/Tiny STUN Client + * @ingroup PJLIB_UTIL + * @{ + */ -#define PJ_STUN_MAX_ATTR 16 +PJ_BEGIN_DECL +/** + * This enumeration describes STUN message types. + */ typedef enum pj_stun_msg_type { PJ_STUN_BINDING_REQUEST = 0x0001, @@ -36,6 +48,10 @@ typedef enum pj_stun_msg_type PJ_STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112 } pj_stun_msg_type; + +/** + * This enumeration describes STUN attribute types. + */ typedef enum pj_stun_attr_type { PJ_STUN_ATTR_MAPPED_ADDR = 1, @@ -51,6 +67,10 @@ typedef enum pj_stun_attr_type PJ_STUN_ATTR_REFLECTED_FORM } pj_stun_attr_type; + +/** + * This structre describes STUN message header. + */ typedef struct pj_stun_msg_hdr { pj_uint16_t type; @@ -58,12 +78,20 @@ typedef struct pj_stun_msg_hdr pj_uint32_t tsx[4]; } pj_stun_msg_hdr; + +/** + * This structre describes STUN attribute header. + */ typedef struct pj_stun_attr_hdr { pj_uint16_t type; pj_uint16_t length; } pj_stun_attr_hdr; + +/** + * This structre describes STUN MAPPED-ADDR attribute. + */ typedef struct pj_stun_mapped_addr_attr { pj_stun_attr_hdr hdr; @@ -118,6 +146,45 @@ PJ_DECL(pj_status_t) pj_stun_parse_msg( void *buf, pj_size_t len, pj_stun_msg *msg); PJ_DECL(void*) pj_stun_msg_find_attr( pj_stun_msg *msg, pj_stun_attr_type t); + +/** + * This is the main function to request the mapped address of local sockets + * to multiple STUN servers. This function is able to find the mapped + * addresses of multiple sockets simultaneously, and for each socket, two + * requests will be sent to two different STUN servers to see if both servers + * get the same public address for the same socket. (Note that application can + * specify the same address for the two servers, but still two requests will + * be sent for each server). + * + * This function will perform necessary retransmissions of the requests if + * response is not received within a predetermined period. When all responses + * have been received, the function will compare the mapped addresses returned + * by the servers, and when both are equal, the address will be returned in + * \a mapped_addr argument. + * + * @param pf The pool factory where memory will be allocated from. + * @param sock_cnt Number of sockets in the socket array. + * @param sock Array of local UDP sockets which public addresses are + * to be queried from the STUN servers. + * @param srv1 Host name or IP address string of the first STUN + * server. + * @param port1 The port number of the first STUN server. + * @param srv2 Host name or IP address string of the second STUN + * server. + * @param port2 The port number of the second STUN server. + * @param mapped_addr Array to receive the mapped public address of the local + * UDP sockets, when the function returns PJ_SUCCESS. + * + * @return This functions returns PJ_SUCCESS if responses are + * received from all servers AND all servers returned the + * same mapped public address. Otherwise this function may + * return one of the following error codes: + * - PJLIB_UTIL_ESTUNNOTRESPOND: no respons from servers. + * - PJLIB_UTIL_ESTUNSYMMETRIC: different mapped addresses + * are returned by servers. + * - etc. + * + */ PJ_DECL(pj_status_t) pj_stun_get_mapped_addr( pj_pool_factory *pf, int sock_cnt, pj_sock_t sock[], const pj_str_t *srv1, int port1, @@ -126,5 +193,9 @@ PJ_DECL(pj_status_t) pj_stun_get_mapped_addr( pj_pool_factory *pf, PJ_END_DECL +/** + * @} + */ + #endif /* __PJ_STUN_H__ */ diff --git a/pjlib-util/include/pjlib-util/types.h b/pjlib-util/include/pjlib-util/types.h new file mode 100644 index 00000000..d943a835 --- /dev/null +++ b/pjlib-util/include/pjlib-util/types.h @@ -0,0 +1,63 @@ +/* $Id$ */ +/* + * Copyright (C) 2003-2006 Benny Prijono <benny@prijono.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __PJLIB_UTIL_TYPES_H__ +#define __PJLIB_UTIL_TYPES_H__ + +/** + * @file types.h + * @brief PJLIB-UTIL types. + */ + +#include <pj/types.h> +#include <pjlib-util/config.h> + +/** + * @defgroup PJLIB_UTIL PJLIB-UTIL Library + */ + +/** + * @mainpage PJLIB-UTIL + * + * \n + * \n + * \n + * This is the documentation of PJLIB-UTIL, an auxiliary library providing + * adjunct functions to PJLIB. + * + * Please go to the <A HREF="modules.htm"><B>Modules</B></A> page for list + * of modules. + * + * + * \n + * \n + * \n + * \n + * \n + * \n + * \n + * \n + * \n + * \n + * \n + * \n + * \n + */ + +#endif /* __PJLIB_UTIL_TYPES_H__ */ + diff --git a/pjlib-util/include/pjlib-util/xml.h b/pjlib-util/include/pjlib-util/xml.h index f3c58152..8b79833f 100644 --- a/pjlib-util/include/pjlib-util/xml.h +++ b/pjlib-util/include/pjlib-util/xml.h @@ -30,8 +30,8 @@ PJ_BEGIN_DECL /** - * @defgroup PJ_XML XML Parser/Helper. - * @ingroup PJ + * @defgroup PJ_TINY_XML Mini/Tiny XML Parser/Helper + * @ingroup PJLIB_UTIL * @{ */ diff --git a/pjlib-util/src/pjlib-util/dns.c b/pjlib-util/src/pjlib-util/dns.c index e2d3b9f4..7f5f0674 100644 --- a/pjlib-util/src/pjlib-util/dns.c +++ b/pjlib-util/src/pjlib-util/dns.c @@ -455,7 +455,7 @@ PJ_DEF(pj_status_t) pj_dns_parse_packet( pj_pool_t *pool, res->q = pj_pool_zalloc(pool, res->hdr.qdcount * sizeof(pj_dns_parsed_query)); for (i=0; i<res->hdr.qdcount; ++i) { - int parsed_len; + int parsed_len = 0; status = parse_query(&res->q[i], pool, packet, start, end, &parsed_len); diff --git a/pjlib-util/src/pjlib-util/resolver.c b/pjlib-util/src/pjlib-util/resolver.c index 3694c8e1..4080ad22 100644 --- a/pjlib-util/src/pjlib-util/resolver.c +++ b/pjlib-util/src/pjlib-util/resolver.c @@ -948,7 +948,7 @@ static void update_res_cache(pj_dns_resolver *resolver, /* Calculate expiration time. */ if (set_expiry) { - if (pkt->hdr.anscount == 0) { + if (pkt->hdr.anscount == 0 || status != PJ_SUCCESS) { /* If we don't have answers for the name, then give a different * ttl value (note: PJ_DNS_RESOLVER_INVALID_TTL may be zero, * which means that invalid names won't be kept in the cache) |