SIP Witch 1.9.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mapped.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
2 // Copyright (C) 2015 Cherokees of Idaho.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
24 #ifndef _SIPWITCH_MAPPED_H_
25 #define _SIPWITCH_MAPPED_H_
26 
27 #ifndef _SIPWITCH_NAMESPACE_H_
28 #include <sipwitch/namespace.h>
29 #endif
30 
31 #ifndef _SIPWITCH_VOIP_H_
32 #include <sipwitch/voip.h>
33 #endif
34 
35 #ifndef _SIPWITCH_STATS_H_
36 #include <sipwitch/stats.h>
37 #endif
38 
47 // user and device properties...
48 
49 #define USER_PROFILE_DIALABLE 0x0001 // user may be dialed
50 #define USER_PROFILE_REACHABLE 0x0002 // user may be reached by gateway
51 #define USER_PROFILE_INTERNAL 0x0008 // user may use dialing/routing
52 #define USER_PROFILE_SUBSCRIPTIONS 0x0010 // user can subscribe to others
53 #define USER_PROFILE_SUBSCRIBERS 0x0020 // user can be subscribed
54 #define USER_PROFILE_INCOMING 0x1000 // user "name" id may be accessed
55 #define USER_PROFILE_OUTGOING 0x2000 // may use generic uri
56 #define USER_PROFILE_SUPERUSER 0x8000 // has admin flag
57 
58 #define USER_PROFILE_ADMIN 0xffff
59 #define USER_PROFILE_LOCAL 0x0fff
60 #define USER_PROFILE_DEVICE 0x0f0f
61 #define USER_PROFILE_SERVICE 0x7f0f
62 #define USER_PROFILE_SYSTEM 0x2f08
63 #define USER_PROFILE_DEFAULT 0x7fff
64 #define USER_PROFILE_RESTRICTED (0)
65 
66 #define MAX_NETWORK_SIZE 16 // based on cidr name size...
67 #define MAX_PATTERN_SIZE 16
68 #define MAX_DISPLAY_SIZE 64
69 #define MAX_USERID_SIZE 48
70 #define MAX_IDENT_SIZE (MAX_USERID_SIZE + 50)
71 #define MAX_URI_SIZE 256
72 #define MAX_SDP_BUFFER 1024
73 
74 namespace sipwitch {
75 
76 #define CALL_MAP "sipwitch.calls"
77 #define REGISTRY_MAP "sipwitch.regs"
78 
83 typedef struct {
84  char id[MAX_USERID_SIZE];
85  unsigned short features;
86  unsigned level;
87 } profile_t;
88 
96 {
97 public:
98  typedef enum {OFFLINE = 0, IDLE, BUSY, AWAY, DND} status_t;
99 
106  bool hidden;
107  voip::reg_t rid; // registry remap or peer id
108  unsigned ext; // 0 or extnum
109  unsigned count; // active regs count
110  volatile unsigned inuse; // in use for call count
111  sockaddr_internet contact; // last/newest created contact registration
112  time_t created; // initial registration
113  volatile time_t expires; // when registry expires as a whole
114  profile_t profile; // profile at time of registration
115  union {
116  struct { // external registry properties...
117  const char *identity; // forced identity string when calling
118  const char *connect; // invite uri host identity
119  stats *statnode; // associated stat node...
120  } external;
121  struct { // internal registry properties
122  LinkedObject *published; // published routes
123  LinkedObject *targets; // active registrations (can be multiple)
124  LinkedObject *routes; // active route records
125  } internal;
126  } source;
127 
128  inline bool is_user(void) const
129  {return (type == USER);}
130 
131  inline bool is_profiled(void) const
132  {return (type == USER || type == SERVICE);}
133 
134  inline bool is_admin(void) const
136 
137  inline bool has_feature(unsigned short X) const
138  {return is_profiled() && (profile.features & X);}
139 };
140 
147 class MappedCall : public LinkedObject
148 {
149 public:
150  time_t created;
151  time_t active;
152  char state[16];
156  uint32_t sequence;
157  int cid;
158 };
159 
160 } // namespace sipwitch
161 
162 #endif
A stat element of call traffic.
Definition: stats.h:57
char display[64]
Definition: mapped.h:155
const char * identity
Definition: mapped.h:117
#define USER_PROFILE_SUPERUSER
Definition: mapped.h:56
User profiles are used to map features and toll restriction level together under a common identifier...
Definition: mapped.h:83
bool is_user(void) const
Definition: mapped.h:128
unsigned short features
Definition: mapped.h:85
Representation of a mapped active user record.
Definition: mapped.h:95
const char * connect
Definition: mapped.h:118
sockaddr_internet contact
Definition: mapped.h:111
uint32_t sequence
Definition: mapped.h:156
volatile time_t expires
Definition: mapped.h:113
bool is_profiled(void) const
Definition: mapped.h:131
LinkedObject * targets
Definition: mapped.h:123
union sipwitch::MappedRegistry::@6 source
char state[16]
Definition: mapped.h:152
Basic server call statistics.
char target[(48+50)]
Definition: mapped.h:154
char authorized[48]
Definition: mapped.h:153
bool has_feature(unsigned short X) const
Definition: mapped.h:137
GNU SIP Witch library namespace.
#define MAX_IDENT_SIZE
Definition: mapped.h:70
Representation of an active call record.
Definition: mapped.h:147
#define MAX_USERID_SIZE
Definition: mapped.h:69
bool is_admin(void) const
Definition: mapped.h:134
LinkedObject * published
Definition: mapped.h:122
LinkedObject * routes
Definition: mapped.h:124
struct sipwitch::MappedRegistry::@6::@7 external
unsigned level
Definition: mapped.h:86
int reg_t
Definition: voip.h:59
char source[(48+50)]
Definition: mapped.h:154
#define MAX_DISPLAY_SIZE
Definition: mapped.h:68
volatile unsigned inuse
Definition: mapped.h:110
#define MAX_NETWORK_SIZE
Definition: mapped.h:66
enum sipwitch::MappedRegistry::@5 type