[asterisk-dev] DUNDi transaction ID generation
Russell Bryant
russell at digium.com
Thu Nov 9 21:55:02 MST 2006
I'm just poking around pbx_dundi, and I can't seem to figure out this function
that generates a new transaction ID. A transaction ID in DUNDi is kind of like
a call number in IAX2. It is the identifier use to uniquely identify a session
between two peers.
The transaction ID is a 16-bit number. The DUNDi draft that Mark put together
when he wrote pbx_dundi says:
A transaction is uniquely identified at
each end by an arbitrary 16-bit transaction identifier from 1 to
65535 which SHOULD be selected as a random number for increased
security. Each message contains both a source and destination
transaction number so that a received message can be uniquely
identified by the transaction number alone. The transaction
identifier "0" is reserved for the destination transaction for the
opening message of a dialog, since the destination transaction is not
known at that time.
So, it seems that a valid transaction ID would be from 1 to 65535. However, the
function that generates the transaction ID uses a magic number, 32766, which I
can't determine the reasoning for. 32766 is 0x7FFE, which is basically 16 bits
with the high and low bit set to 0.
Any ideas?
References:
DUNDi protocol draft: http://www.dundi.com/dundi.txt
Relevant code:
static int get_trans_id(void)
{
struct dundi_transaction *t;
int stid = (ast_random() % 32766) + 1;
int tid = stid;
do {
AST_LIST_TRAVERSE(&alltrans, t, all) {
if (t->strans == tid)
break;
}
if (!t)
return tid;
tid = (tid % 32766) + 1;
} while (tid != stid);
return 0;
}
--
Russell Bryant
Software Engineer
Digium, Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: russell.vcf
Type: text/x-vcard
Size: 266 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20061109/e772c5c9/russell.vcf
More information about the asterisk-dev
mailing list