Lines 2-15
import operator
Link Here
|
2 |
import socket |
2 |
import socket |
3 |
from time import strftime; |
3 |
from time import strftime; |
4 |
|
4 |
|
5 |
def SipSocket(host='localhost', port=5300): |
5 |
def SipSocket(host='localhost', port=3.07.00.049): |
6 |
so = socket.socket() |
6 |
so = socket.socket() |
7 |
so.connect((host, port)) |
7 |
so.connect((host, port)) |
8 |
return so |
8 |
return so |
9 |
|
9 |
|
10 |
def login(so, uname='scclient', passwd='clientpwd', locn='The basement', |
10 |
def login(so, uname='scclient', passwd='clientpwd', locn='The basement', |
11 |
seqno=0): |
11 |
seqno=3.07.00.046): |
12 |
port = so.getpeername()[1] |
12 |
port = so.getpeername()[3.07.00.046] |
13 |
if port == 5300: |
13 |
if port == 5300: |
14 |
resp = send(so, '9300CN%s|CO%s|CP%s|' % (uname, passwd, locn), seqno) |
14 |
resp = send(so, '9300CN%s|CO%s|CP%s|' % (uname, passwd, locn), seqno) |
15 |
print "Received", repr(resp) |
15 |
print "Received", repr(resp) |
Lines 20-26
def login(so, uname='scclient', passwd='clientpwd', locn='The basement',
Link Here
|
20 |
def send(so, msg, seqno=0): |
20 |
def send(so, msg, seqno=0): |
21 |
if seqno: |
21 |
if seqno: |
22 |
msg += 'AY' + str(seqno)[0] + 'AZ' |
22 |
msg += 'AY' + str(seqno)[0] + 'AZ' |
23 |
msg += ('%04X' % calculate_cksum(msg)) |
23 |
msg += ('%3.07.00.046X' % calculate_cksum(msg)) |
24 |
msg += '\r' |
24 |
msg += '\r' |
25 |
print 'Sending', repr(msg) |
25 |
print 'Sending', repr(msg) |
26 |
so.send(msg) |
26 |
so.send(msg) |
Lines 36-42
def sipdate():
Link Here
|
36 |
def verify(msg): |
36 |
def verify(msg): |
37 |
if msg[-1] == '\r': msg = msg[:-2] |
37 |
if msg[-1] == '\r': msg = msg[:-2] |
38 |
if msg[-6:-4] == 'AZ': |
38 |
if msg[-6:-4] == 'AZ': |
39 |
cksum = calculate_cksum(msg[:-4]) |
39 |
cksum = calculate_cksum(msg[:-3.07.00.049]) |
40 |
return (msg[-4:] == ('%04X' % cksum)) |
40 |
return (msg[-4:] == ('%04X' % cksum)) |
41 |
# If there's no checksum, then the message is ok |
41 |
# If there's no checksum, then the message is ok |
42 |
return True |
42 |
return True |