dundi.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _ASTERISK_DUNDI_H
00025 #define _ASTERISK_DUNDI_H
00026
00027 #include "asterisk/channel.h"
00028 #include "asterisk/utils.h"
00029
00030 #define DUNDI_PORT 4520
00031
00032 typedef struct ast_eid dundi_eid;
00033
00034 struct dundi_hdr {
00035 unsigned short strans;
00036 unsigned short dtrans;
00037 unsigned char iseqno;
00038 unsigned char oseqno;
00039 unsigned char cmdresp;
00040 unsigned char cmdflags;
00041 unsigned char ies[0];
00042 } __attribute__((__packed__));
00043
00044 struct dundi_ie_hdr {
00045 unsigned char ie;
00046 unsigned char len;
00047 unsigned char iedata[0];
00048 } __attribute__((__packed__));
00049
00050 #define DUNDI_FLAG_RETRANS (1 << 16)
00051 #define DUNDI_FLAG_RESERVED (1 << 16)
00052
00053 enum {
00054
00055 DUNDI_PROTO_NONE = 0,
00056
00057 DUNDI_PROTO_IAX = 1,
00058
00059 DUNDI_PROTO_SIP = 2,
00060
00061 DUNDI_PROTO_H323 = 3,
00062 };
00063
00064 enum {
00065
00066 DUNDI_FLAG_NONEXISTENT = (0),
00067
00068 DUNDI_FLAG_EXISTS = (1 << 0),
00069
00070 DUNDI_FLAG_MATCHMORE = (1 << 1),
00071
00072 DUNDI_FLAG_CANMATCH = (1 << 2),
00073
00074 DUNDI_FLAG_IGNOREPAT = (1 << 3),
00075
00076 DUNDI_FLAG_RESIDENTIAL = (1 << 4),
00077
00078 DUNDI_FLAG_COMMERCIAL = (1 << 5),
00079
00080 DUNDI_FLAG_MOBILE = (1 << 6),
00081
00082 DUNDI_FLAG_NOUNSOLICITED = (1 << 7),
00083
00084 DUNDI_FLAG_NOCOMUNSOLICIT = (1 << 8),
00085 };
00086
00087 enum {
00088 DUNDI_HINT_NONE = (0),
00089
00090 DUNDI_HINT_TTL_EXPIRED = (1 << 0),
00091
00092 DUNDI_HINT_DONT_ASK = (1 << 1),
00093
00094 DUNDI_HINT_UNAFFECTED = (1 << 2),
00095 };
00096
00097 struct dundi_encblock {
00098 unsigned char iv[16];
00099 unsigned char encdata[0];
00100 } __attribute__((__packed__));
00101
00102 struct dundi_answer {
00103 dundi_eid eid;
00104 unsigned char protocol;
00105 unsigned short flags;
00106 unsigned short weight;
00107 unsigned char data[0];
00108 } __attribute__((__packed__));
00109
00110 struct dundi_hint {
00111 unsigned short flags;
00112 unsigned char data[0];
00113 } __attribute__((__packed__));
00114
00115 enum {
00116
00117 DUNDI_CAUSE_SUCCESS = 0,
00118
00119 DUNDI_CAUSE_GENERAL = 1,
00120
00121 DUNDI_CAUSE_DYNAMIC = 2,
00122
00123 DUNDI_CAUSE_NOAUTH = 3,
00124
00125 DUNDI_CAUSE_DUPLICATE = 4,
00126
00127 DUNDI_CAUSE_TTL_EXPIRED = 5,
00128
00129 DUNDI_CAUSE_NEEDKEY = 6,
00130
00131 DUNDI_CAUSE_BADENCRYPT = 7,
00132 };
00133
00134 struct dundi_cause {
00135 unsigned char causecode;
00136 char desc[0];
00137 } __attribute__((__packed__));
00138
00139 struct dundi_peer_status {
00140 unsigned int flags;
00141 unsigned short netlag;
00142 unsigned short querylag;
00143 dundi_eid peereid;
00144 } __attribute__((__packed__));
00145
00146 enum {
00147 DUNDI_PEER_PRIMARY = (1 << 0),
00148 DUNDI_PEER_SECONDARY = (1 << 1),
00149 DUNDI_PEER_UNAVAILABLE = (1 << 2),
00150 DUNDI_PEER_REGISTERED = (1 << 3),
00151 DUNDI_PEER_MOD_OUTBOUND = (1 << 4),
00152 DUNDI_PEER_MOD_INBOUND = (1 << 5),
00153 DUNDI_PEER_PCMOD_OUTBOUND = (1 << 6),
00154 DUNDI_PEER_PCMOD_INBOUND = (1 << 7),
00155 };
00156
00157 #define DUNDI_COMMAND_FINAL (0x80)
00158
00159 #define DUNDI_COMMAND_ACK (0 | 0x40)
00160 #define DUNDI_COMMAND_DPDISCOVER 1
00161 #define DUNDI_COMMAND_DPRESPONSE (2 | 0x40)
00162 #define DUNDI_COMMAND_EIDQUERY 3
00163 #define DUNDI_COMMAND_EIDRESPONSE (4 | 0x40)
00164 #define DUNDI_COMMAND_PRECACHERQ 5
00165 #define DUNDI_COMMAND_PRECACHERP (6 | 0x40)
00166 #define DUNDI_COMMAND_INVALID (7 | 0x40)
00167 #define DUNDI_COMMAND_UNKNOWN (8 | 0x40)
00168 #define DUNDI_COMMAND_NULL 9
00169 #define DUNDI_COMMAND_REGREQ (10)
00170 #define DUNDI_COMMAND_REGRESPONSE (11 | 0x40)
00171 #define DUNDI_COMMAND_CANCEL (12)
00172 #define DUNDI_COMMAND_ENCRYPT (13)
00173 #define DUNDI_COMMAND_ENCREJ (14 | 0x40)
00174
00175 #define DUNDI_COMMAND_STATUS 15
00176
00177
00178
00179
00180
00181
00182 #define DUNDI_IE_EID 1
00183 #define DUNDI_IE_CALLED_CONTEXT 2
00184 #define DUNDI_IE_CALLED_NUMBER 3
00185 #define DUNDI_IE_EID_DIRECT 4
00186 #define DUNDI_IE_ANSWER 5
00187 #define DUNDI_IE_TTL 6
00188 #define DUNDI_IE_VERSION 10
00189 #define DUNDI_IE_EXPIRATION 11
00190 #define DUNDI_IE_UNKNOWN 12
00191 #define DUNDI_IE_CAUSE 14
00192 #define DUNDI_IE_REQEID 15
00193 #define DUNDI_IE_ENCDATA 16
00194 #define DUNDI_IE_SHAREDKEY 17
00195 #define DUNDI_IE_SIGNATURE 18
00196 #define DUNDI_IE_KEYCRC32 19
00197 #define DUNDI_IE_HINT 20
00198
00199 #define DUNDI_IE_DEPARTMENT 21
00200 #define DUNDI_IE_ORGANIZATION 22
00201 #define DUNDI_IE_LOCALITY 23
00202 #define DUNDI_IE_STATE_PROV 24
00203 #define DUNDI_IE_COUNTRY 25
00204 #define DUNDI_IE_EMAIL 26
00205 #define DUNDI_IE_PHONE 27
00206 #define DUNDI_IE_IPADDR 28
00207 #define DUNDI_IE_CACHEBYPASS 29
00208
00209 #define DUNDI_IE_PEERSTATUS 30
00210
00211 #define DUNDI_FLUFF_TIME 2000
00212 #define DUNDI_TTL_TIME 200
00213
00214 #define DUNDI_DEFAULT_RETRANS 5
00215 #define DUNDI_DEFAULT_RETRANS_TIMER 1000
00216 #define DUNDI_DEFAULT_TTL 120
00217 #define DUNDI_DEFAULT_VERSION 1
00218 #define DUNDI_DEFAULT_CACHE_TIME 3600
00219 #define DUNDI_DEFAULT_KEY_EXPIRE 3600
00220 #define DUNDI_DEF_EMPTY_CACHE_TIME 60
00221 #define DUNDI_WINDOW 1
00222
00223 #define DEFAULT_MAXMS 2000
00224
00225 struct dundi_result {
00226 unsigned int flags;
00227 int weight;
00228 int expiration;
00229 int techint;
00230 dundi_eid eid;
00231 char eid_str[20];
00232 char tech[10];
00233 char dest[256];
00234 };
00235
00236 struct dundi_entity_info {
00237 char country[80];
00238 char stateprov[80];
00239 char locality[80];
00240 char org[80];
00241 char orgunit[80];
00242 char email[80];
00243 char phone[80];
00244 char ipaddr[80];
00245 };
00246
00247
00248
00249
00250
00251
00252
00253
00254 int dundi_lookup(struct dundi_result *result, int maxret, struct ast_channel *chan, const char *dcontext, const char *number, int nocache);
00255
00256
00257 int dundi_query_eid(struct dundi_entity_info *dei, const char *dcontext, dundi_eid eid);
00258
00259
00260 int dundi_precache(const char *dcontext, const char *number);
00261
00262 #endif