summaryrefslogtreecommitdiff
path: root/cesar/maximus/python/lib/proto/fcall.py
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/python/lib/proto/fcall.py')
-rw-r--r--cesar/maximus/python/lib/proto/fcall.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/cesar/maximus/python/lib/proto/fcall.py b/cesar/maximus/python/lib/proto/fcall.py
index 909dcce556..c9ee449804 100644
--- a/cesar/maximus/python/lib/proto/fcall.py
+++ b/cesar/maximus/python/lib/proto/fcall.py
@@ -17,7 +17,7 @@ from scapy import *
from uuid import getnode
# Constants
-FUNCTION_CALL_VERSION = 0x03
+FUNCTION_CALL_VERSION = 0x02
FUNCTION_CALL_FLAG_FAILED = 0x01
FUNCTION_CALL_TYPE_REQ = 0x01
FUNCTION_CALL_TYPE_RSP = 0x02
@@ -33,6 +33,11 @@ SIZE_OF_TYPE = SIZE_OF_U16 # in octets
SIZE_OF_MMV = 1 # in octets
SIZE_OF_MMTYPE = 2 # in octets
SIZE_OF_FMI = 2 # in octets
+INTERFACE_FCALL_PAYLOAD_OFFSET = 22 # in octets
+
+# For unitary test purpose
+FUNCTION_CALL_WRITE_FILE = "/tmp/proto_in"
+FUNCTION_CALL_READ_FILE = "/tmp/proto_out"
class Param:
@@ -240,7 +245,7 @@ class Fcall:
# Interface sub-module (1 octet)
# Payload length (2 octets)
#
- mmentry = htohp8(INTERFACE_MODULE_FCALL) + htohp16(len(fcall_data))
+ mmentry = htohp8(INTERFACE_MODULE_FCALL) + htohp16(len(fcall_hdr + fcall_data))
return mmentry + fcall_hdr + fcall_data
@@ -268,10 +273,7 @@ class Fcall:
# In case of unitary test
else:
print "Sending an MME..."
- display(mme)
- file = open("/tmp/" + FUNCTION_CALL_NETWORK_INTERFACE + ".txt", 'w+')
- file.write(str(mme))
- file.close()
+ os.write(self.__maximus.write_file, str(mme))
def display(mme):
try:
@@ -323,7 +325,7 @@ def display(mme):
end += SIZE_OF_U16
print "reserved =", hex(hptoh16(mme.payload.load[begin:end]))
- print "Fcall Payload:", mme.payload.load[end:]
+ print "Fcall Payload:"
print "payload =",
for i in range(16, len(mme.payload.load)):
print hex(hptoh8(mme.payload.load[i])),
@@ -340,12 +342,14 @@ def read_param_name(data):
return read_name(data)
def read_param_length(data):
- return hptoh16(data[:SIZE_OF_U16])
+ #return hptoh16(data[:SIZE_OF_U16])
+ return ntoh16(data[:SIZE_OF_U16])
def read_param_value(data, length):
return data[:length]
def read(mme, maximus):
+
# MM Header
#
@@ -405,7 +409,7 @@ def read(mme, maximus):
display(mme)
raise Error("MM Header: bad Module! (" + hex(hptoh8(mme.payload.load[begin:end])) + ")")
- # Length: Payload length (0 to 1484) - 2 octets
+ # Length: Payload length (0 to 1492) - 2 octets
begin = end
end += SIZE_OF_U16
length = hptoh16(mme.payload.load[begin:end])
@@ -431,10 +435,10 @@ def read(mme, maximus):
display(mme)
raise Error("FCALL header: bad version! (" + hex(hptoh8(fcall_hdr[0])) + ")")
if hptoh8(fcall_hdr[1]) != FUNCTION_CALL_TYPE_RSP: # uint8_t type
- if not maximus.UNIT_TEST or (maximus.UNIT_TEST and hptoh8(fcall_hdr[1]) != FUNCTION_CALL_TYPE_REQ):
- display(mme)
- raise Error("FCALL header: bad type! (" + hex(hptoh8(fcall_hdr[1])) + ")")
- msg_id = hptoh16(fcall_hdr[2:4])
+ display(mme)
+ raise Error("FCALL header: bad type! (" + hex(hptoh8(fcall_hdr[1])) + ")")
+ #msg_id = hptoh16(fcall_hdr[2:4])
+ msg_id = ntoh16(fcall_hdr[2:4])
param_nb = hptoh8(fcall_hdr[4]) # uint8_t param_nb
if hptoh8(fcall_hdr[5]) >= FUNCTION_CALL_FLAG_FAILED: # uint8_t flags
display(mme)
@@ -445,7 +449,7 @@ def read(mme, maximus):
index = end
name = read_name(mme.payload.load[index:])
fcall = Fcall(name, maximus)
- length -= len(name) + 1
+ length -= SIZE_OF_FUNCTION_CALL_HEADER + len(name) + 1
index += len(name) + 1
for n in range(0, param_nb):
param_name = read_param_name(mme.payload.load[index:])