6
6
#include "packet.h"
7
7
#include "buffer.h"
8
8
#include "core.h"
9
+ #include "util.h"
9
10
10
11
extern conn_t connection ;
11
12
@@ -42,10 +43,7 @@ int packet_new_handshake(packet_t *packet)
42
43
{
43
44
char buffer [8 * sizeof (uint32_t )];
44
45
uint32_t * p = NULL ;
45
- uint32_t type = 0 ,
46
- isn = 0 ,
47
- mss = 0 ,
48
- flight_flag_size = 0 ,
46
+ uint32_t flight_flag_size = 0 ,
49
47
id = 0 ,
50
48
req_type = 0 ,
51
49
cookie = 0 ;
@@ -58,9 +56,9 @@ int packet_new_handshake(packet_t *packet)
58
56
59
57
p = (uint32_t * ) buffer ;
60
58
* p ++ = UDT_VERSION ;
61
- * p ++ = type ;
62
- * p ++ = isn ;
63
- * p ++ = mss ;
59
+ * p ++ = connection . type ;
60
+ * p ++ = 123123 ; /* TODO: Generate random number */
61
+ * p ++ = MAX_PACKET_SIZE ;
64
62
* p ++ = flight_flag_size ;
65
63
* p ++ = req_type ;
66
64
* p ++ = id ;
@@ -76,6 +74,7 @@ void packet_parse(packet_t packet)
76
74
switch (packet_get_type (packet )) {
77
75
78
76
case PACKET_TYPE_HANDSHAKE : /* handshake */
77
+ console_log ("packet: handshake" );
79
78
if (connection .is_client ) {
80
79
handshake_terminate ();
81
80
break ;
@@ -86,37 +85,47 @@ void packet_parse(packet_t packet)
86
85
break ;
87
86
88
87
case PACKET_TYPE_KEEPALIVE : /* keep-alive */
88
+ console_log ("packet: keep alive" );
89
89
break ;
90
90
91
91
case PACKET_TYPE_ACK : /* ack */
92
+ console_log ("packet: ack" );
92
93
break ;
93
94
94
95
case PACKET_TYPE_NAK : /* nak */
96
+ console_log ("packet: nak" );
95
97
break ;
96
98
97
99
case PACKET_TYPE_CONGDELAY : /* congestion-delay warn */
100
+ console_log ("packet: congestion delay" );
98
101
break ;
99
102
100
103
case PACKET_TYPE_SHUTDOWN : /* shutdown */
104
+ console_log ("packet: shutdown" );
101
105
connection .is_open = 0 ;
102
106
connection .is_connected = 0 ;
103
107
break ;
104
108
105
109
case PACKET_TYPE_ACK2 : /* ack of ack */
110
+ console_log ("packet: ack of ack" );
106
111
break ;
107
112
108
113
case PACKET_TYPE_DROPREQ : /* message drop request */
114
+ console_log ("packet: drop request" );
109
115
break ;
110
116
111
117
case PACKET_TYPE_ERRSIG : /* error signal */
118
+ console_log ("packet: error signal" );
112
119
break ;
113
120
114
121
default : /* unsupported packet type */
115
- recv_buffer_write ( "Unknown message" , 16 );
122
+ console_log ( "packet: unknown" );
116
123
117
124
}
118
125
} else { /* data packet */
119
126
127
+ console_log ("packet: data" );
128
+
120
129
if (packet .header ._head1 & 0x80000000 &&
121
130
packet .header ._head1 & 0x40000000 ) /* solo packet */
122
131
recv_buffer_write (packet .data , PACKET_DATA_SIZE );
0 commit comments