summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2008-06-10 12:48:50 +0000
committerRussell Bryant <russell@russellbryant.com>2008-06-10 12:48:50 +0000
commitf4a8062e9316b065b9b83632ca2046d43b990538 (patch)
tree6628d8e6cf74abb51f1267effcf152b32c7401ba /include
parent74932445b78e728c1b9819e3e5da4d0c82e72645 (diff)
Merge another change from team/russell/events ...
DUNDi uses a concept called the Entity ID for unique server identifiers. I have pulled out the handling of EIDs and made it something available to all of Asterisk. There is now a global Entity ID that can be used for other purposes as well, such as code providing distributed device state, which is why I did this. The global Entity ID is set automatically, just like it was done in DUNDi, but it can also be set in asterisk.conf. DUNDi will now use this global EID unless one is specified in dundi.conf. The current EID for the system can be seen in the "core show settings" CLI command. It is also available in the dialplan via the ENTITYID variable. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@121439 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/dundi.h117
-rw-r--r--include/asterisk/utils.h42
2 files changed, 116 insertions, 43 deletions
diff --git a/include/asterisk/dundi.h b/include/asterisk/dundi.h
index e588338ae..c2a85493e 100644
--- a/include/asterisk/dundi.h
+++ b/include/asterisk/dundi.h
@@ -25,15 +25,11 @@
#define _ASTERISK_DUNDI_H
#include "asterisk/channel.h"
+#include "asterisk/utils.h"
#define DUNDI_PORT 4520
-/*!\brief A DUNDi Entity ID is essentially a MAC address, brief and unique */
-struct _dundi_eid {
- unsigned char eid[6];
-} __attribute__ ((__packed__));
-
-typedef struct _dundi_eid dundi_eid;
+typedef struct ast_eid dundi_eid;
struct dundi_hdr {
unsigned short strans; /*!< Source transaction */
@@ -54,26 +50,49 @@ struct dundi_ie_hdr {
#define DUNDI_FLAG_RETRANS (1 << 16) /*!< Applies to dtrans */
#define DUNDI_FLAG_RESERVED (1 << 16) /*!< Applies to strans */
-#define DUNDI_PROTO_NONE 0 /*!< No answer yet */
-#define DUNDI_PROTO_IAX 1 /*!< IAX version 2 */
-#define DUNDI_PROTO_SIP 2 /*!< Session Initiation Protocol */
-#define DUNDI_PROTO_H323 3 /*!< ITU H.323 */
-
-#define DUNDI_FLAG_NONEXISTENT (0) /*!< Isn't and can't be a valid number */
-#define DUNDI_FLAG_EXISTS (1 << 0) /*!< Is a valid number */
-#define DUNDI_FLAG_MATCHMORE (1 << 1) /*!< Might be valid if you add more digits */
-#define DUNDI_FLAG_CANMATCH (1 << 2) /*!< Might be a match */
-#define DUNDI_FLAG_IGNOREPAT (1 << 3) /*!< Keep dialtone */
-#define DUNDI_FLAG_RESIDENTIAL (1 << 4) /*!< Destination known to be residential */
-#define DUNDI_FLAG_COMMERCIAL (1 << 5) /*!< Destination known to be commercial */
-#define DUNDI_FLAG_MOBILE (1 << 6) /*!< Destination known to be cellular/mobile */
-#define DUNDI_FLAG_NOUNSOLICITED (1 << 7) /*!< No unsolicited calls of any kind through this route */
-#define DUNDI_FLAG_NOCOMUNSOLICIT (1 << 8) /*!< No commercial unsolicited calls through this route */
-
-#define DUNDI_HINT_NONE (0)
-#define DUNDI_HINT_TTL_EXPIRED (1 << 0) /*!< TTL Expired */
-#define DUNDI_HINT_DONT_ASK (1 << 1) /*!< Don't ask for anything beginning with data */
-#define DUNDI_HINT_UNAFFECTED (1 << 2) /*!< Answer not affected by entity list */
+enum {
+ /*! No answer yet */
+ DUNDI_PROTO_NONE = 0,
+ /*! IAX, version 2 */
+ DUNDI_PROTO_IAX = 1,
+ /*! SIP - Session Initiation Protocol, RFC 3261 */
+ DUNDI_PROTO_SIP = 2,
+ /*! ITU H.323 */
+ DUNDI_PROTO_H323 = 3,
+};
+
+enum {
+ /*! Isn't and can't be a valid number */
+ DUNDI_FLAG_NONEXISTENT = (0),
+ /*! Is a valid number */
+ DUNDI_FLAG_EXISTS = (1 << 0),
+ /*! Might be valid if you add more digits */
+ DUNDI_FLAG_MATCHMORE = (1 << 1),
+ /*! Might be a match */
+ DUNDI_FLAG_CANMATCH = (1 << 2),
+ /*! Keep dialtone */
+ DUNDI_FLAG_IGNOREPAT = (1 << 3),
+ /*! Destination known to be residential */
+ DUNDI_FLAG_RESIDENTIAL = (1 << 4),
+ /*! Destination known to be commercial */
+ DUNDI_FLAG_COMMERCIAL = (1 << 5),
+ /*! Destination known to be cellular/mobile */
+ DUNDI_FLAG_MOBILE = (1 << 6),
+ /*! No unsolicited calls of any kind through this route */
+ DUNDI_FLAG_NOUNSOLICITED = (1 << 7),
+ /*! No commercial unsolicited calls through this route */
+ DUNDI_FLAG_NOCOMUNSOLICIT = (1 << 8),
+};
+
+enum {
+ DUNDI_HINT_NONE = (0),
+ /*! TTL Expired */
+ DUNDI_HINT_TTL_EXPIRED = (1 << 0),
+ /*! Don't ask for anything beginning with data */
+ DUNDI_HINT_DONT_ASK = (1 << 1),
+ /*! Answer not affected by entity list */
+ DUNDI_HINT_UNAFFECTED = (1 << 2),
+};
struct dundi_encblock { /*!< AES-128 encrypted block */
unsigned char iv[16]; /*!< Initialization vector of random data */
@@ -93,14 +112,24 @@ struct dundi_hint {
unsigned char data[0]; /*!< For data for hint */
} __attribute__ ((__packed__));
-#define DUNDI_CAUSE_SUCCESS 0 /*!< Success */
-#define DUNDI_CAUSE_GENERAL 1 /*!< General unspecified failure */
-#define DUNDI_CAUSE_DYNAMIC 2 /*!< Requested entity is dynamic */
-#define DUNDI_CAUSE_NOAUTH 3 /*!< No or improper authorization */
-#define DUNDI_CAUSE_DUPLICATE 4 /*!< Duplicate request */
-#define DUNDI_CAUSE_TTL_EXPIRED 5 /*!< Expired TTL */
-#define DUNDI_CAUSE_NEEDKEY 6 /*!< Need new session key to decode */
-#define DUNDI_CAUSE_BADENCRYPT 7 /*!< Badly encrypted data */
+enum {
+ /*! Success */
+ DUNDI_CAUSE_SUCCESS = 0,
+ /*! General unspecified failure */
+ DUNDI_CAUSE_GENERAL = 1,
+ /*! Requested entity is dynamic */
+ DUNDI_CAUSE_DYNAMIC = 2,
+ /*! No or improper authorization */
+ DUNDI_CAUSE_NOAUTH = 3,
+ /*! Duplicate request */
+ DUNDI_CAUSE_DUPLICATE = 4,
+ /*! Expired TTL */
+ DUNDI_CAUSE_TTL_EXPIRED = 5,
+ /*! Need new session key to decode */
+ DUNDI_CAUSE_NEEDKEY = 6,
+ /*! Badly encrypted data */
+ DUNDI_CAUSE_BADENCRYPT = 7,
+};
struct dundi_cause {
unsigned char causecode; /*!< Numerical cause (DUNDI_CAUSE_*) */
@@ -114,14 +143,16 @@ struct dundi_peer_status {
dundi_eid peereid;
} __attribute__ ((__packed__));
-#define DUNDI_PEER_PRIMARY (1 << 0)
-#define DUNDI_PEER_SECONDARY (1 << 1)
-#define DUNDI_PEER_UNAVAILABLE (1 << 2)
-#define DUNDI_PEER_REGISTERED (1 << 3)
-#define DUNDI_PEER_MOD_OUTBOUND (1 << 4)
-#define DUNDI_PEER_MOD_INBOUND (1 << 5)
-#define DUNDI_PEER_PCMOD_OUTBOUND (1 << 6)
-#define DUNDI_PEER_PCMOD_INBOUND (1 << 7)
+enum {
+ DUNDI_PEER_PRIMARY = (1 << 0),
+ DUNDI_PEER_SECONDARY = (1 << 1),
+ DUNDI_PEER_UNAVAILABLE = (1 << 2),
+ DUNDI_PEER_REGISTERED = (1 << 3),
+ DUNDI_PEER_MOD_OUTBOUND = (1 << 4),
+ DUNDI_PEER_MOD_INBOUND = (1 << 5),
+ DUNDI_PEER_PCMOD_OUTBOUND = (1 << 6),
+ DUNDI_PEER_PCMOD_INBOUND = (1 << 7),
+};
#define DUNDI_COMMAND_FINAL (0x80) /*!< Or'd with other flags */
@@ -163,7 +194,7 @@ struct dundi_peer_status {
#define DUNDI_IE_SHAREDKEY 17 /*!< RSA encrypted AES-128 key */
#define DUNDI_IE_SIGNATURE 18 /*!< RSA Signature of encrypted shared key */
#define DUNDI_IE_KEYCRC32 19 /*!< CRC32 of encrypted key (int) */
-#define DUNDI_IE_HINT 20 /*!< Answer hints (struct ast_hint) */
+#define DUNDI_IE_HINT 20 /*!< Answer hints */
#define DUNDI_IE_DEPARTMENT 21 /*!< Department, for EIDQUERY (string) */
#define DUNDI_IE_ORGANIZATION 22 /*!< Organization, for EIDQUERY (string) */
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 074bc085d..0735babf1 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -671,4 +671,46 @@ static void force_inline _ast_assert(int condition, const char *condition_str,
#include "asterisk/strings.h"
+/*!
+ * \brief An Entity ID is essentially a MAC address, brief and unique
+ */
+struct ast_eid {
+ unsigned char eid[6];
+} __attribute__ ((__packed__));
+
+/*!
+ * \brief Global EID
+ *
+ * This is set in asterisk.conf, or determined automatically by taking the mac
+ * address of an Ethernet interface on the system.
+ */
+extern struct ast_eid g_eid;
+
+/*!
+ * \brief Fill in an ast_eid with the default eid of this machine
+ */
+void ast_set_default_eid(struct ast_eid *eid);
+
+/*!
+ * /brief Convert an EID to a string
+ */
+char *ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid);
+
+/*!
+ * \brief Convert a string into an EID
+ *
+ * This function expects an EID in the format:
+ * 00:11:22:33:44:55
+ *
+ * \return 0 success, non-zero failure
+ */
+int ast_str_to_eid(struct ast_eid *eid, const char *s);
+
+/*!
+ * \brief Compare two EIDs
+ *
+ * \return 0 if the two are the same, non-zero otherwise
+ */
+int ast_eid_cmp(const struct ast_eid *eid1, const struct ast_eid *eid2);
+
#endif /* _ASTERISK_UTILS_H */