Commit b4d9dfd7 authored by Philip Withnall's avatar Philip Withnall Committed by Olivier Crête

pseudotcp: Put TCP flags in an enum

The on-the-wire flags (FIN, RST, ACK, etc.) should be in an enum to
clarify the code a little. This introduces no functional changes.
parent af02fa81
...@@ -175,8 +175,12 @@ typedef enum { ...@@ -175,8 +175,12 @@ typedef enum {
#define FLAG_ACK 0x10 #define FLAG_ACK 0x10
*/ */
#define FLAG_CTL 0x02 /* NOTE: This must fit in 5 bits. This is used on the wire. */
#define FLAG_RST 0x04 typedef enum {
FLAG_NONE = 0,
FLAG_CTL = 1 << 1,
FLAG_RST = 1 << 2,
} TcpFlags;
#define CTL_CONNECT 0 #define CTL_CONNECT 0
//#define CTL_REDIRECT 1 //#define CTL_REDIRECT 1
...@@ -402,7 +406,7 @@ typedef enum { ...@@ -402,7 +406,7 @@ typedef enum {
typedef struct { typedef struct {
guint32 conv, seq, ack; guint32 conv, seq, ack;
guint8 flags; TcpFlags flags;
guint16 wnd; guint16 wnd;
const gchar * data; const gchar * data;
guint32 len; guint32 len;
...@@ -501,7 +505,7 @@ static void queue_connect_message (PseudoTcpSocket *self); ...@@ -501,7 +505,7 @@ static void queue_connect_message (PseudoTcpSocket *self);
static guint32 queue(PseudoTcpSocket *self, const gchar * data, static guint32 queue(PseudoTcpSocket *self, const gchar * data,
guint32 len, gboolean bCtrl); guint32 len, gboolean bCtrl);
static PseudoTcpWriteResult packet(PseudoTcpSocket *self, guint32 seq, static PseudoTcpWriteResult packet(PseudoTcpSocket *self, guint32 seq,
guint8 flags, guint32 offset, guint32 len, guint32 now); TcpFlags flags, guint32 offset, guint32 len, guint32 now);
static gboolean parse (PseudoTcpSocket *self, static gboolean parse (PseudoTcpSocket *self,
const guint8 *_header_buf, gsize header_buf_len, const guint8 *_header_buf, gsize header_buf_len,
const guint8 *data_buf, gsize data_buf_len); const guint8 *data_buf, gsize data_buf_len);
...@@ -1103,7 +1107,7 @@ queue(PseudoTcpSocket *self, const gchar * data, guint32 len, gboolean bCtrl) ...@@ -1103,7 +1107,7 @@ queue(PseudoTcpSocket *self, const gchar * data, guint32 len, gboolean bCtrl)
// value is 0 then this is an ACK packet, otherwise this packet has payload. // value is 0 then this is an ACK packet, otherwise this packet has payload.
static PseudoTcpWriteResult static PseudoTcpWriteResult
packet(PseudoTcpSocket *self, guint32 seq, guint8 flags, packet(PseudoTcpSocket *self, guint32 seq, TcpFlags flags,
guint32 offset, guint32 len, guint32 now) guint32 offset, guint32 len, guint32 now)
{ {
PseudoTcpSocketPrivate *priv = self->priv; PseudoTcpSocketPrivate *priv = self->priv;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment