mirror of
https://github.com/asterisk/asterisk.git
synced 2026-05-03 20:06:24 +00:00
Minor IAX2 fixes, add incomplete-but-very-basically-functional IAX2 encryption
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4595 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -205,6 +205,9 @@ static struct iax2_ie {
|
||||
{ IAX_IE_CALLINGTON, "CALLING TYPEOFNUM", dump_byte },
|
||||
{ IAX_IE_CALLINGTNS, "CALLING TRANSITNET", dump_short },
|
||||
{ IAX_IE_SAMPLINGRATE, "SAMPLINGRATE", dump_samprate },
|
||||
{ IAX_IE_CAUSECODE, "CAUSE CODE", dump_byte },
|
||||
{ IAX_IE_ENCRYPTION, "ENCRYPTION", dump_short },
|
||||
{ IAX_IE_ENCKEY, "ENCRYPTION KEY" },
|
||||
};
|
||||
|
||||
static struct iax2_ie prov_ies[] = {
|
||||
@@ -418,7 +421,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
||||
/* Don't mess with mini-frames */
|
||||
return;
|
||||
}
|
||||
if (fh->type > (int)sizeof(frames)/(int)sizeof(char *)) {
|
||||
if (fh->type > (int)sizeof(frames)/(int)sizeof(frames[0])) {
|
||||
snprintf(class2, (int)sizeof(class2), "(%d?)", fh->type);
|
||||
class = class2;
|
||||
} else {
|
||||
@@ -435,7 +438,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
|
||||
subclass = iaxs[(int)fh->csub];
|
||||
}
|
||||
} else if (fh->type == AST_FRAME_CONTROL) {
|
||||
if (fh->csub > (int)sizeof(cmds)/(int)sizeof(char *)) {
|
||||
if (fh->csub >= (int)sizeof(cmds)/(int)sizeof(cmds[0])) {
|
||||
snprintf(subclass2, (int)sizeof(subclass2), "(%d?)", fh->csub);
|
||||
subclass = subclass2;
|
||||
} else {
|
||||
@@ -612,6 +615,13 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
|
||||
} else
|
||||
ies->authmethods = ntohs(get_uint16(data + 2));
|
||||
break;
|
||||
case IAX_IE_ENCRYPTION:
|
||||
if (len != (int)sizeof(unsigned short)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expecting encryption to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
|
||||
errorf(tmp);
|
||||
} else
|
||||
ies->encmethods = ntohs(get_uint16(data + 2));
|
||||
break;
|
||||
case IAX_IE_CHALLENGE:
|
||||
ies->challenge = data + 2;
|
||||
break;
|
||||
@@ -715,6 +725,10 @@ int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen)
|
||||
ies->fwdata = data + 2;
|
||||
ies->fwdatalen = len;
|
||||
break;
|
||||
case IAX_IE_ENCKEY:
|
||||
ies->enckey = data + 2;
|
||||
ies->enckeylen = len;
|
||||
break;
|
||||
case IAX_IE_PROVVER:
|
||||
if (len != (int)sizeof(unsigned int)) {
|
||||
snprintf(tmp, (int)sizeof(tmp), "Expected provisioning version to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
|
||||
|
||||
Reference in New Issue
Block a user