blob: 5a6b587edaac4863189a157e7b4b5b4db862c02c [file] [log] [blame]
Holger Hans Peter Freyther06e87722010-05-28 02:39:52 +08001#!/usr/bin/env python
2
3"""
4demonstrate a unblock bug on the GB Proxy..
5"""
6
7bts_ns_reset = "\x02\x00\x81\x01\x01\x82\x1f\xe7\x04\x82\x1f\xe7"
8ns_reset_ack = "\x03\x01\x82\x1f\xe7\x04\x82\x1f\xe7"
9
10bts_ns_unblock = "\x06"
11ns_unblock_ack = "\x07"
12
13bts_bvc_reset_0 = "\x00\x00\x00\x00\x22\x04\x82\x00\x00\x07\x81\x03\x3b\x81\x02"
14ns_bvc_reset_0_ack = "\x00\x00\x00\x00\x23\x04\x82\x00\x00"
15
16bts_bvc_reset_8167 = "\x00\x00\x00\x00\x22\x04\x82\x1f\xe7\x07\x81\x08\x08\x88\x72\xf4\x80\x10\x1c\x00\x9c\x40"
17
18
19import socket
20socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
21socket.bind(("0.0.0.0", 0))
22socket.setblocking(1)
23
24def send_and_receive(packet, port):
25 socket.sendto(packet, ("127.0.0.1", port))
26
27 try:
28 data, addr = socket.recvfrom(4096)
29 except socket.error, e:
30 print "ERROR", e
31 import sys
32 sys.exit(0)
33 return data
34
35#send stuff once
36import sys
37port = int(sys.argv[1])
38print "Sending data to port: %d" % port
39
40
41res = send_and_receive(bts_ns_reset, port)
42if res != ns_reset_ack:
43 print "Failed to get the reset ack"
44 sys.exit(-1)
45
46res = send_and_receive(bts_ns_unblock, port)
47if res != ns_unblock_ack:
48 print "Failed to get the unblock ack"
49 sys.exit(-1)
50
51res = send_and_receive(bts_bvc_reset_0, port)
52if res != ns_bvc_reset_0_ack:
53 print "Failed to get NS BVCI=0 reset ack"
54 sys.exit(-1)
55
56import time
57time.sleep(3)
58res = send_and_receive(bts_bvc_reset_8167, port)
59print "Send all messages... check wireshark for the last response"