[go: up one dir, main page]

Menu

[r999]: / trunk / VTS3 / VTSPacket.cpp  Maximize  Restore  History

Download this file

764 lines (628 with data), 18.6 kB

  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
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
// VTSPacket.cpp: implementation of the VTSPacketKill class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "vts.h"
#include "VTSPacket.h"
#include "VTSDoc.h"
#include "PI.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//
// VTSPacketHeader::VTSPacketHeader
//
// The packet header contains information about the packet: where it
// came from, where it was going, how to interpret the contents, etc.
//
VTSPacketHeader::VTSPacketHeader( void )
: packetProtocolID(0) // protocol identifier for decoding
, packetFlags(0) // protocol specific flags
, packetType(txData) // not really transmit
, packetSource(nullAddr) // source address
, packetDestination(nullAddr) // destination address
{
::GetSystemTimeAsFileTime( &packetTime ); // gets current time
memset(m_szPortName, 0, sizeof(m_szPortName));
}
//
// VTSPacket::VTSPacket
//
// If the packet is constructed with known data (the length is non-zero
// and the data is not null) then the packet just uses that information
// rather than make a copy of it. The idea is to keep the amount of
// buffer creation and memory copies to a minimum.
//
// In the ReadPacket function, the packet is created without data, then
// new data is provided once the information is available from the database.
// Because the database object is released, it is important to make a copy.
// The application may use the same packet object in multiple reads (like
// in a search loop).
//
VTSPacket::VTSPacket( int len, BACnetOctetPtr data )
: packetHdr() // empty header
, ownData(false) // packet does not own data
, packetLen(0) // number of octets in data
, packetData(0) // pointer to data
{
// make a reference to the data
if (len != 0) {
packetLen = len;
packetData = data;
}
bErrorDecode = FALSE;
}
//
// VTSPacket::~VTSPacket
//
// If the packet owns its data pointer, delete it.
//
VTSPacket::~VTSPacket( void )
{
// toss current data iff owned
if (ownData && packetData)
delete[] packetData;
}
//
// VTSPacket::NewData
//
// This function is called when the packet contents should reflect a new
// record from the database.
//
void VTSPacket::NewData( BACnetOctetPtr data, int len )
{
// toss current data iff owned
if (ownData && packetData)
delete[] packetData;
// take ownership of the pointer
ownData = true;
// make a copy of the data
packetLen = len;
packetData = new BACnetOctet[ len ];
memcpy( packetData, data, len );
}
//
// VTSPacket::NewDataRef
//
// This function is called when the packet contents should reflect new data
// and the application knows that the packet will be destroyed at the time
// the packet goes away (no dangling pointers).
//
void VTSPacket::NewDataRef( BACnetOctetPtr data, int len, bool fOwned /* = false */ )
{
// toss current data iff owned
if (ownData && packetData)
delete[] packetData;
// this is not owned data
ownData = fOwned; // MAD_DB
// refer to the new data
packetLen = len;
packetData = data;
}
VTSPacket::VTSPacket( const VTSPacket& pkt)
{
if(this != &pkt)
{
memcpy(&packetHdr, &pkt.packetHdr, sizeof(packetHdr));
ownData = false;
packetData = 0;
packetLen = 0;
NewData(pkt.packetData, pkt.packetLen);
}
}
void VTSPacket::operator =( const VTSPacket& pkt)
{
memcpy(&packetHdr, &pkt.packetHdr, sizeof(packetHdr));
NewData(pkt.packetData, pkt.packetLen);
}
LPCSTR VTSPacket::GetTimeStampString()
{
FILETIME locFileTime;
SYSTEMTIME st;
static char theTime[16];
::FileTimeToLocalFileTime( &packetHdr.packetTime, &locFileTime );
::FileTimeToSystemTime( &locFileTime, &st );
sprintf( theTime, "%02d:%02d:%02d.%03d", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
// Warning... must do something with this before calling this method again
// or data will be overwritten
return theTime;
}
LPCSTR VTSPacket::GetAddressString( VTSDoc *pdoc, bool bSource, bool bIncludeNetwork ) const
{
static CString nameBuffer;
nameBuffer.Empty();
if (bIncludeNetwork)
{
// If the packet was routed, get the remote destination
BACnetAddress remoteAddr;
bool hasNetwork = false;
if (bSource)
{
// Look for SNET/SADDR
hasNetwork = GetNetworkSource( remoteAddr );
}
else
{
// Look for DNET/DADDR
hasNetwork = GetNetworkDestination( remoteAddr );
}
if (hasNetwork)
{
// Look for Name for remoteAddress
if (pdoc != NULL)
nameBuffer = pdoc->AddrToName( remoteAddr, packetHdr.m_szPortName );
if (nameBuffer.IsEmpty())
{
// Show network and MAC
nameBuffer.Format( "(%d, %s)", remoteAddr.addrNet, remoteAddr.MacAddress() );
}
nameBuffer += " via ";
}
}
const BACnetAddress *paddr = bSource ? &packetHdr.packetSource : &packetHdr.packetDestination;
// attempt to resolve name... if no doc supplied, we can't, but no harm done.
CString str;
if (pdoc != NULL)
str = pdoc->AddrToName( *paddr, packetHdr.m_szPortName );
if (str.IsEmpty())
{
switch(packetHdr.packetProtocolID)
{
case BACnetPIInfo::ipProtocol:
str = BACnetIPAddr::AddressToString(paddr);
break;
case BACnetPIInfo::ethernetProtocol:
case BACnetPIInfo::arcnetProtocol:
case BACnetPIInfo::mstpProtocol:
case BACnetPIInfo::ptpProtocol:
case BACnetPIInfo::msgProtocol:
default:
str = paddr->MacAddress();
break;
}
}
// Warning... must do something with this before calling this method again
// or data will be overwritten
nameBuffer += str;
return (LPCSTR)nameBuffer;
}
// Return the offset to the NPDU.
// If there is no NPDU, return packetData, causing caller to bail
int VTSPacket::FindNPDUStartPos() const
{
int retval = 0;
if (packetData == NULL)
{
// Claim end of PDU: caller will say "not enough data" and bail
return packetLen;
}
switch ((BACnetPIInfo::ProtocolType)packetHdr.packetProtocolID)
{
case BACnetPIInfo::ipProtocol:
// skip the fake ip header, address (4), and port (2)
retval += 6;
// BVLC. Must have room for 0x81, function byte, and 2 length bytes
if ((retval+4 < packetLen) && (packetData[retval] == 0x81))
{
retval++;
// extract the function
int func = packetData[retval];
retval += 3; //BVLC Function: 1 bytes; BVLC Length: 2 bytes
// set the function group
switch ((BVLCFunction)func)
{
case bvlcDistributeBroadcastToNetwork:
case bvlcOriginalUnicastNPDU:
case bvlcOriginalBroadcastNPDU:
// These have an NPDU
break;
case blvcForwardedNPDU:
// Has an NPDU just after the forwarded-from address
retval += 6;
break;
case bvlcResult:
case blvcWriteBroadcastDistributionTable:
case blvcReadBroadcastDistributionTable:
case blvcReadBroadcastDistributionTableAck:
case bvlcRegisterForeignDevice:
case bvlcReadForeignDeviceTable:
case bvlcReadForeignDeviceTableAck:
case bvlcDeleteForeignDeviceTableEntry:
default:
// BVLC messages with no NPDU.
// Set bogus offset so caller will bail
retval = packetLen;
break;
}
}
else
{
// Set bogus offset so caller will bail
retval = packetLen;
}
break;
case BACnetPIInfo::ethernetProtocol:
// skip over source (6), destination (6), length (2), and SAP (3)
// Our WinPCAP filter will give us only frames with proper
// BACnet DSAP, SSAP, and LLC, so this is safe
retval += 17;
break;
case BACnetPIInfo::arcnetProtocol:
// skip over source (1), destination (1), SAP (3), LLC (1)
retval += 6;
break;
case BACnetPIInfo::mstpProtocol:
// skip over preamble
// TODO: if this really IS preamble, then need to bypass addresses,
// then look at frame type to be sure there is an NPDU
retval += 2;
break;
case BACnetPIInfo::msgProtocol:
case BACnetPIInfo::textMsgProtocol:
// Not a PDU. Claim end of PDU so caller will say "not enough data" and bail
retval = packetLen;
break;
}
return retval;
}
// Get SNET and SADDR, else return false
bool VTSPacket::GetNetworkSource( BACnetAddress &theAddress ) const
{
int ix = FindNPDUStartPos();
if (packetLen - ix < 2)
return false;
if (!(packetData[ix + 1] & 0x08)) // SNET doesn't exist
return false;
if (packetData[ix + 1] & 0x20)
{
// Skip over DNET/DADR
ix = ix + 3 + packetData[ix + 4];
}
ix += 2;
theAddress.addrNet = (packetData[ix] << 8) | packetData[ix + 1];
int len = packetData[ ix + 2 ];
theAddress.addrLen = len;
memcpy( theAddress.addrAddr, packetData + ix + 3, len );
theAddress.addrType = (len == 0) ? remoteBroadcastAddr : remoteStationAddr;
return true;
}
// Get DNET and DADDR, else return false
bool VTSPacket::GetNetworkDestination( BACnetAddress &theAddress ) const
{
int ix = FindNPDUStartPos();
if (packetLen - ix < 2)
return false;
if (!(packetData[ix + 1] & 0x20)) // DNET doesn't exist
return false;
ix += 2;
theAddress.addrNet = (packetData[ix] << 8) | packetData[ix + 1];
int len = packetData[ ix + 2 ];
theAddress.addrLen = len;
memcpy( theAddress.addrAddr, packetData + ix + 3, len );
theAddress.addrType = (len == 0) ? remoteBroadcastAddr : remoteStationAddr;
return true;
}
BOOL VTSPacket::GetSNET(unsigned short& snet) const
{
int npduindex = FindNPDUStartPos();
if (packetLen - npduindex < 2)
return FALSE;
if (!(packetData[npduindex + 1] & 0x08)) //SNET doesn't exist
return FALSE;
int index = 2;
if (packetData[npduindex + 1] & 0x20) //DNET and DADR exist
{
index = index + 3 + packetData[npduindex + 4];
}
snet = packetData[npduindex + index];
snet = (snet << 8) | packetData[npduindex + index + 1];
return TRUE;
}
CString VTSPacket::GetSADRString(VTSDoc * pdoc, BOOL bAlias) const
{
CString sadrStr;
BACnetAddress sadr;
if (GetNetworkSource( sadr ))
{
if (pdoc != NULL && bAlias)
sadrStr = pdoc->AddrToName(sadr, packetHdr.m_szPortName);
if (sadrStr == "")
{
// The original called BACnetAddr::ToString.
// But that shows as {net,mac}, and we want only the MAC here
sadrStr = sadr.MacAddress();
}
}
return sadrStr;
}
BOOL VTSPacket::GetDNET(unsigned short& dnet) const
{
CString str;
BACnetAddress dadr;
int npduindex = FindNPDUStartPos();
if (packetLen - npduindex< 2)
return FALSE;
if( !(packetData[npduindex + 1] & 0x20) ) //DNET and DADR don't exist
return FALSE;
dnet = packetData[npduindex + 2];
dnet = (dnet << 8) | packetData[npduindex + 3];
return TRUE;
}
CString VTSPacket::GetDADRString(VTSDoc * pdoc, BOOL bAlias) const
{
CString dadrStr;
BACnetAddress dadr;
if (GetNetworkDestination( dadr ))
{
if (pdoc != NULL && bAlias)
dadrStr = pdoc->AddrToName(dadr, packetHdr.m_szPortName);
if (dadrStr == "")
{
// The original called BACnetAddr::ToString.
// But that shows as {net,mac}, and we want only the MAC here
dadrStr = dadr.MacAddress();
}
}
return dadrStr;
}
BOOL VTSPacket::SetDesAddress(BACnetAddress& addr)
{
switch(packetHdr.packetProtocolID)
{
case BACnetPIInfo::ipProtocol:
if(addr.addrLen != 6)
return FALSE;
memcpy(packetData, addr.addrAddr, 6);
break;
case BACnetPIInfo::ethernetProtocol:
break;
case BACnetPIInfo::mstpProtocol:
break;
}
return TRUE;
}
BOOL VTSPacket::SetSNET(unsigned short snet, BOOL bReserveSnet)
{
BOOL bDnet = FALSE;
BOOL bSnet = FALSE;
int npduindex = FindNPDUStartPos();
if (packetLen - npduindex < 2)
return FALSE;
if(!(packetData[npduindex + 1] & 0x08)) //SNET doesn't exist
{
bSnet = FALSE;
}
else
{
bSnet = TRUE;
}
if(packetData[npduindex + 1] & 0x20) //DNET and DADR exist
{
bDnet = TRUE;
}
else
{
bDnet = FALSE;
}
if( bSnet )
{
if( bReserveSnet )
{
if( bDnet )
{
unsigned char dlen = packetData[npduindex + 4];
packetData[npduindex + 5 + dlen] = (snet & 0xFF00) >> 8;
packetData[npduindex + 6 + dlen] = (snet & 0x00FF);
}
else
{
packetData[npduindex + 2] = (snet & 0xFF00) >> 8;
packetData[npduindex + 3] = (snet & 0x00FF);
}
}
else
{
packetData[npduindex + 1] &= 0xF7; //set SNET bit 0
BACnetOctetPtr oldbuff = packetData;
int oldPacketLen = packetLen;
if( bDnet )
{
unsigned char dlen = oldbuff[npduindex + 4];
unsigned char slen = oldbuff[npduindex + 7 + dlen];
packetLen -= 3 + slen;
packetData = new BACnetOctet[packetLen];
memcpy(packetData, oldbuff, npduindex + 5 + dlen);
memcpy(packetData + npduindex + 5 + dlen, oldbuff + npduindex + 8 + dlen + slen,
oldPacketLen - (npduindex + 8 + dlen + slen));
}
else
{
unsigned char slen = oldbuff[npduindex + 4];
packetLen -= 3 + slen;
packetData = new BACnetOctet[packetLen];
memcpy(packetData, oldbuff, npduindex + 2);
memcpy(packetData + npduindex + 2, oldbuff + npduindex + 5 + slen,
oldPacketLen - (npduindex + 5 + slen));
}
delete[] oldbuff;
}
}
else
{
if( bReserveSnet )
{
packetData[npduindex + 1] |= 0x08; //set SNET bit 1
BACnetOctetPtr oldbuff = packetData;
int oldPacketLen = packetLen;
packetLen += 3;
packetData = new BACnetOctet[packetLen];
if( bDnet )
{
unsigned char dlen = oldbuff[npduindex + 4];
memcpy(packetData, oldbuff, npduindex + 5 + dlen);
packetData[npduindex + 5 + dlen] = (snet & 0xFF00) >> 8;
packetData[npduindex + 6 + dlen] = (snet & 0x00FF);
packetData[npduindex + 7 + dlen] = 0; //slen = 0
memcpy(packetData + npduindex + 8 + dlen, oldbuff + npduindex + 5 + dlen,
oldPacketLen - (npduindex + 5 + dlen));
}
else
{
memcpy(packetData, oldbuff, npduindex + 2);
packetData[npduindex + 2] = (snet & 0xFF00) >> 8;
packetData[npduindex + 3] = (snet & 0x00FF);
packetData[npduindex + 4] = 0; //slen = 0
memcpy(packetData + npduindex + 5, oldbuff + npduindex + 2,
oldPacketLen - (npduindex + 2));
}
}
}
return TRUE;
}
//bReserveDnet = FALSE, ignore parameter 'dnet', delete DNET/DLEN/DADR from packet if they exit
//
BOOL VTSPacket::SetDNET(unsigned short dnet, BOOL bReserveDnet)
{
CString str;
BACnetAddress dadr;
BOOL bDnet = FALSE;
BOOL bSnet = FALSE;
int npduindex = FindNPDUStartPos();
if (packetLen - npduindex< 2)
return FALSE;
if( !(packetData[npduindex + 1] & 0x20) )
bDnet = FALSE; //DNET and DADR don't exist
else
bDnet = TRUE;
if(!(packetData[npduindex + 1] & 0x08))
bSnet = FALSE; //SNET doesn't exist
else
bSnet = TRUE;
if( bDnet )
{
if( bReserveDnet )
{
packetData[npduindex + 2] = (dnet & 0xFF00) >> 8;
packetData[npduindex + 3] = (dnet & 0x00FF);
}
else
{
packetData[npduindex + 1] &= 0xDF; //set DNET bit 0
unsigned char dlen = packetData[npduindex + 4];
BACnetOctetPtr oldbuff = packetData;
int oldPacketLen = packetLen;
packetLen = packetLen - 4 - dlen; //DNET 2 bytes, DLEN 1 byte, DADR dlen bytes, Hop Count 1 byte
packetData = new BACnetOctet[packetLen];
memcpy(packetData, oldbuff, npduindex + 2);
if( bSnet )
{
unsigned char slen = oldbuff[npduindex + 7 + dlen];
memcpy(packetData + npduindex + 2, oldbuff + npduindex + 5 + dlen,
3 + slen);
memcpy(packetData + npduindex + 5 + slen, oldbuff + npduindex + 9 + dlen + slen,
oldPacketLen - (npduindex + 9 + dlen + slen));
}
else
{
memcpy(packetData + npduindex + 2, oldbuff + npduindex + 6 + dlen,
oldPacketLen - (npduindex + 6 + dlen)); //do not forget hopcount byte
}
delete[] oldbuff;
}
}
else
{
if( bReserveDnet )
{
packetData[npduindex + 1] |= 0x20; //set DNET bit 1
BACnetOctetPtr oldbuff = packetData;
int oldPacketLen = packetLen;
packetLen = packetLen + 4; //add DNET and DLEN and Hop Count, 4 byte
packetData = new BACnetOctet[packetLen];
memcpy(packetData, oldbuff, npduindex + 2);
packetData[npduindex + 2] = (dnet & 0xFF00) >> 8;
packetData[npduindex + 3] = (dnet & 0x00FF);
packetData[npduindex + 4] = 0; //dlen = 0
if( bSnet )
{
unsigned char slen = oldbuff[npduindex + 4];
memcpy(packetData + npduindex + 5, oldbuff + npduindex + 2, 3 + slen);
packetData[npduindex + 8 + slen] = 0; //hopcount = 0
memcpy(packetData + npduindex + 9 + slen, oldbuff + npduindex + 5 + slen,
oldPacketLen - (npduindex + 5 + slen));
}
else
{
packetData[npduindex + 5] = 0; //hopcount = 0
memcpy(packetData + npduindex + 6, oldbuff + npduindex + 2,
oldPacketLen - (npduindex + 2));
}
delete[] oldbuff;
}
}
return TRUE;
}
BOOL VTSPacket::SetDADR(unsigned char *dadr, unsigned int len)
{
int npduindex = FindNPDUStartPos();
if (packetLen - npduindex< 2)
return FALSE;
if( !(packetData[npduindex + 1] & 0x20) ) //DNET and DADR don't exist
return FALSE;
unsigned char dlen = packetData[npduindex + 4];
if( dlen == len )
{
memcpy(packetData + npduindex + 5, dadr, dlen);
}
else
{
BACnetOctetPtr oldbuff = packetData;
int oldPacketLen = packetLen;
packetLen = packetLen + len - dlen;
packetData = new BACnetOctet[packetLen];
memcpy(packetData, oldbuff, npduindex + 4);
packetData[npduindex + 4] = len;
memcpy(packetData + npduindex + 5, dadr, len);
memcpy(packetData + npduindex + 5 + len, oldbuff + npduindex + 5 + dlen,
oldPacketLen - (npduindex + 5 + dlen));
delete[] oldbuff;
}
return TRUE;
}
BOOL VTSPacket::SetSADR(unsigned char *sadr, unsigned int len)
{
int npduindex = FindNPDUStartPos();
if (packetLen - npduindex < 2)
return FALSE;
if(!(packetData[npduindex + 1] & 0x08)) //SADR doesn't exist
return FALSE;
int index = 4;
if(packetData[npduindex + 1] & 0x20) //DNET and DADR exist
{
index = index + 3 + packetData[npduindex + 4];
}
unsigned char slen = packetData[npduindex + index];
if( slen == len )
{
memcpy(packetData + npduindex + index + 1, sadr, slen);
}
else
{
BACnetOctetPtr oldbuff = packetData;
int oldPacketLen = packetLen;
packetLen = packetLen + len - slen;
packetData = new BACnetOctet[packetLen];
memcpy(packetData, oldbuff, npduindex + index);
packetData[npduindex + index] = len;
memcpy(packetData + npduindex + index + 1, sadr, len);
memcpy(packetData + npduindex + index + 1 + len, oldbuff + npduindex + index + 1 + slen,
oldPacketLen - (npduindex + index + 1 + slen));
delete[] oldbuff;
}
return TRUE;
}