1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// magic value for messages
const uint32_t MSG_MAGIC = 0x46474653; // "FGFS"
// protocoll version
const uint32_t PROTO_VER = 0x00010001; // 1.1
// Message identifiers
#define CHAT_MSG_ID 1
#define UNUSABLE_POS_DATA_ID 2
#define OLD_OLD_POS_DATA_ID 3
#define OLD_POS_DATA_ID 4
#define OLD_PROP_MSG_ID 5
#define RESET_DATA_ID 6
#define POS_DATA_ID 7
// XDR demands 4 byte alignment, but some compilers use8 byte alignment
// so it's safe to let the overall size of a network message be a
// multiple of 8!
#define MAX_CALLSIGN_LEN 8
#define MAX_CHAT_MSG_LEN 256
#define MAX_MODEL_NAME_LEN 96
#define MAX_PROPERTY_LEN 52
// Header for use with all messages sent
struct T_MsgHdr {
xdr_data_t Magic; // Magic Value
xdr_data_t Version; // Protocoll version
xdr_data_t MsgId; // Message identifier
xdr_data_t MsgLen; // absolute length of message
xdr_data_t ReplyAddress; // (player's receiver address
xdr_data_t ReplyPort; // player's receiver port
char Callsign[MAX_CALLSIGN_LEN]; // Callsign used by the player
};
// Chat message
struct T_ChatMsg {
char Text[MAX_CHAT_MSG_LEN]; // Text of chat message
};
// Position message
struct T_PositionMsg {
char Model[MAX_MODEL_NAME_LEN]; // Name of the aircraft model
// Time when this packet was generated
xdr_data2_t time;
xdr_data2_t lag;
// position wrt the earth centered frame
xdr_data2_t position[3];
// orientation wrt the earth centered frame, stored in the angle axis
// representation where the angle is coded into the axis length
xdr_data_t orientation[3];
// linear velocity wrt the earth centered frame measured in
// the earth centered frame
xdr_data_t linearVel[3];
// angular velocity wrt the earth centered frame measured in
// the earth centered frame
xdr_data_t angularVel[3];
// linear acceleration wrt the earth centered frame measured in
// the earth centered frame
xdr_data_t linearAccel[3];
// angular acceleration wrt the earth centered frame measured in
// the earth centered frame
xdr_data_t angularAccel[3];
// Padding. The alignment is 8 bytes on x86_64 because there are
// 8-byte types in the message, so the size should be explicitly
// rounded out to a multiple of 8. Of course, it's a bad idea to
// put a C struct directly on the wire, but that's a fight for
// another day...
xdr_data_t pad;
};
2012-08-08T10:49:14 GwenDragonUnd wie ist deine Frage zum Problem? Wo brauchst du Hilfe? Was klappt nicht?
Zeig bitte mal Code, was du probiert hast.
1 2 3 4 5 6 7
sub conv2xdr() { my $data = shift; pack ('N', $data); return $data; } print &conv2xdr('test');
Quote09.08.2012 14:30:33 FG_SERVER::AddBadClient() - 62.108.37.223 BAD magic number: #
1 2 3 4 5 6 7 8 9 10 11 12
sub xdrencode() { use XDR::Encode qw(:all); use XDR::Decode; my ($args) = opaque (shift); my $xid = 0x123; my $proc = 42; my $vers = 4; my $prog = 3; my $rpcvers = 2; my $packet = call_packet ($xid, $proc, $args, $vers, $prog, $rpcvers); return ($packet); }
1
2
3
4
// magic value for messages
const uint32_t MSG_MAGIC = 0x46474653; // "FGFS"
// protocoll version
const uint32_t PROTO_VER = 0x00010001; // 1.1