• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1% TCPROS transport layer for ROS Melodic Morenia 1.14.5 dissection
2%
3% Copyright (C) Víctor Mayoral-Vilches <v.mayoralv@gmail.com>
4%
5% This program is free software; you can redistribute it and/or modify it under
6% the terms of the GNU General Public License as published by the Free Software
7% Foundation; either version 2 of the License, or (at your option) any later
8% version.
9%
10% This program is distributed in the hope that it will be useful, but WITHOUT ANY
11% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12% PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13%
14% You should have received a copy of the GNU General Public License along with
15% this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
16% Street, Fifth Floor, Boston, MA  02110-1301, USA.
17
18% TCPROS layer test campaign
19
20+ Syntax check
21= Import the RTPS layer
22from scapy.contrib.tcpros import *
23
24bind_layers(TCP, TCPROS, sport=11311)
25bind_layers(HTTPRequest, XMLRPC)
26bind_layers(HTTPResponse, XMLRPC)
27
28pkt =   b"POST /RPC2 HTTP/1.1\r\nAccept-Encoding: gzip\r\nContent-Length: " \
29        b"227\r\nContent-Type: text/xml\r\nHost: 12.0.0.2:11311\r\nUser-Agent:" \
30        b"xmlrpclib.py/1.0.1 (by www.pythonware.com)\r\n\r\n<?xml version=" \
31        b"'1.0'?>\n<methodCall>\n<methodName>shutdown</methodName>\n<params>" \
32        b"\n<param>\n<value><string>/rosparam-92418</string></value>\n" \
33        b"</param>\n<param>\n<value><string>BOOM</string></value>" \
34        b"\n</param>\n</params>\n</methodCall>\n"
35
36p = TCPROS(pkt)
37
38+ Test TCPROS
39= Test basic package composition
40assert(HTTP in p)
41assert(HTTPRequest in p)
42assert(XMLRPC in p)
43assert(XMLRPCCall in p)
44
45= Test HTTPRequest within TCPROS
46assert(p[HTTPRequest].Content_Length ==  b'227')
47assert(p[HTTPRequest].Content_Type ==  b'text/xml')
48assert(p[HTTPRequest].Host ==  b'12.0.0.2:11311')
49assert(p[HTTPRequest].User_Agent ==  b'xmlrpclib.py/1.0.1 (by www.pythonware.com)')
50assert(p[HTTPRequest].Method ==  b'POST')
51assert(p[HTTPRequest].Path ==  b'/RPC2')
52assert(p[HTTPRequest].Http_Version ==  b'HTTP/1.1')
53
54= Test XMLRPCCall within TCPROS
55assert(p[XMLRPCCall].version ==  b"<?xml version='1.0'?>\n")
56assert(p[XMLRPCCall].methodcall_opentag ==  b'<methodCall>\n')
57assert(p[XMLRPCCall].methodname ==  b'shutdown')
58assert(p[XMLRPCCall].params ==  b'<param>\n<value><string>/rosparam-92418</string></value>\n</param>\n<param>\n<value><string>BOOM</string></value>\n</param>\n')
59