Subversion Repositories Kolibri OS

Rev

Rev 298 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 298 Rev 300
Line 137... Line 137...
137
 
137
 
138
 
138
 
139
//
139
//
140
// HSendPacket
-
 
141
//
-
 
142
void
-
 
143
HSendPacket
140
// HSendPacket
144
 (int	node,
141
//
145
  int	flags )
142
void HSendPacket (int node,int flags )
Line 146... Line 143...
146
{
143
{
147
    netbuffer->checksum = NetbufferChecksum () | flags;
144
    netbuffer->checksum = NetbufferChecksum () | flags;
Line 170... Line 167...
170
	if (netbuffer->checksum & NCMD_RETRANSMIT)
167
	if (netbuffer->checksum & NCMD_RETRANSMIT)
171
	    realretrans = ExpandTics (netbuffer->retransmitfrom);
168
	    realretrans = ExpandTics (netbuffer->retransmitfrom);
172
	else
169
	else
173
	    realretrans = -1;
170
	    realretrans = -1;
Line 174... Line 171...
174
 
171
 
175
	fprintf (debugfile,"send (%i + %i, R %i) [%i] ",
172
	printf ("send (%i + %i, R %i) [%i] ",
176
		 ExpandTics(netbuffer->starttic),
173
		 ExpandTics(netbuffer->starttic),
Line 177... Line 174...
177
		 netbuffer->numtics, realretrans, doomcom->datalength);
174
		 netbuffer->numtics, realretrans, doomcom->datalength);
178
	
175
	
Line 179... Line 176...
179
	for (i=0 ; idatalength ; i++)
176
	for (i=0 ; idatalength ; i++)
180
	    fprintf (debugfile,"%i ",((byte *)netbuffer)[i]);
177
	    printf ("%i ",((byte *)netbuffer)[i]);
Line 181... Line 178...
181
 
178
 
182
	fprintf (debugfile,"\n");
179
	printf ("\n");
Line 212... Line 209...
212
	return false;
209
	return false;
Line 213... Line 210...
213
 
210
 
214
    if (doomcom->datalength != NetbufferSize ())
211
    if (doomcom->datalength != NetbufferSize ())
215
    {
212
    {
216
	if (debugfile)
213
	if (debugfile)
217
	    fprintf (debugfile,"bad packet length %i\n",doomcom->datalength);
214
	    printf ("bad packet length %i\n",doomcom->datalength);
218
	return false;
215
	return false;
Line 219... Line 216...
219
    }
216
    }
220
	
217
	
221
    if (NetbufferChecksum () != (netbuffer->checksum&NCMD_CHECKSUM) )
218
    if (NetbufferChecksum () != (netbuffer->checksum&NCMD_CHECKSUM) )
222
    {
219
    {
223
	if (debugfile)
220
	if (debugfile)
224
	    fprintf (debugfile,"bad packet checksum\n");
221
	    printf ("bad packet checksum\n");
Line 225... Line 222...
225
	return false;
222
	return false;
226
    }
223
    }
227
 
224
 
228
    if (debugfile)
225
    if (debugfile)
Line 229... Line 226...
229
    {
226
    {
230
	int		realretrans;
227
	int		realretrans;
231
	int	i;
228
	int	i;
232
			
229
			
233
	if (netbuffer->checksum & NCMD_SETUP)
230
	if (netbuffer->checksum & NCMD_SETUP)
234
	    fprintf (debugfile,"setup packet\n");
231
	    printf ("setup packet\n");
235
	else
232
	else
236
	{
233
	{
Line 237... Line 234...
237
	    if (netbuffer->checksum & NCMD_RETRANSMIT)
234
	    if (netbuffer->checksum & NCMD_RETRANSMIT)
238
		realretrans = ExpandTics (netbuffer->retransmitfrom);
235
		realretrans = ExpandTics (netbuffer->retransmitfrom);
239
	    else
236
	    else
240
		realretrans = -1;
237
		realretrans = -1;
Line 241... Line 238...
241
	    
238
	    
242
	    fprintf (debugfile,"get %i = (%i + %i, R %i)[%i] ",
239
	    printf ("get %i = (%i + %i, R %i)[%i] ",
243
		     doomcom->remotenode,
240
		     doomcom->remotenode,
244
		     ExpandTics(netbuffer->starttic),
241
		     ExpandTics(netbuffer->starttic),
245
		     netbuffer->numtics, realretrans, doomcom->datalength);
242
		     netbuffer->numtics, realretrans, doomcom->datalength);
246
 
243
 
247
	    for (i=0 ; idatalength ; i++)
244
	    for (i=0 ; idatalength ; i++)
Line 304... Line 301...
304
	if ( resendcount[netnode] <= 0 
301
	if ( resendcount[netnode] <= 0 
305
	     && (netbuffer->checksum & NCMD_RETRANSMIT) )
302
	     && (netbuffer->checksum & NCMD_RETRANSMIT) )
306
	{
303
	{
307
	    resendto[netnode] = ExpandTics(netbuffer->retransmitfrom);
304
	    resendto[netnode] = ExpandTics(netbuffer->retransmitfrom);
308
	    if (debugfile)
305
	    if (debugfile)
309
		fprintf (debugfile,"retransmit from %i\n", resendto[netnode]);
306
		printf ("retransmit from %i\n", resendto[netnode]);
310
	    resendcount[netnode] = RESENDCOUNT;
307
	    resendcount[netnode] = RESENDCOUNT;
311
	}
308
	}
312
	else
309
	else
313
	    resendcount[netnode]--;
310
	    resendcount[netnode]--;
Line 317... Line 314...
317
	    continue;
314
	    continue;
Line 318... Line 315...
318
			
315
			
319
	if (realend < nettics[netnode])
316
	if (realend < nettics[netnode])
320
	{
317
	{
321
	    if (debugfile)
-
 
322
		fprintf (debugfile,
318
	    if (debugfile)
323
			 "out of order packet (%i + %i)\n" ,
319
		printf ("out of order packet (%i + %i)\n" ,
324
			 realstart,netbuffer->numtics);
320
			 realstart,netbuffer->numtics);
325
	    continue;
321
	    continue;
Line 326... Line 322...
326
	}
322
	}
327
	
323
	
328
	// check for a missed packet
324
	// check for a missed packet
329
	if (realstart > nettics[netnode])
325
	if (realstart > nettics[netnode])
330
	{
326
	{
331
	    // stop processing until the other system resends the missed tics
-
 
332
	    if (debugfile)
327
	    // stop processing until the other system resends the missed tics
333
		fprintf (debugfile,
328
	    if (debugfile)
334
			 "missed tics from %i (%i - %i)\n",
329
		printf ("missed tics from %i (%i - %i)\n",
335
			 netnode, realstart, nettics[netnode]);
330
			 netnode, realstart, nettics[netnode]);
336
	    remoteresend[netnode] = true;
331
	    remoteresend[netnode] = true;