From b8414dc3911ccaaa0b27f21695dbc5f987cca38e Mon Sep 17 00:00:00 2001 From: Maurizio Porrato Date: Wed, 25 Aug 2010 21:33:57 +0200 Subject: [PATCH] Fix handling of html inside text messages in server. Add some protocol documentation. --- docs/protocols.markdown | 52 ++++++++++++++++++++++++++++++++++++++++- frn/utility.py | 6 ++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/docs/protocols.markdown b/docs/protocols.markdown index 20fb0e4..90aff0a 100644 --- a/docs/protocols.markdown +++ b/docs/protocols.markdown @@ -2,7 +2,7 @@ The FreeRadioNetwork protocol ============================= This document describes the results of reverse-engeneering the official -set of [FreeRadioNetwork](http//freeradionetwork.eu) programs through +set of [FreeRadioNetwork](http://freeradionetwork.eu) programs through network traffic sniffing and software decompilation. @@ -113,6 +113,56 @@ Padding to five digits we would get `03046`, so D=0, E=3, F=0, G=4, H=6 so the auth code wold be `40063`. +### Keepalive ### + +After the communication between client and server has been established, +server starts sending keepalive messages to the client at a rate of two +messages per second. +The keepalive message, as any other server to client message must be +acknowledged by the client. + +Server to client: + +* chr(0): keepalive message identifier + +Client to server: + +* P\r\n +### Sending audio signal ### + +Sending audio signal from client to server is a two-step procedure: +client must request permission to trasmit to the server and then, if +server acknowledges, client can start transmitting audio data. + +Client to server: + +* TX0\r\n + +Server to client: + +* chr(1)+chr(hh)+chr(ll): transmission acknowledged (hh*256+ll is the +client index in client list) + +Client to server: + +* TX1\r\n followed by 325 bytes: data following the first line +contains 10 GSM 6.10 frames (representing 20mS of audio signal each one) +encoded with WAV#49 variant. + +Client to server: + +* RX0\r\n: clients stops transmitting audio. + + +### Receiving audio signal ### + +Server to client: + +* chr(2)+chr(hh)+chr(ll) followed by 325 bytes: data following the first +3 bytes contains 10 GSM 6.10 frames (representing 20mS of audio signal +each one) encoded with WAV#49 variant. hh*256+ll represents the index in +the client list of the client sending audio. + diff --git a/frn/utility.py b/frn/utility.py index b4b5968..4dd9b5d 100644 --- a/frn/utility.py +++ b/frn/utility.py @@ -32,7 +32,11 @@ class SimpleXMLParser(HTMLParser): self.next_field = tag self.next_data = '' else: - self.next_data += "<%s>" % tag + if attrs: + a = ' '+' '.join(['%s="%s"' % (k,v) for k,v in attrs]) + else: + a = '' + self.next_data += "<%s%s>" % (tag,a) def handle_data(self, data): if self.next_field is not None: