|
|
|
@ -33,7 +33,8 @@ struct MmsMsg {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int encode_msgheaders(Octstr *os, List *hdrs);
|
|
|
|
|
static int decode_msgheaders(ParseContext *context, List *hdr, Octstr *from, int stop_on_ctype);
|
|
|
|
|
static int decode_msgheaders(ParseContext *context, List *hdr, Octstr *from, int stop_on_ctype,
|
|
|
|
|
char *unified_prefix, List *strip_prefixes);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static inline void pack_short_integer(Octstr *s, int ch)
|
|
|
|
@ -267,8 +268,9 @@ static Octstr *decode_encoded_string_value(int ret, ParseContext *context, unsig
|
|
|
|
|
* useful for unpacking msg type
|
|
|
|
|
*/
|
|
|
|
|
static int mms_unpack_well_known_field(List *unpacked, int field_type,
|
|
|
|
|
ParseContext *context,
|
|
|
|
|
Octstr *xfrom, int msgtype)
|
|
|
|
|
ParseContext *context,
|
|
|
|
|
Octstr *xfrom, int msgtype,
|
|
|
|
|
char *unified_prefix, List *strip_prefixes)
|
|
|
|
|
{
|
|
|
|
|
int val, ret;
|
|
|
|
|
unsigned char *hname = NULL;
|
|
|
|
@ -296,7 +298,8 @@ static int mms_unpack_well_known_field(List *unpacked, int field_type,
|
|
|
|
|
case MMS_HEADER_BCC:
|
|
|
|
|
if (ret == WSP_FIELD_VALUE_DATA)
|
|
|
|
|
decoded = decode_encoded_string_value(ret, context, hname);
|
|
|
|
|
|
|
|
|
|
if (decoded)
|
|
|
|
|
_mms_fixup_address(&decoded, unified_prefix, strip_prefixes, 1);
|
|
|
|
|
if (decoded == NULL || mms_validate_address(decoded))
|
|
|
|
|
warning(0, "Faulty address [%s] format in field %s!",
|
|
|
|
|
octstr_get_cstr(decoded), hname);
|
|
|
|
@ -464,14 +467,16 @@ static int mms_unpack_well_known_field(List *unpacked, int field_type,
|
|
|
|
|
else {
|
|
|
|
|
int n = parse_get_char(context);
|
|
|
|
|
|
|
|
|
|
if (n == 0x80) { /* Address present. */
|
|
|
|
|
if (n == 0x80) /* Address present. */
|
|
|
|
|
decoded = decode_encoded_string_value(-1,context, hname);
|
|
|
|
|
if (decoded == NULL ||
|
|
|
|
|
mms_validate_address(decoded))
|
|
|
|
|
warning(0, "Faulty address [%s] format in field %s!",
|
|
|
|
|
octstr_get_cstr(decoded), hname);
|
|
|
|
|
} else /* Insert address. */
|
|
|
|
|
else /* Insert address. */
|
|
|
|
|
decoded = octstr_duplicate(xfrom);
|
|
|
|
|
|
|
|
|
|
if (decoded)
|
|
|
|
|
_mms_fixup_address(&decoded, unified_prefix, strip_prefixes, 1);
|
|
|
|
|
if (decoded == NULL || mms_validate_address(decoded))
|
|
|
|
|
warning(0, "Faulty address [%s] format in field %s!",
|
|
|
|
|
octstr_get_cstr(decoded), hname);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MMS_HEADER_PREVIOUSLY_SENT_BY:
|
|
|
|
@ -603,7 +608,8 @@ static int mms_unpack_well_known_field(List *unpacked, int field_type,
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int decode_msgheaders(ParseContext *context, List *hdrs, Octstr *from, int stop_on_ctype)
|
|
|
|
|
static int decode_msgheaders(ParseContext *context, List *hdrs, Octstr *from,
|
|
|
|
|
int stop_on_ctype, char *unified_prefixes, List *strip_prefixes)
|
|
|
|
|
{
|
|
|
|
|
int fcont = 1;
|
|
|
|
|
int msgtype = 0;
|
|
|
|
@ -616,7 +622,8 @@ static int decode_msgheaders(ParseContext *context, List *hdrs, Octstr *from, in
|
|
|
|
|
int val = 0;
|
|
|
|
|
|
|
|
|
|
if (byte >= 0x80)
|
|
|
|
|
val = mms_unpack_well_known_field(hdrs, byte&0x7f, context, from, msgtype);
|
|
|
|
|
val = mms_unpack_well_known_field(hdrs, byte&0x7f, context, from, msgtype,
|
|
|
|
|
unified_prefixes, strip_prefixes);
|
|
|
|
|
else {
|
|
|
|
|
parse_skip(context, -1); /* Go back a bit. */
|
|
|
|
|
wsp_unpack_app_header(hdrs, context);
|
|
|
|
@ -1087,7 +1094,7 @@ mms_encoding mms_message_enc(MmsMsg *msg)
|
|
|
|
|
return msg->enc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MmsMsg *mms_frombinary(Octstr *msg, Octstr *from)
|
|
|
|
|
MmsMsg *mms_frombinary_ex(Octstr *msg, Octstr *from, char *unified_prefix, List *strip_prefixes)
|
|
|
|
|
{
|
|
|
|
|
int res = 0;
|
|
|
|
|
MmsMsg _m = {0}, *m = NULL;
|
|
|
|
@ -1101,7 +1108,7 @@ MmsMsg *mms_frombinary(Octstr *msg, Octstr *from)
|
|
|
|
|
mms_strings_init(); /* Just in case. */
|
|
|
|
|
|
|
|
|
|
_m.headers = gwlist_create();
|
|
|
|
|
decode_msgheaders(p, _m.headers, from, 1);
|
|
|
|
|
decode_msgheaders(p, _m.headers, from, 1, unified_prefix, strip_prefixes);
|
|
|
|
|
|
|
|
|
|
if (_m.headers == NULL ||
|
|
|
|
|
gwlist_len(_m.headers) == 0)
|
|
|
|
|