aboutsummaryrefslogtreecommitdiff
path: root/dat.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-02-11 00:26:30 +0000
committerrodri <rgl@antares-labs.eu>2023-02-11 00:26:30 +0000
commit775309861b51dd1f340d82074b7e9234f3e0675e (patch)
treec0a20e4edcb09814e3fc659e97aaeb363b5b51ef /dat.h
parentc1cdf0f980b92193953f05bf444b7c78f369a122 (diff)
downloadmusw-775309861b51dd1f340d82074b7e9234f3e0675e.tar.gz
musw-775309861b51dd1f340d82074b7e9234f3e0675e.tar.bz2
musw-775309861b51dd1f340d82074b7e9234f3e0675e.zip
implemented connection establishment with per client DHX.
Diffstat (limited to 'dat.h')
-rw-r--r--dat.h47
1 files changed, 32 insertions, 15 deletions
diff --git a/dat.h b/dat.h
index 9727db3..89554bc 100644
--- a/dat.h
+++ b/dat.h
@@ -14,6 +14,12 @@ typedef enum {
WEDGE
} Kind;
+typedef enum {
+ NCSDisconnected,
+ NCSConnecting,
+ NCSConnected
+} NCState;
+
enum {
SCRW = 640,
SCRH = 480,
@@ -22,24 +28,25 @@ enum {
};
enum {
- NChi = 10, /* C wants to connect */
- NShi, /* S accepts */
- NCdhx0 = 12, /* C asks for p and g */
- NSdhx0, /* S sends them. it's not a negotiation */
- NCdhx1 = 14, /* C shares pubkey */
- NSdhx1, /* S shares pubkey */
- NCnudge = 16,
- NSnudge, /* check the pulse of the line */
-
- NCinput = 20, /* C sends player input state */
- NSsimstate, /* S sends current simulation state */
+ NChi = 10, /* C wants to connect */
+ NShi, /* S accepts. sends P and G for DHX */
+ NCdhx = 12, /* C shares pubkey */
+ NSdhx, /* S shares pubkey */
+ NCnudge = 16,
+ NSnudge, /* check the pulse of the line */
+
+ NCinput = 20, /* C sends player input state */
+ NSsimstate, /* S sends current simulation state */
NCbuhbye = 30,
- NSbuhbye
+ NSbuhbye,
+
+ NSerror = 66 /* report an error */
};
enum {
- Framehdrsize = 1+4+4+2,
+ ProtocolID = 0x5753554d, /* MUSW */
+ Framehdrsize = 4+1+4+4+2,
MTU = 1024
};
@@ -53,6 +60,7 @@ typedef struct Universe Universe;
typedef struct Derivative Derivative;
typedef struct Frame Frame;
+typedef struct DHparams DHparams;
typedef struct NetConn NetConn;
typedef struct Player Player;
typedef struct Party Party;
@@ -63,7 +71,7 @@ typedef struct Party Party;
struct VModel
{
Point2 *pts;
- ulong npts;
+ usize npts;
/* WIP
* l(ine) → takes 2 points
* c(urve) → takes 3 points
@@ -134,6 +142,7 @@ struct Derivative
struct Frame
{
Udphdr udp;
+ u32int id; /* ProtocolID */
u8int type;
u32int seq;
u32int ack;
@@ -141,10 +150,18 @@ struct Frame
uchar data[];
};
+struct DHparams
+{
+ ulong p, g, pub, sec, priv;
+};
+
struct NetConn
{
Udphdr udp;
- int isconnected;
+ DHparams dh;
+ NCState state;
+ u32int lastseq;
+ u32int lastack;
};
struct Player