Commit 3fa786ad authored by Pekka Pessi's avatar Pekka Pessi

Added namespace-specific filter tags.

darcs-hash:20060105174213-65a35-bc59bb7ea6a567653d1fd491d076a422819cc6ca.gz
parent 9ff71c51
......@@ -54,6 +54,8 @@
#include <http_tag.h>
#include <http_tag_class.h>
tag_typedef_t httptag_any = NSTAG_TYPEDEF(*);
tag_typedef_t httptag_http = HTTPMSGTAG_TYPEDEF(http);
tag_typedef_t httptag_version = STRTAG_TYPEDEF(version);
tag_typedef_t httptag_header =
......
......@@ -80,6 +80,10 @@ HTTP_DLL extern tag_class_t httphdrtag_class[1];
HTTP_DLL extern tag_class_t httpstrtag_class[1];
HTTP_DLL extern tag_class_t httpmsgtag_class[1];
/** Filter tag matching any http tag. */
#define HTTPTAG_ANY() httptag_any, ((tag_value_t)0)
HTTP_DLL extern tag_typedef_t httptag_any;
/**Tag list item for @c http_t object.
*
* The HTTPTAG_HTTP() macro is used to include a tag item for a http_t object
......
......@@ -206,6 +206,9 @@ const char *auth_mod_check_http(auth_mod_t *am,
auth_kind_t proxy);
#endif
#define AUTHTAG_ANY() authtag_any, ((tag_value_t)0)
AUTH_DLL extern tag_typedef_t authtag_any;
/** Pointer to an authentication server (auth_mod_t). */
#define AUTHTAG_MODULE(x) authtag_module, authtag_module_v((x))
AUTH_DLL extern tag_typedef_t authtag_module;
......
......@@ -39,6 +39,12 @@
#include <su_tag_class.h>
#include <url_tag_class.h>
/**@def AUTHTAG_ANY()
*
* Filter tag matching any AUTHTAG_*().
*/
tag_typedef_t authtag_any = NSTAG_TYPEDEF(*);
/**@def AUTHTAG_MODULE()
*
* Pointer to an authentication server module (auth_mod_t).
......
......@@ -43,6 +43,7 @@
#include <sip_tag_class.h>
#include <url_tag_class.h>
tag_typedef_t neatag_any = NSTAG_TYPEDEF(*);
tag_typedef_t neatag_min_expires = UINTTAG_TYPEDEF(min_expires);
tag_typedef_t neatag_expires = UINTTAG_TYPEDEF(expires);
tag_typedef_t neatag_max_expires = UINTTAG_TYPEDEF(max_expires);
......
......@@ -66,6 +66,10 @@ typedef enum {
nea_terminated
} nea_state_t;
/** Filter tag matching any nea tag. */
#define NEATAG_ANY() neatag_any, ((tag_value_t)0)
NEA_DLL extern tag_typedef_t neatag_any;
/** Specify the minimum duration of a subscription (by default, 15 minutes) */
#define NEATAG_MIN_EXPIRES(x) neatag_min_expires, tag_uint_v((x))
NEA_DLL extern tag_typedef_t neatag_min_expires;
......
......@@ -67,6 +67,3 @@ EXTRA_DIST = Doxyfile nta.docs sl_utils.docs \
# Sofia specific rules
include ../sofia.am
# Generate list of nta tags
TAG_DLL_FLAGS = LIST=nta_tag_list
......@@ -47,6 +47,8 @@
#include <sip_protos.h>
tag_typedef_t ntatag_any = NSTAG_TYPEDEF(*);
tag_typedef_t ntatag_mclass = PTRTAG_TYPEDEF(mclass);
tag_typedef_t ntatag_bad_req_mask = UINTTAG_TYPEDEF(bad_req_mask);
tag_typedef_t ntatag_bad_resp_mask = UINTTAG_TYPEDEF(bad_resp_mask);
......
......@@ -51,7 +51,10 @@
SOFIA_BEGIN_DECLS
NTA_DLL extern tag_type_t nta_tag_list[];
/** Filter tag matching any nta tag. */
#define NTATAG_ANY() ntatag_any, ((tag_value_t)0)
NTA_DLL extern tag_typedef_t ntatag_any;
/* Tags for parameters */
......
......@@ -47,6 +47,8 @@
#include <http_protos.h>
tag_typedef_t nthtag_any = NSTAG_TYPEDEF(*);
/* Common */
tag_typedef_t nthtag_mclass = PTRTAG_TYPEDEF(mclass);
tag_typedef_t nthtag_message = PTRTAG_TYPEDEF(message);
......
......@@ -55,7 +55,9 @@ SOFIA_BEGIN_DECLS
#endif
#endif
NTH_DLL extern tagi_t nth_client_tags[];
/** Filter tag matching any nth tag. */
#define NTHTAG_ANY() nthtag_any, ((tag_value_t)0)
NTH_DLL extern tag_typedef_t nthtag_any;
/* Common tags */
......
......@@ -71,5 +71,3 @@ EXTRA_DIST = Doxyfile nua.docs $(BUILT_SOURCES)
# Sofia specific rules
include ../sofia.am
TAG_DLL_FLAGS = LIST=nua_tag_list
......@@ -41,6 +41,8 @@
#include <sip_tag_class.h>
#include <sip_hclasses.h>
tag_typedef_t nutag_any = NSTAG_TYPEDEF(*);
tag_typedef_t nutag_url = URLTAG_TYPEDEF(url);
tag_typedef_t nutag_address = STRTAG_TYPEDEF(address);
tag_typedef_t nutag_uicc = STRTAG_TYPEDEF(uicc);
......
......@@ -63,8 +63,9 @@ typedef struct nua_s nua_t;
/** NUA transaction handle. */
typedef struct nua_handle_s nua_handle_t;
/** List of all NUA tags. */
extern tag_type_t nua_tag_list[];
/** Filter tag matching any nua tag. */
#define NUTAG_ANY() nutag_any, ((tag_value_t)0)
extern tag_typedef_t nutag_any;
/** URL address from application to NUA
*
......
......@@ -660,6 +660,44 @@ int test_api_errors(struct context *ctx)
END();
}
#include <su_tag_class.h>
int test_tag_filter(void)
{
BEGIN();
#undef TAG_NAMESPACE
#define TAG_NAMESPACE "test"
tag_typedef_t tag_a = STRTAG_TYPEDEF(a);
#define TAG_A(s) tag_a, tag_str_v((s))
tag_typedef_t tag_b = STRTAG_TYPEDEF(b);
#define TAG_B(s) tag_b, tag_str_v((s))
tagi_t filter[2] = {{ NUTAG_ANY() }, { TAG_END() }};
tagi_t *lst, *result;
lst = tl_list(TAG_A("X"),
TAG_SKIP(2),
NUTAG_URL((void *)"urn:foo"),
TAG_B("Y"),
NUTAG_URL((void *)"urn:bar"),
TAG_NULL());
TEST_1(lst);
result = tl_afilter(NULL, filter, lst);
TEST_1(result);
TEST(result[0].t_tag, nutag_url);
TEST(result[1].t_tag, nutag_url);
tl_vfree(lst);
free(result);
END();
}
int test_params(struct context *ctx)
{
BEGIN();
......@@ -4797,6 +4835,7 @@ int main(int argc, char *argv[])
} while(0)
retval |= test_api_errors(ctx); SINGLE_FAILURE_CHECK();
retval |= test_tag_filter(); SINGLE_FAILURE_CHECK();
retval |= test_params(ctx); SINGLE_FAILURE_CHECK();
retval |= test_init(ctx, o_iproxy,
......
......@@ -40,6 +40,8 @@
#include <sdp_tag.h>
tag_typedef_t sdptag_any = NSTAG_TYPEDEF(*);
tag_typedef_t sdptag_session = {{
TAG_NAMESPACE, "session", sdptag_session_class
}};
......@@ -53,6 +53,10 @@ SOFIA_BEGIN_DECLS
struct sdp_session_s;
/** Filter tag matching any sdp tag. */
#define SDPTAG_ANY() sdptag_any, ((tag_value_t)0)
SDP_DLL extern tag_typedef_t sdptag_any;
/* Tags for parameters */
SDP_DLL extern tag_typedef_t sdptag_session;
......
......@@ -57,6 +57,8 @@
#include <su_tagarg.h>
tag_typedef_t siptag_any = NSTAG_TYPEDEF(*);
tag_typedef_t siptag_sip = SIPMSGTAG_TYPEDEF(sip);
tag_typedef_t siptag_header = {{ "sip", "header", siphdrtag_class, 0 }};
......@@ -75,16 +77,3 @@ tag_typedef_t siptag_#xxxxxx# = SIPHDRTAG_TYPEDEF(#xxxxxx#);
*/
tag_typedef_t siptag_#xxxxxx#_str = SIPSTRTAG_TYPEDEF(#xxxxxx#);
/** List of all tags for SIP headers */
tag_type_t sip_tag_list[] =
{
siptag_#xxxxxx#,
NULL
};
/** List of all string tags for SIP headers */
tag_type_t sip_tag_str_list[] =
{
siptag_#xxxxxx#_str,
NULL
};
......@@ -76,10 +76,12 @@ SIP_DLL extern tag_class_t sipstrtag_class[1];
/** Tag class for SIP message */
SIP_DLL extern tag_class_t sipmsgtag_class[1];
SIP_DLL extern tag_type_t sip_tag_list[], sip_tag_str_list[];
/** Filter tag matching any sip tag. */
#define SIPTAG_ANY() siptag_any, ((tag_value_t)0)
SIP_DLL extern tag_typedef_t siptag_any;
/** End of SIP headers */
#define SIPTAG_END() siptag_end, (tag_value_t)0
#define SIPTAG_END() siptag_end, (tag_value_t)0
SIP_DLL extern tag_typedef_t siptag_end;
/**Tag list item for #sip_t object.
......
......@@ -48,5 +48,3 @@ EXTRA_DIST = Doxyfile soa.docs $(BUILT_SOURCES)
# Sofia specific rules
include ../sofia.am
TAG_DLL_FLAGS = LIST=soa_tag_list
......@@ -39,6 +39,12 @@
#include <su_tag_class.h>
#include <sdp_tag.h>
/**@def SOATAG_ANY()
*
* Filter tag matching any SOATAG_*() item.
*/
tag_typedef_t soatag_any = NSTAG_TYPEDEF(*);
/**@def SOATAG_CAPS_SDP(x)
* Pass parsed capability description to soa session object.
*
......
......@@ -40,6 +40,10 @@
SOFIA_BEGIN_DECLS
/** Filter tag matching any soa tag. */
#define SOATAG_ANY() soatag_any, ((tag_value_t)0)
extern tag_typedef_t soatag_any;
/**
* Media states
*/
......
......@@ -2919,6 +2919,7 @@ m_get_domain(char *d,
#include <su_tag_class.h>
#include <su_tagarg.h>
tag_typedef_t srestag_any = NSTAG_TYPEDEF(*);
tag_typedef_t srestag_resolv_conf = STRTAG_TYPEDEF(resolv_conf);
tag_typedef_t srestag_resolv_conf_ref = REFTAG_TYPEDEF(srestag_resolv_conf);
......
......@@ -330,6 +330,10 @@ void sres_free_answer(sres_resolver_t *res, sres_record_t *answer);
#include <su_wait.h>
#include <su_tag.h>
/** Filter tag matching any sresolv tag. */
#define SRESOLVTAG_ANY() srestag_any, ((tag_value_t)0)
extern tag_typedef_t srestag_any;
extern tag_typedef_t srestag_resolv_conf;
#define SRESTAG_RESOLV_CONF(x) srestag_resolv_conf, tag_str_v((x))
extern tag_typedef_t srestag_resolv_conf_ref;
......
......@@ -51,7 +51,3 @@ torture_stun_LDFLAGS = -static
#TESTS = torture_stun
include ../sofia.am
TAG_DLL_FLAGS = LIST=stun_tag_list
built_sources: $(BUILT_SOURCES)
......@@ -35,6 +35,12 @@
#include <su_tag_class.h>
/**@def STUNTAG_ANY()
*
* Filter tag matching any STUNTAG_*().
*/
tag_typedef_t stuntag_any = NSTAG_TYPEDEF(*);
/**@def STUNTAG_SERVER(x)
*
* Pass media address.
......
......@@ -37,6 +37,9 @@
SOFIA_BEGIN_DECLS
#define STUNTAG_ANY() stuntag_any, ((tag_value_t)0)
extern tag_typedef_t stuntag_any;
#define STUNTAG_SERVER(x) stuntag_server, tag_str_v(x)
extern tag_typedef_t stuntag_server;
#define STUNTAG_SERVER_REF(x) stuntag_server_ref, tag_str_vr(&(x))
......
......@@ -104,10 +104,10 @@ HEADER {
/^#define TAG_NAMESPACE/ {
print "#undef TAG_NAMESPACE" > REF;
print $0 > REF;
print > REF;
print "" > REF;
print "#undef TAG_NAMESPACE" > DLL;
print $0 > DLL;
print > DLL;
print "" > DLL;
}
!DEFS && /^tag_typedef_t/ { DEFS = 1; }
......@@ -115,18 +115,17 @@ HEADER {
DEFS && /tag_typedef_t/ {
tag = $2;
typedefs[tag] = $0;
gsub(/ = .*$/, ";");
if (DLLREF) {
print "EXPORT tag_typedef_t "tag"_ref;" > DLL;
}
else {
if ($0 !~ /NSTAG_TYPEDEF/) {
print "EXPORT tag_typedef_t "tag"_ref;" > DLL;
print "extern tag_typedef_t "tag";" > REF;
print "EXPORT tag_typedef_t "tag"_ref = \n REFTAG_TYPEDEF("tag");" > REF;
}
print "extern tag_typedef_t "tag";" > REF;
print "EXPORT tag_typedef_t "tag"_ref = \n REFTAG_TYPEDEF("tag");" > REF;
gsub(/ = .*$/, ";");
}
!DLLREF { print > DLL; }
!DLLREF { print $0 > DLL; }
END {
if (LIST) {
......
......@@ -103,7 +103,8 @@ struct tp_test_s {
uint8_t tt_digest[SU_MD5_DIGEST_SIZE];
};
#define TSTFLAGS tt->tt_flags
int tstflags;
#define TSTFLAGS tstflags
#include <tstdef.h>
......@@ -1313,6 +1314,36 @@ static int deinit_test(tp_test_t *tt)
END();
}
/* Test tport_tags filter */
static int filter_test(tp_test_t *tt)
{
tagi_t *lst, *result;
su_home_t home[1] = { SU_HOME_INIT(home) };
BEGIN();
lst = tl_list(TSTTAG_HEADER_STR("X: Y"),
TAG_SKIP(2),
TPTAG_IDENT("foo"),
TSTTAG_HEADER_STR("X: Y"),
TPTAG_IDENT("bar"),
TAG_NULL());
TEST_1(lst);
result = tl_afilter(home, tport_tags, lst);
TEST_1(result);
TEST(result[0].t_tag, tptag_ident);
TEST(result[1].t_tag, tptag_ident);
free(lst);
su_home_deinit(home);
END();
}
int main(int argc, char *argv[])
{
int flags = 0; /* XXX */
......@@ -1322,7 +1353,7 @@ int main(int argc, char *argv[])
for (i = 1; argv[i]; i++) {
if (strcmp(argv[i], "-v") == 0)
tt->tt_flags |= tst_verbatim;
tstflags |= tst_verbatim;
else
usage();
}
......@@ -1334,6 +1365,7 @@ int main(int argc, char *argv[])
tport_log->log_default = 1;
retval |= name_test(tt); fflush(stdout);
retval |= filter_test(tt); fflush(stdout);
retval |= init_test(tt); fflush(stdout);
if (retval == 0) {
......
......@@ -47,32 +47,10 @@
/* ==== Globals ========================================================== */
/** List of tags used by tport_tsend(). */
tagi_t tport_tags[] =
{
{ tptag_ident, 0 },
{ tptag_reuse, 0 },
{ tptag_server, 0 },
{ tptag_mtu, 0 },
{ tptag_connect, 0 },
{ tptag_queuesize, 0 },
{ tptag_sdwn_error, 0 },
{ tptag_sdwn_after, 0 },
{ tptag_idle, 0 },
{ tptag_certificate, 0 },
#if 0
/* These tags can only be used with tport_tbind() or tport_tcreate() */
{ tptag_tls_version, 0 },
{ tptag_queuesize, 0 },
{ tptag_udp_rmem, 0 },
{ tptag_udp_wmem, 0 },
{ tptag_thrpsize, 0 },
{ tptag_thrprqsize, 0 },
#endif
{ TAG_END() }
};
/** Filter for tport tags. */
tagi_t tport_tags[] = { { tptag_any, 0 }, { TAG_END() } };
tag_typedef_t tptag_any = NSTAG_TYPEDEF(*);
tag_typedef_t tptag_ident = CSTRTAG_TYPEDEF(ident);
tag_typedef_t tptag_reuse = BOOLTAG_TYPEDEF(reuse);
......@@ -87,7 +65,7 @@ tag_typedef_t tptag_idle = UINTTAG_TYPEDEF(idle);
tag_typedef_t tptag_timeout = UINTTAG_TYPEDEF(timeout);
tag_typedef_t tptag_sigcomp_lifetime = UINTTAG_TYPEDEF(sigcomp_lifetime);
tag_typedef_t tptag_certificate = STRTAG_TYPEDEF(certificate);
tag_typedef_t tptag_compartment = PTRTAG_TYPEDEF(certificate);
tag_typedef_t tptag_compartment = PTRTAG_TYPEDEF(compartment);
tag_typedef_t tptag_tls_version = UINTTAG_TYPEDEF(tls_version);
tag_typedef_t tptag_queuesize = UINTTAG_TYPEDEF(queuesize);
......
......@@ -47,9 +47,13 @@
SOFIA_BEGIN_DECLS
/** List of tport tags (to be used with, e.g., tl_filter()). */
/** Filter matcing any tport tag. */
TPORT_DLL extern tagi_t tport_tags[];
/** Filter tag matching any tport tag. */
#define TPTAG_ANY() tptag_any, ((tag_value_t)0)
TPORT_DLL extern tag_typedef_t tptag_any;
TPORT_DLL extern tag_typedef_t tptag_ident;
/** Ident transport connection (true by default). */
#define TPTAG_IDENT(x) tptag_ident, tag_str_v((x))
......
......@@ -41,6 +41,8 @@
#include "url.h"
#include "url_tag.h"
static int tstflags = 0;
#define TSTFLAGS tstflags
#include <tstdef.h>
......@@ -52,53 +54,8 @@ void usage(void)
fprintf(stderr, "usage: %s [-v]\n", name);
}
static int test_quote(void);
static int test_any(void);
static int test_sip(void);
static int test_wv(void);
static int test_tel(void);
static int test_fax(void);
static int test_modem(void);
static int test_file(void);
static int test_rtsp(void);
static int test_http(void);
static int test_sanitizing(void);
static int test_tags(void);
static int test_print(void);
unsigned char hash1[16], hash2[16];
static int tstflags = 0;
int main(int argc, char *argv[])
{
int retval = 0;
int i;
for (i = 1; argv[i]; i++) {
if (strcmp(argv[i], "-v") == 0)
tstflags |= tst_verbatim;
else
usage();
}
retval |= test_quote(); fflush(stdout);
retval |= test_any(); fflush(stdout);
retval |= test_sip(); fflush(stdout);
retval |= test_wv(); fflush(stdout);
retval |= test_tel(); fflush(stdout);
retval |= test_fax(); fflush(stdout);
retval |= test_modem(); fflush(stdout);
retval |= test_file(); fflush(stdout);
retval |= test_rtsp(); fflush(stdout);
retval |= test_http(); fflush(stdout);
retval |= test_sanitizing(); fflush(stdout);
retval |= test_tags(); fflush(stdout);
retval |= test_print(); fflush(stdout);
return retval;
}
/* test unquoting and canonizing */
int test_quote(void)
{
......@@ -113,9 +70,6 @@ int test_quote(void)
#define UNWISE "{}|\\^[]`"
#define EXCLUDED RESERVED DELIMS UNWISE
char escaped[1 + 3 * 23 + 1];
#define UNRESERVED "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
......@@ -847,6 +801,44 @@ int test_tags(void)
END();
}
#include <su_tag_class.h>
int test_tag_filter(void)
{
BEGIN();
#undef TAG_NAMESPACE
#define TAG_NAMESPACE "test"
tag_typedef_t tag_a = STRTAG_TYPEDEF(a);
#define TAG_A(s) tag_a, tag_str_v((s))
tag_typedef_t tag_b = STRTAG_TYPEDEF(b);
#define TAG_B(s) tag_b, tag_str_v((s))
tagi_t filter[2] = {{ URLTAG_ANY() }, { TAG_END() }};
tagi_t *lst, *result;
lst = tl_list(TAG_A("X"),
TAG_SKIP(2),
URLTAG_URL((void *)"urn:foo"),
TAG_B("Y"),
URLTAG_URL((void *)"urn:bar"),
TAG_NULL());
TEST_1(lst);
result = tl_afilter(NULL, filter, lst);
TEST_1(result);
TEST(result[0].t_tag, urltag_url);
TEST(result[1].t_tag, urltag_url);
tl_vfree(lst);
free(result);
END();
}
#if 0
/* This is just a spike. How we can get
* register_printf_function('U', printf_url, printf_url_info)
......@@ -911,3 +903,35 @@ int test_print(void)
END();
}
int main(int argc, char *argv[])
{
int retval = 0;
int i;
for (i = 1; argv[i]; i++) {
if (strcmp(argv[i], "-v") == 0)
tstflags |= tst_verbatim;
else
usage();
}
retval |= test_quote(); fflush(stdout);
retval |= test_any(); fflush(stdout);
retval |= test_sip(); fflush(stdout);
retval |= test_wv(); fflush(stdout);
retval |= test_tel(); fflush(stdout);
retval |= test_fax(); fflush(stdout);
retval |= test_modem(); fflush(stdout);
retval |= test_file(); fflush(stdout);
retval |= test_rtsp(); fflush(stdout);
retval |= test_http(); fflush(stdout);
retval |= test_sanitizing(); fflush(stdout);
retval |= test_tags(); fflush(stdout);
retval |= test_print(); fflush(stdout);
retval |= test_tag_filter(); fflush(stdout);
return retval;
}
......@@ -41,6 +41,8 @@
#include <url.h>
tag_typedef_t urltag_any = NSTAG_TYPEDEF(*);
tag_typedef_t urltag_url = URLTAG_TYPEDEF(url);
int urltag_snprintf(tagi_t const *t, char b[], size_t size)
......
......@@ -44,6 +44,10 @@
SOFIA_BEGIN_DECLS
/** Filter tag matching any url tag. */
#define URLTAG_ANY() urltag_any, ((tag_value_t)0)
URL_DLL extern tag_typedef_t urltag_any;
URL_DLL extern tag_typedef_t urltag_url;
/** Tag list item for an URL. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment