-
+ 1190FB877B7956B9B38F1D817858FE872F6E93B7E4FAC674BF3C82D664ACB11204FC88DE2563B33298A2A9AD547343CDF03F2CF068B3B1208DB0B1EE0B3C246C
smg_comms/src/messages.ads
(0 . 0)(1 . 77)
431 -- Message reader & writers for SMG Communication Protocol
432 -- This part effectively serializes/deserializes game data structures
433 -- for transmission between client and server.
434 -- Note that messages themeselves are simply arrays of octets.
435 -- (see also raw_types.ads/adb and packing.ads/adb for related parts)
436 -- NB: message ids and padding as per protocol spec are handled HERE ONLY.
437 -- Relies on:
438 -- RNG (for random padding)
439 -- CRC32 (for CRC calculations)
440 -- Raw_Types
441 -- Data_Structs
442 -- S.MG, 2018
443
444 with Raw_Types;
445 with RNG;
446 with CRC32;
447 with Data_Structs; use Data_Structs;
448 with Interfaces;
449
450 package Messages is
451 -- exception raised when given message to read fails sanity checks
452 Invalid_Msg: exception;
453
454 ------------------------------------------------
455 -- Writes a Serpent Keyset to the given Serpent Message
456 --
457 -- Keyset - the set of keys to write to message
458 -- Counter - the message count
459 procedure Write_SKeys_SMsg( Keyset : in Serpent_Keyset;
460 Counter : in Interfaces.Unsigned_16;
461 Msg : out Raw_Types.Serpent_Msg);
462
463 -- Reads a Serpent Keyset from the given Serpent Message
464 -- The opposite of Write_SKeys_SMsg above
465 -- Raises Invalid_Message exception if given message fails sanity checks
466 procedure Read_SKeys_SMsg( Msg : in Raw_Types.Serpent_Msg;
467 Counter : out Interfaces.Unsigned_16;
468 Keyset : out Serpent_Keyset);
469
470 private
471
472 -- if native is little endian, does nothing;
473 -- if native is big endian, it flips the input's octets.
474 -- (strictly for arrays of octets)
475 procedure Cast_LE( LE: in out Raw_Types.Octets );
476
477 -- protocol message types IDs, fixed as per protocol specification
478 -- Serpent messages end in "S_Type"
479 -- RSA messages end in "R_Type"
480 -- Character action types end in "A_Type"
481
482 -- Serpent message types
483 SKeys_S_Type : constant Interfaces.Unsigned_8 := 1;
484 Key_Mgm_S_Type : constant Interfaces.Unsigned_8 := 2;
485 File_Transfer_S_Type : constant Interfaces.Unsigned_8 := 3;
486 File_Req_S_Type : constant Interfaces.Unsigned_8 := 4;
487 Client_Action_S_Type : constant Interfaces.Unsigned_8 := 5;
488 World_Bulletin_S_Type: constant Interfaces.Unsigned_8 := 6;
489 Obj_Request_S_Type : constant Interfaces.Unsigned_8 := 7;
490 Obj_Info_S_Type : constant Interfaces.Unsigned_8 := 8;
491
492 -- RSA message types
493 RKeys_R_Type : constant Interfaces.Unsigned_8 := 251;
494 SKeys_R_Type : constant Interfaces.Unsigned_8 := 157;
495 Key_Mgm_R_Type : constant Interfaces.Unsigned_8 := 233;
496
497 -- Character action types
498 Lock_A_Type : constant Interfaces.Unsigned_8 := 0;
499 Make_A_Type : constant Interfaces.Unsigned_8 := 1;
500 Explore_A_Type : constant Interfaces.Unsigned_8 := 2;
501 Exchange_A_Type : constant Interfaces.Unsigned_8 := 3;
502 Attack_A_Type : constant Interfaces.Unsigned_8 := 4;
503 Repair_A_Type : constant Interfaces.Unsigned_8 := 5;
504 Move_A_Type : constant Interfaces.Unsigned_8 := 6;
505 Train_A_Type : constant Interfaces.Unsigned_8 := 7;
506
507 end Messages;