#include <common.h>
Public Member Functions | |
PacketHdr () | |
void | init () |
short | getShortIntegerInfo (int position) |
int | getIntegerInfo (int position) |
char * | accessInfo () |
int | getSize () |
void | setIntegerInfo (int a, int position) |
void | setShortIntegerInfo (short b, int position) |
void | setOctet (unsigned char c, int position) |
void | setHeaderSize (int len) |
unsigned char | getOctet (int position) |
Protected Attributes | |
unsigned char * | info_ |
pointer to the header's content | |
int | length_ |
length of the header |
Packethdr is an entity which represents the packet header portion of a packet. Important protocol information fields are stored in the header.
Definition at line 32 of file common.h.
|
Get a pointer to the actual information header . Definition at line 51 of file common.h. References info_. Referenced by Packet::extractHeader(), and Packet::makePacket(). 00051 {return info_;}
|
|
read the information filed at "postion" as a 32-bit integer Definition at line 16 of file common.cpp. References info_. 00017 { 00018 int val; 00019 unsigned char *p = info_ +position; 00020 val = *(p++); 00021 val = val << 8 | *(p++); 00022 val = val << 8 | *(p++); 00023 val = val << 8 | *(p++); 00024 00025 return val; 00026 }
|
|
get an octet Definition at line 75 of file common.h. References info_. 00075 { return info_[position];}
|
|
read the information filed at "postion" as a short integer Definition at line 28 of file common.cpp. References info_. 00029 { 00030 short val; 00031 unsigned char *p = info_ + position; 00032 val = *(p++); 00033 val = val << 8 | *(p++); 00034 00035 return val; 00036 }
|
|
get the length(size) of the header Definition at line 55 of file common.h. References length_. Referenced by Packet::getHeaderSize(), and Packet::makePacket(). 00055 { return length_; }
|
|
Clear all information fileds as empty Definition at line 39 of file common.h. References info_. 00039 {memset(info_,0,MAX_HEADER_SIZE );}
|
|
Set the header size Definition at line 71 of file common.h. References length_. Referenced by Packet::extractHeader(). 00071 { length_ =len; }
|
|
set a 4-byte(32-bit) information field with an integer Definition at line 38 of file common.cpp. References info_, and length_. 00039 { 00040 unsigned char *p = info_ + position; 00041 *(p++) = a >> 24; 00042 *(p++) = (a >> 16) & 0xFF; 00043 *(p++) = (a >> 8) & 0xFF; 00044 *(p++) = a & 0xFF; 00045 length_ +=4; 00046 }
|
|
set one octet as a desired character An octet in computer networking is an eight bit quantity Definition at line 67 of file common.h. References info_, and length_.
|
|
set a 2-byte(16-bit) information field with an short integer Definition at line 48 of file common.cpp. References info_, and length_. 00049 { 00050 unsigned char *p = info_ + position; 00051 *(p++) = b >> 8; 00052 *(p++) = b & 0xFF; 00053 length_+=2; 00054 }
|