From dbe58bc2e04c4dbae282b0ff1ed5fea9a0d3c122 Mon Sep 17 00:00:00 2001 From: ekahn27 <50031375+ekahn27@users.noreply.github.com> Date: Thu, 15 Aug 2019 19:12:32 -0400 Subject: [PATCH 1/3] Update mms_pdu.py --- messaging/mms/mms_pdu.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/messaging/mms/mms_pdu.py b/messaging/mms/mms_pdu.py index ed44c46..5121ef6 100644 --- a/messaging/mms/mms_pdu.py +++ b/messaging/mms/mms_pdu.py @@ -994,3 +994,36 @@ def encode_status_value(status_value): # Return an unrecognised state if it couldn't be decoded return [status_values.get(status_value, 'Unrecognised')] + @staticmethod + def encode_expiry_value(expiry_value): + """ + Encodes the expiry value for an MMS message using a relative token + (delta time), not an absolute token (fixed date and time) + + encoding: [(total # of octets), (0x81), (# of octets in expiry value), (expiry value)] + + Param: expiry_value + Precondition: expiry_value must be an base 10 integer representing the number + of seconds until the MMSC should delete an unaccepted MMS message + + Returns: Encoded expiry value + rtype: list of ints + """ + assert type(expiry_value) == int + + encoded_expiry_value = [] + relativeToken = 129 + hexValue = hex(expiry_value)[2:] + length = len(hexValue) + + for x in range(length, 0, -2): + if x-2 < 0: + encoded_expiry_value.insert(0, int(hexValue[:x], 16)) + else: + encoded_expiry_value.insert(0, int(hexValue[x-2:x], 16)) + + encoded_expiry_value.insert(0, len(encoded_expiry_value)) + encoded_expiry_value.insert(0, relativeToken) + encoded_expiry_value.insert(0, len(encoded_expiry_value)) + + return encoded_expiry_value From 8ac9de9da8c910bcbb0c03bc561d464cfee35c5a Mon Sep 17 00:00:00 2001 From: ekahn27 <50031375+ekahn27@users.noreply.github.com> Date: Thu, 15 Aug 2019 19:13:08 -0400 Subject: [PATCH 2/3] Update mms_pdu.py --- messaging/mms/mms_pdu.py | 1 + 1 file changed, 1 insertion(+) diff --git a/messaging/mms/mms_pdu.py b/messaging/mms/mms_pdu.py index 5121ef6..76b5cf8 100644 --- a/messaging/mms/mms_pdu.py +++ b/messaging/mms/mms_pdu.py @@ -994,6 +994,7 @@ def encode_status_value(status_value): # Return an unrecognised state if it couldn't be decoded return [status_values.get(status_value, 'Unrecognised')] + @staticmethod def encode_expiry_value(expiry_value): """ From b1ac18d0ebde0b6cc5fb86649ed6bbc872b81454 Mon Sep 17 00:00:00 2001 From: Eric Kahn Date: Fri, 16 Aug 2019 11:03:43 -0400 Subject: [PATCH 3/3] Expiry value added --- messaging/mms/message.py | 1 + 1 file changed, 1 insertion(+) diff --git a/messaging/mms/message.py b/messaging/mms/message.py index 6cff8a0..651479a 100644 --- a/messaging/mms/message.py +++ b/messaging/mms/message.py @@ -36,6 +36,7 @@ def __init__(self): 'Message-Type': 'm-send-req', 'Transaction-Id': '1234', 'MMS-Version': '1.0', + 'Expiry': 3600 'Content-Type': ('application/vnd.wap.multipart.mixed', {}), } self.width = 176