# Path: sippy/SipGenericHF.py
# class SipGenericHF(object):
#     hf_names = None	# Set this in each subclass!!
#     body = None
#     parsed = False
# 
#     def __init__(self, body, name = None):
#         self.body = body
#         if name != None:
#             self.hf_names = (name.lower(),)
# 
#     def parse(self):
#         pass
# 
#     def localStr(self, local_addr = None, local_port = None):
#         return self.__str__()
# 
#     def __str__(self):
#         return self.body
# 
#     def getCopy(self):
#         return self.__class__(self.body)
# 
#     def getCanName(self, name, compact = False):
#         return name.capitalize()


from random import random
from hashlib import md5
from time import time
from math import floor
from sippy.SipConf import SipConf
from sippy.SipGenericHF import SipGenericHF
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


CALL_ID_CHARSET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.!%*_+`\'~()<>:\\"/[]?{}'
_clen = len(CALL_ID_CHARSET)
DEFAULT_TEST_LEN = (32, 16)

def gen_test_cid(lens = DEFAULT_TEST_LEN):
    r = ''
    for j in (0, 1):
        for i in range(0, lens[j]):
            r += CALL_ID_CHARSET[int(floor(random() * _clen))]
        if j == 0:
            r += '@'
    return r


# Path: sippy/SipGenericHF.py
# class SipGenericHF(object):
#     hf_names = None	# Set this in each subclass!!
#     body = None
#     parsed = False
# 
#     def __init__(self, body, name = None):
#         self.body = body
#         if name != None:
#             self.hf_names = (name.lower(),)
# 
#     def parse(self):
#         pass
# 
#     def localStr(self, local_addr = None, local_port = None):
#         return self.__str__()
# 
#     def __str__(self):
#         return self.body
# 
#     def getCopy(self):
#         return self.__class__(self.body)
# 
#     def getCanName(self, name, compact = False):
#         return name.capitalize()


# Path: sippy/SipCallId.py
from random import random
from hashlib import md5
from time import time
from math import floor
from sippy.SipConf import SipConf
from sippy.SipGenericHF import SipGenericHF

#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


CALL_ID_CHARSET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.!%*_+`\'~()<>:\\"/[]?{}'
_clen = len(CALL_ID_CHARSET)
DEFAULT_TEST_LEN = (32, 16)

def gen_test_cid(lens = DEFAULT_TEST_LEN):
    r = ''
    for j in (0, 1):
        for i in range(0, lens[j]):
            r += CALL_ID_CHARSET[int(floor(random() * _clen))]
        if j == 0:
            r += '@'
    return r


class SipCallId(SipGenericHF):