common_policy.h

00001 /* 
00002  * Copyright (C) 2005 iptelorg GmbH
00003  *
00004  * This file is part of ser, a free SIP server.
00005  *
00006  * ser is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version
00010  *
00011  * For a license to use the ser software under conditions
00012  * other than those described here, or to purchase support for this
00013  * software, please contact iptel.org by e-mail at the following addresses:
00014  *    info@iptel.org
00015  *
00016  * ser is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  */
00025 
00026 #ifndef __COMMON_POLICY
00027 #define __COMMON_POLICY
00028 
00029 #include <cds/sstr.h>
00030 #include <time.h>
00031 
00032 typedef struct {
00033         time_t from;
00034         time_t to;
00035 } cp_validity_t;
00036 
00037 typedef struct _cp_domain_t {
00038         struct _cp_domain_t *next;
00039         str_t domain;
00040 } cp_domain_t;
00041 
00042 typedef struct _cp_except_domain_t {
00043         struct _cp_except_domain_t *next;
00044         str_t domain;
00045 } cp_except_domain_t;
00046 
00047 typedef struct _cp_except_t {
00048         struct _cp_except_t *next;
00049         str_t entity;
00050 } cp_except_t;
00051 
00052 typedef struct _cp_unknown_t {
00053         struct _cp_unknown_t *next;
00054 
00055         char data[1]; /* elements from external schemes */
00056 } cp_unknown_t;
00057 
00058 typedef struct {
00059         cp_unknown_t *unknown; /* elements from external schemes */
00060 } cp_actions_t;
00061 
00062 typedef struct {
00063         cp_unknown_t *unknown; /* elements from external schemes */
00064 } cp_transformations_t;
00065 
00066 typedef struct _cp_id_t {
00067         struct _cp_id_t *next;
00068         str_t entity;
00069 } cp_id_t;
00070 
00071 typedef struct {
00072         cp_domain_t *domains;
00073         cp_except_domain_t *except_domains;
00074 } cp_any_identity_t;
00075 
00076 typedef struct {
00077         cp_id_t *ids;
00078         cp_domain_t *domains;
00079         cp_except_t *excepts;
00080         cp_any_identity_t *any_identity;
00081 } cp_identity_t;
00082 
00083 typedef struct _cp_sphere_t {
00084         struct _cp_sphere_t *next;
00085         str_t value;
00086 } cp_sphere_t;
00087 
00088 typedef struct {
00089         cp_validity_t *validity;
00090         cp_identity_t *identity;
00091         cp_sphere_t *spheres;
00092 } cp_conditions_t;
00093 
00094 typedef struct _cp_rule_t {
00095         struct _cp_rule_t *next;
00096                 
00097         cp_conditions_t *conditions;
00098         cp_actions_t *actions;
00099         cp_transformations_t *transformations;
00100         str_t id;
00101 } cp_rule_t;
00102 
00103 typedef struct {
00104         cp_rule_t *rules;
00105 } cp_ruleset_t;
00106 
00107 cp_unknown_t *create_unknown(int data_size);
00108 
00109 typedef void (cp_free_actions_func)(cp_actions_t *a);
00110 
00111 void free_cp_rule(cp_rule_t *r, cp_free_actions_func free_actions);
00112 void free_common_rules(cp_ruleset_t *r, cp_free_actions_func free_actions);
00113 int is_rule_for_uri(cp_rule_t *rule, const str_t *uri);
00114 
00115 #endif