From 494bafcf5c16560d447c00b1f9957163c067cdf1 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 18 Oct 2005 03:12:25 +0000 Subject: [PATCH] Bugfix: snac-flags HEX: 8000 means extra-data section. Packets parsed correctly now --- contrib/aim/aim.factor | 45 ++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/contrib/aim/aim.factor b/contrib/aim/aim.factor index c9fb1893bf..446f6ecd04 100644 --- a/contrib/aim/aim.factor +++ b/contrib/aim/aim.factor @@ -17,6 +17,7 @@ SYMBOL: family SYMBOL: opcode SYMBOL: snac-flags SYMBOL: snac-request-id +SYMBOL: extra-data SYMBOL: name SYMBOL: message @@ -157,8 +158,7 @@ TUPLE: buddy name id gid capabilities buddy-icon online ; {{ }} clone banned-hash-name set {{ }} clone banned-hash-id set modify-queue set - ! 65535 random-int seq-num set - 0 seq-num set + HEX: 7fff random-int seq-num set 1 stage-num set ; : prepend-aim-protocol ( data -- ) @@ -167,7 +167,7 @@ TUPLE: buddy name id gid capabilities buddy-icon online ; stage-num get >byte seq-num get >short ] "" make - seq-num [ 1+ ] change + seq-num get dup HEX: 7fff >= [ 0 ] [ 1+ ] if seq-num set swap dup >r length (>short) r> append append ; : (send-aim) ( str -- ) @@ -197,7 +197,11 @@ TUPLE: buddy name id gid capabilities buddy-icon online ; head-short family set head-short opcode set head-short snac-flags set - head-int snac-request-id set ; + head-int snac-request-id set + snac-flags get HEX: 8000 bitand 0 > [ + head-short head-string extra-data set + extra-data get "Extra data: " writeln hexdump + ] when ; : (unhandled-opcode) ( str -- ) ! "Family: " write family get >hex write @@ -288,6 +292,16 @@ M: object get-banned ( name -- ) (handle-supported-families) ] unless ; +! : unscoped-stream get empty? [ + ! head-short + ! [ + ! head-short + ! head-short head-string [ + ! cond + ! ] with-unscoped-stream + ! ] repeat + ! ] unless ; + : handle-supported-families "Families: " print (handle-supported-families) @@ -373,12 +387,6 @@ M: object get-banned ( name -- ) ] unless ; : handle-online-info - snac-flags get 32768 = [ - head-short drop - head-short drop - head-short drop - head-short drop - ] when (handle-online-info) ; FAMILY: 1 OPCODE: f @@ -488,12 +496,11 @@ M: object get-banned ( name -- ) ] repeat ; FAMILY: 3 OPCODE: c : parse-family-4h-header - head-short drop - head-short drop - head-short drop - head-short drop - 8 head-string drop - head-short channel set ; + extra-data get [ + head-short drop + head-short drop + head-short drop + ] with-unscoped-stream ; : parse-message-text ( -- str ) head-short drop head-short drop head-contents ; @@ -663,6 +670,8 @@ M: object get-banned ( name -- ) : handle-incoming-message ( -- ) parse-family-4h-header + head-longlong drop + head-short channel set head-byte head-string name set head-short warning set head-short parse-message-tlv @@ -683,6 +692,8 @@ M: object get-banned ( name -- ) : handle-typing-message ( -- ) parse-family-4h-header + head-longlong drop + head-short channel set head-byte head-string write head-short { @@ -892,7 +903,7 @@ SYMBOL: type : second-server aim-chat-ip get aim-chat-port get conn set 1 stage-num set - 65535 random-int seq-num set + HEX: 7fff random-int seq-num set send-second-login read-aim drop 2 stage-num set ;