summaryrefslogtreecommitdiff
path: root/src/Network
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2018-09-08 06:25:55 -0400
committerJoe Crayne <joe@jerkface.net>2018-09-08 08:36:05 -0400
commitadf62395931f4b90491cc1338b9a5105da98fbbe (patch)
tree1177cc719fdd2e5449e03963fb32b24b7017a94a /src/Network
parentad20be57786ad34f80192206c480d575392b4ebb (diff)
Factored Data.Tox.Message out of Network.Tox.Crypto.Transport.
Diffstat (limited to 'src/Network')
-rw-r--r--src/Network/Tox/Crypto/Handlers.hs1
-rw-r--r--src/Network/Tox/Crypto/Transport.hs271
2 files changed, 2 insertions, 270 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs
index 3269f5dd..f0332df0 100644
--- a/src/Network/Tox/Crypto/Handlers.hs
+++ b/src/Network/Tox/Crypto/Handlers.hs
@@ -476,7 +476,6 @@ ncToWire getState seqno bufend pktno msg = do
476 setMessageId (UpToN _ x) mid = UpToN (toEnum8 mid) x 476 setMessageId (UpToN _ x) mid = UpToN (toEnum8 mid) x
477 msg' = setMessageId msg outid 477 msg' = setMessageId msg outid
478 in case lsness msg of 478 in case lsness msg of
479 UnknownLossyness -> return Nothing
480 Lossy -> let cd = 479 Lossy -> let cd =
481 CryptoData 480 CryptoData
482 { bufferStart = seqno 481 { bufferStart = seqno
diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs
index 3ade25f7..9220fd1e 100644
--- a/src/Network/Tox/Crypto/Transport.hs
+++ b/src/Network/Tox/Crypto/Transport.hs
@@ -53,16 +53,17 @@ module Network.Tox.Crypto.Transport
53 , sizedAtLeastN 53 , sizedAtLeastN
54 , isIndirectGrpChat 54 , isIndirectGrpChat
55 , LossyOrLossless(..) 55 , LossyOrLossless(..)
56 , lossyness
57 , fromEnum8 56 , fromEnum8
58 , fromEnum16 57 , fromEnum16
59 , toEnum8 58 , toEnum8
60 , msgSizeParam 59 , msgSizeParam
61 , NegotiationID(..) 60 , NegotiationID(..)
62 , NegotiationMsg(..) 61 , NegotiationMsg(..)
62 , module Data.Tox.Message
63 ) where 63 ) where
64 64
65import Crypto.Tox 65import Crypto.Tox
66import Data.Tox.Message
66import Network.Tox.DHT.Transport (Cookie) 67import Network.Tox.DHT.Transport (Cookie)
67import Network.Tox.NodeId 68import Network.Tox.NodeId
68 69
@@ -750,15 +751,6 @@ isIndirectGrpChat MESSAGE_GROUPCHAT = True
750isIndirectGrpChat LOSSY_GROUPCHAT = True 751isIndirectGrpChat LOSSY_GROUPCHAT = True
751isIndirectGrpChat _ = False 752isIndirectGrpChat _ = False
752 753
753data LossyOrLossless = UnknownLossyness | Lossless | Lossy
754 deriving (Eq,Ord,Enum,Show,Bounded)
755
756lossyness :: MessageID -> LossyOrLossless
757lossyness (fromEnum -> x) | x < 3 = Lossy
758lossyness (fromEnum -> x) | {-x >= 16,-} x < 192 = Lossless
759lossyness (fromEnum -> x) | x >= 192, x < 255 = Lossy
760lossyness (fromEnum -> 255) = Lossless
761lossyness _ = UnknownLossyness
762 754
763isKillPacket :: MessageType -> Bool 755isKillPacket :: MessageType -> Bool
764isKillPacket (Msg KillPacket) = True 756isKillPacket (Msg KillPacket) = True
@@ -768,265 +760,6 @@ isOFFLINE :: MessageType -> Bool
768isOFFLINE (Msg OFFLINE) = True 760isOFFLINE (Msg OFFLINE) = True
769isOFFLINE _ = False 761isOFFLINE _ = False
770 762
771-- TODO: Flesh this out.
772data MessageID -- First byte indicates data
773 = Padding -- ^ 0 padding (skipped until we hit a non zero (data id) byte)
774 | PacketRequest -- ^ 1 packet request packet (lossy packet)
775 | KillPacket -- ^ 2 connection kill packet (lossy packet)
776 | UnspecifiedPacket003 -- ^ 3+ unspecified
777 | UnspecifiedPacket004
778 | UnspecifiedPacket005
779 | UnspecifiedPacket006
780 | UnspecifiedPacket007
781 | UnspecifiedPacket008
782 | UnspecifiedPacket009
783 | UnspecifiedPacket010
784 | UnspecifiedPacket011
785 | UnspecifiedPacket012
786 | UnspecifiedPacket013
787 | UnspecifiedPacket014
788 | UnspecifiedPacket015
789 | PING -- ^ 16+ reserved for Messenger usage (lossless packets)
790 | MessengerLossless017
791 | MessengerLossless018
792 | MessengerLossless019
793 | MessengerLossless020
794 | MessengerLossless021
795 | MessengerLossless022
796 | MessengerLossless023
797 | ONLINE -- 1 byte
798 | OFFLINE -- 1 byte
799 | MessengerLossless026
800 | MessengerLossless027
801 | MessengerLossless028
802 | MessengerLossless029
803 | MessengerLossless030
804 | MessengerLossless031
805 | MessengerLossless032
806 | MessengerLossless033
807 | MessengerLossless034
808 | MessengerLossless035
809 | MessengerLossless036
810 | MessengerLossless037
811 | MessengerLossless038
812 | MessengerLossless039
813 | MessengerLossless040
814 | MessengerLossless041
815 | MessengerLossless042
816 | MessengerLossless043
817 | MessengerLossless044
818 | MessengerLossless045
819 | MessengerLossless046
820 | MessengerLossless047
821 | NICKNAME -- up to 129 bytes
822 | STATUSMESSAGE -- up to 1008 bytes
823 | USERSTATUS -- 2 bytes
824 | TYPING -- 2 bytes
825 | MessengerLossless052
826 | MessengerLossless053
827 | MessengerLossless054
828 | MessengerLossless055
829 | MessengerLossless056
830 | MessengerLossless057
831 | MessengerLossless058
832 | MessengerLossless059
833 | MessengerLossless060
834 | MessengerLossless061
835 | MessengerLossless062
836 | MessengerLossless063
837 | MESSAGE -- up to 1373 bytes
838 | ACTION -- up to 1373 bytes
839 | MessengerLossless066
840 | MessengerLossless067
841 | MessengerLossless068
842 | MSI
843 | MessengerLossless070
844 | MessengerLossless071
845 | MessengerLossless072
846 | MessengerLossless073
847 | MessengerLossless074
848 | MessengerLossless075
849 | MessengerLossless076
850 | MessengerLossless077
851 | MessengerLossless078
852 | MessengerLossless079
853 | FILE_SENDREQUEST -- 1+1+4+8+32+max255 = up to 301
854 | FILE_CONTROL -- 8 bytes if seek, otherwise 4
855 | FILE_DATA -- up to 1373
856 | MessengerLossless083
857 | MessengerLossless084
858 | MessengerLossless085
859 | MessengerLossless086
860 | MessengerLossless087
861 | MessengerLossless088
862 | MessengerLossless089
863 | MessengerLossless090
864 | MessengerLossless091
865 | MessengerLossless092
866 | MessengerLossless093
867 | MessengerLossless094
868 | MessengerLossless095
869 | INVITE_GROUPCHAT -- 0x60
870 | ONLINE_PACKET -- 0x61
871 | DIRECT_GROUPCHAT -- 0x62
872 | MESSAGE_GROUPCHAT -- 0x63
873 | MessengerLossless100
874 | MessengerLossless101
875 | MessengerLossless102
876 | MessengerLossless103
877 | MessengerLossless104
878 | MessengerLossless105
879 | MessengerLossless106
880 | MessengerLossless107
881 | MessengerLossless108
882 | MessengerLossless109
883 | MessengerLossless110
884 | MessengerLossless111
885 | MessengerLossless112
886 | MessengerLossless113
887 | MessengerLossless114
888 | MessengerLossless115
889 | MessengerLossless116
890 | MessengerLossless117
891 | MessengerLossless118
892 | MessengerLossless119
893 | MessengerLossless120
894 | MessengerLossless121
895 | MessengerLossless122
896 | MessengerLossless123
897 | MessengerLossless124
898 | MessengerLossless125
899 | MessengerLossless126
900 | MessengerLossless127
901 | MessengerLossless128
902 | MessengerLossless129
903 | MessengerLossless130
904 | MessengerLossless131
905 | MessengerLossless132
906 | MessengerLossless133
907 | MessengerLossless134
908 | MessengerLossless135
909 | MessengerLossless136
910 | MessengerLossless137
911 | MessengerLossless138
912 | MessengerLossless139
913 | MessengerLossless140
914 | MessengerLossless141
915 | MessengerLossless142
916 | MessengerLossless143
917 | MessengerLossless144
918 | MessengerLossless145
919 | MessengerLossless146
920 | MessengerLossless147
921 | MessengerLossless148
922 | MessengerLossless149
923 | MessengerLossless150
924 | MessengerLossless151
925 | MessengerLossless152
926 | MessengerLossless153
927 | MessengerLossless154
928 | MessengerLossless155
929 | MessengerLossless156
930 | MessengerLossless157
931 | MessengerLossless158
932 | MessengerLossless159
933 | MessengerLossless160
934 | MessengerLossless161
935 | MessengerLossless162
936 | MessengerLossless163
937 | MessengerLossless164
938 | MessengerLossless165
939 | MessengerLossless166
940 | MessengerLossless167
941 | MessengerLossless168
942 | MessengerLossless169
943 | MessengerLossless170
944 | MessengerLossless171
945 | MessengerLossless172
946 | MessengerLossless173
947 | MessengerLossless174
948 | MessengerLossless175
949 | MessengerLossless176
950 | MessengerLossless177
951 | MessengerLossless178
952 | MessengerLossless179
953 | MessengerLossless180
954 | MessengerLossless181
955 | MessengerLossless182
956 | MessengerLossless183
957 | MessengerLossless184
958 | MessengerLossless185
959 | MessengerLossless186
960 | MessengerLossless187
961 | MessengerLossless188
962 | MessengerLossless189
963 | MessengerLossless190
964 | MessengerLossless191
965 | MessengerLossy192 -- ^ 192+ reserved for Messenger usage (lossy packets)
966 | MessengerLossy193
967 | MessengerLossy194
968 | MessengerLossy195
969 | MessengerLossy196
970 | MessengerLossy197
971 | MessengerLossy198
972 | LOSSY_GROUPCHAT -- 0xC7
973 | MessengerLossy200
974 | MessengerLossy201
975 | MessengerLossy202
976 | MessengerLossy203
977 | MessengerLossy204
978 | MessengerLossy205
979 | MessengerLossy206
980 | MessengerLossy207
981 | MessengerLossy208
982 | MessengerLossy209
983 | MessengerLossy210
984 | MessengerLossy211
985 | MessengerLossy212
986 | MessengerLossy213
987 | MessengerLossy214
988 | MessengerLossy215
989 | MessengerLossy216
990 | MessengerLossy217
991 | MessengerLossy218
992 | MessengerLossy219
993 | MessengerLossy220
994 | MessengerLossy221
995 | MessengerLossy222
996 | MessengerLossy223
997 | MessengerLossy224
998 | MessengerLossy225
999 | MessengerLossy226
1000 | MessengerLossy227
1001 | MessengerLossy228
1002 | MessengerLossy229
1003 | MessengerLossy230
1004 | MessengerLossy231
1005 | MessengerLossy232
1006 | MessengerLossy233
1007 | MessengerLossy234
1008 | MessengerLossy235
1009 | MessengerLossy236
1010 | MessengerLossy237
1011 | MessengerLossy238
1012 | MessengerLossy239
1013 | MessengerLossy240
1014 | MessengerLossy241
1015 | MessengerLossy242
1016 | MessengerLossy243
1017 | MessengerLossy244
1018 | MessengerLossy245
1019 | MessengerLossy246
1020 | MessengerLossy247
1021 | MessengerLossy248
1022 | MessengerLossy249
1023 | MessengerLossy250
1024 | MessengerLossy251
1025 | MessengerLossy252
1026 | MessengerLossy253
1027 | MessengerLossy254
1028 | Messenger255 -- ^ 255 reserved for Messenger usage (lossless packet)
1029 deriving (Show,Eq,Enum,Ord,Bounded)
1030 763
1031 764
1032 765