Reduce byte count for mdp payloads by excluding overlay type

This commit is contained in:
Jeremy Lakeman 2012-11-27 11:24:03 +10:30
parent 527e922e29
commit dee3367308
3 changed files with 18 additions and 4 deletions

View File

@ -77,6 +77,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define OVERLAY_MAX_LOCAL_IDENTITIES 256
/* All of these types should be considered deprecated. Processing code should migrate to well known MDP port numbers */
/* Overlay mesh packet codes */
#define OF_TYPE_SELFANNOUNCE 0x10 /* BATMAN style announcement frames */
#define OF_TYPE_SELFANNOUNCE_ACK 0x20 /* BATMAN style "I saw your announcment" frames */
@ -98,6 +99,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define PAYLOAD_FLAG_CIPHERED (1<<4)
#define PAYLOAD_FLAG_SIGNED (1<<5)
// this can be removed once all overlay messages have been turned into mdp payloads
#define PAYLOAD_FLAG_LEGACY_TYPE (1<<7)
/* Crypto/security options */
#define OF_CRYPTO_NONE 0x00
#define OF_CRYPTO_CIPHERED PAYLOAD_FLAG_CIPHERED /* Encrypted frame */

View File

@ -265,9 +265,13 @@ int packetOkOverlay(struct overlay_interface *interface,unsigned char *packet, s
f.ttl--;
if (f.ttl<=0)
forward=0;
f.type=ob_get(b);
if (f.type<0)
break;
if (flags & PAYLOAD_FLAG_LEGACY_TYPE){
f.type=ob_get(b);
if (f.type<0)
break;
}else
f.type=OF_TYPE_DATA;
f.modifiers=flags;

View File

@ -40,6 +40,9 @@ int overlay_frame_build_header(struct decode_context *context, struct overlay_bu
if (!destination)
flags |= PAYLOAD_FLAG_TO_BROADCAST;
if (type!=OF_TYPE_DATA)
flags |= PAYLOAD_FLAG_LEGACY_TYPE;
if (ob_append_byte(buff, flags)) return -1;
if (!(flags & PAYLOAD_FLAG_SENDER_SAME)){
@ -60,7 +63,10 @@ int overlay_frame_build_header(struct decode_context *context, struct overlay_bu
if (!(flags & PAYLOAD_FLAG_ONE_HOP)){
if (ob_append_byte(buff, ttl | ((queue&3)<<5))) return -1;
}
if (ob_append_byte(buff, type)) return -1;
if (flags & PAYLOAD_FLAG_LEGACY_TYPE){
if (ob_append_byte(buff, type)) return -1;
}
if (ob_append_rfs(buff, 2)) return -1;