SIP Witch 1.9.15
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
uri.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 
26 #ifndef _SIPWITCH_URI_H_
27 #define _SIPWITCH_URI_H_
28 
29 #ifndef _UCOMMON_STRING_H_
30 #include <ucommon/string.h>
31 #endif
32 
33 #ifndef _UCOMMON_PLATFORM_H_
34 #include <ucommon/platform.h>
35 #endif
36 
37 #ifndef _UCOMMON_SOCKET_H_
38 #include <ucommon/socket.h>
39 #endif
40 
41 #ifndef __SIPWITCH_NAMESPACE_H_
42 #include <sipwitch/namespace.h>
43 #endif
44 
45 #ifndef __SIPWITCH_VOIP_H_
46 #include <sipwitch/voip.h>
47 #endif
48 
49 namespace sipwitch {
50 
55 class __EXPORT uri
56 {
57 public:
58  static voip::context_t route(const char *uri, char *buf, size_t size);
59  static void serviceid(const char *sipuri, char *buffer, size_t size);
60  static bool server(struct sockaddr *address, char *buffer, size_t size);
61  static bool userid(const char *sipuri, char *buffer, size_t size);
62  static bool hostid(const char *sipuri, char *buffer, size_t size);
63  static unsigned short portid(const char *sipuri);
64  static void identity(const struct sockaddr *address, char *buffer, const char *user, size_t size);
65  static void publish(const char *uri, char *buffer, const char *user, size_t size);
66  static voip::context_t context(const char *uri);
67 };
68 
69 class __EXPORT srv : protected Socket::address
70 {
71 public:
72  class address
73  {
74  public:
75  struct sockaddr_storage addr;
76  uint16_t weight, priority;
77  };
78 
79 protected:
81  struct sockaddr *entry;
82  uint16_t pri;
83  unsigned count;
84 
85 public:
86  srv(const char *uri);
87  srv();
88  ~srv();
89 
90  void set(const char *uri);
91 
92  void clear(void);
93 
94  inline struct sockaddr *operator*() const
95  {return entry;}
96 
97  inline operator bool() const
98  {return entry != NULL;}
99 
100  inline bool operator!() const
101  {return entry == NULL;}
102 
103  struct sockaddr *next(void);
104 
105  uint16_t after(uint16_t priority = 0);
106 
107  uint32_t total(uint16_t priority);
108 
109  struct sockaddr *find(uint16_t priority, uint32_t weight);
110 
111  voip::context_t route(const char *uri, char *buf, size_t size);
112 
113 };
114 
115 } // namespace sipwitch
116 
117 #endif
Some convenience methods for manipulating SIP uri's.
Definition: uri.h:55
struct sockaddr * entry
Definition: uri.h:81
uint16_t pri
Definition: uri.h:82
bool operator!() const
Definition: uri.h:100
GNU SIP Witch library namespace.
address * srvlist
Definition: uri.h:80
struct sockaddr * operator*() const
Definition: uri.h:94
unsigned count
Definition: uri.h:83
uint16_t weight
Definition: uri.h:76
void * context_t
Definition: voip.h:53