Difference between revisions of "Xebra Module Communication Protocol"

(Example)
Line 13: Line 13:
 
For every request, the module sends a message of the following format to the server:
 
For every request, the module sends a message of the following format to the server:
 
<code>
 
<code>
REQUEST = (GET_HEADER HEADERS_IN HEADERS_OUT SUBPROCESS_ENVIRONMENT_VARS GET_ARGUMENTS)
+
REQUEST = GET_REQUEST | POST_TABLE_REQUEST | POST_PLAIN_REQUEST;
        | (POST_HEADER HEADERS_IN HEADERS_OUT SUBPROCESS_ENVIRONMENT_VARS POST_ARGUMENTS) ;
+
GET_REQUEST = "GET" BODY TABLE_ARGS
 
+
POST_TABLE_REQUEST = "POST" BODY TABLE_ARGS
GET_HEADER = "GET" HEADER;
+
POST_PLAIN_REQUEST = "POST" BODY PLAIN_ARGS
POST_HEADER = "POST" HEADER;
+
BODY = HEADER HEADERS_IN HEADERS_OUT SUBPROCESS_ENVIRONMENT_VARS
HEADER = " " url " HTTP/1.1";
+
 
+
 
HEADERS_IN = "#HI#" TABLE_ENTRIES "#E#";
 
HEADERS_IN = "#HI#" TABLE_ENTRIES "#E#";
 
HEADERS_OUT = "#HO#" TABLE_ENTRIES "#E#";
 
HEADERS_OUT = "#HO#" TABLE_ENTRIES "#E#";
 
SUBPROCESS_ENVIRONMENT_VARS = "#SE#" TABLE_ENTRIES "#E#";
 
SUBPROCESS_ENVIRONMENT_VARS = "#SE#" TABLE_ENTRIES "#E#";
 
TABLE_ENTRIES = {"#$#" item_name "#%#" item_value};
 
TABLE_ENTRIES = {"#$#" item_name "#%#" item_value};
 
+
HEADER =  " "  url " HTTP/1.1";
GET_ARGUMENTS = "#A#"  {"$" arg_name "=" arg_value}  "#E#";
+
TABLE_ARGS = "#A#"  {"$" arg_name "=" arg_value}  "#E#";
POST_ARGUMENTS = "#A##CT#" content_type "#CTE#"  (TABLE_POST_DATA | post_data) "#E#";
+
PLAIN_ARGS = "#A#$" plain_args "#E#";  
TABLE_POST_DATA = {"$" arg_name "=" arg_value};
+
 
+
 
+
 
</code>
 
</code>
  

Revision as of 14:42, 2 July 2009


Basic Communication

For every string message that is to be sent between a module and server, the sender first sends the length of the message ENCODED_MESSAGE_LENGTH and then the message MESSAGE. The max length FRAG_SIZE of a message to be sent is 65536 bytes. If a message is longer, it is divided into fragments. ENCODED_MESSAGE_LENGTH is called ENCODED_ because it also contains a FRAG_FLAG which specifies if the next message is a fragment and has to be assembled to a whole message after receiving.

Let's say the server wants so send a message of size 150'000 bytes to the module. The following would be sent: [65536 FRAG_FLAG=1][Message part 1...][65536 FRAG_FLAG=1][Message part 2....][18928 FRAG_FLAG=0][Message part 3....]

The ENCODED_MESSAGE_LENGTH is constructed as follows: The lenght of the message (integer) is shifted by 1 bit to the left. Then the most right bit is set to FRAG_FLAG.

Request Message

For every request, the module sends a message of the following format to the server:

REQUEST = GET_REQUEST | POST_TABLE_REQUEST | POST_PLAIN_REQUEST;
GET_REQUEST = "GET" BODY TABLE_ARGS
POST_TABLE_REQUEST = "POST" BODY TABLE_ARGS
POST_PLAIN_REQUEST = "POST" BODY PLAIN_ARGS
BODY = HEADER HEADERS_IN HEADERS_OUT SUBPROCESS_ENVIRONMENT_VARS
HEADERS_IN = "#HI#" TABLE_ENTRIES "#E#";
HEADERS_OUT = "#HO#" TABLE_ENTRIES "#E#";
SUBPROCESS_ENVIRONMENT_VARS = "#SE#" TABLE_ENTRIES "#E#";
TABLE_ENTRIES = {"#$#" item_name "#%#" item_value};
HEADER =  " "  url " HTTP/1.1";
TABLE_ARGS = "#A#"  {"$" arg_name "=" arg_value}  "#E#";
PLAIN_ARGS = "#A#$" plain_args "#E#";

Example

GET /demoapplication/reservations.xeb HTTP/1.1#HI##$#Host#%#localhost:55000#$#User-Agent#%#Mozilla/5.0 (X11; U; Linux x86_64; en; rv:1.9.0.11) Gecko/20080528 Epiphany/2.22 Firefox/3.0#$#Accept#%#text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8#$#Accept-Language#%#en-us,en;q=0.5#$#Accept-Encoding#%#gzip,deflate#$#Accept-Charset#%#ISO-8859-1,utf-8;q=0.7,*;q=0.7#$#Keep-Alive#%#300#$#Connection#%#keep-alive#$#Referer#%#http://localhost:55000/demoapplication/contact.xeb#$#Cookie#%#xuuid=E5573216-8AEC-4187-8ECD-0BC38CF36FF0#E##HO##E##SE##E##A##E#
 
POST /demoapplication/login.xeb HTTP/1.1#HI##$#Host#%#localhost:55000#$#User-Agent#%#Mozilla/5.0 (X11; U; Linux x86_64; en; rv:1.9.0.11) Gecko/20080528 Epiphany/2.22 Firefox/3.0#$#Accept#%#text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8#$#Accept-Language#%#en-us,en;q=0.5#$#Accept-Encoding#%#gzip,deflate#$#Accept-Charset#%#ISO-8859-1,utf-8;q=0.7,*;q=0.7#$#Keep-Alive#%#300#$#Connection#%#keep-alive#$#Referer#%#http://localhost:55000/demoapplication/login.xeb#$#Cookie#%#xuuid=E5573216-8AEC-4187-8ECD-0BC38CF36FF0#$#Content-Type#%#application/x-www-form-urlencoded#$#Content-Length#%#88#E##HO##E##SE##E##A##CT#application/x-www-form-urlencoded#CTE#&l_temp_4=admin&l_temp_6=123&l_temp_8=&servlet_uid_3=servlet_uid_3&l_temp_3=servlet_uid_0#E#

Response Message

The server answers with a response message of the following format:

RESPONSE = {COOKIE_ORDER} CONTENT_TYPE HTML;
COOKIE_ORDER = "#C#" cookie_name "=" cookie_value COOKIE_OPT ";Version=1#CE#";
COOKIE_OPT = [";" "Domain=" cookie_domain]
             [";" "Max-Age=" cookie_max_age]  
             [";" "Path=" cookie_path]
             [";" "Secure"];
CONTENT_TYPE = "#CT#" content_type;
HTML = "#H#" html_code;

Example