ip_packet Class Reference

The ip_packet class contains the information extracted from a packet received using pcap for packets that are IP/TCP or IP/UDP. We only save src and dst addresses and ports, and type of Transport protocol. The class hinerates the fields hardware address field because every IP packet is part of a ethernet packet. The remaining packet is stored as payload. More...

`#include <ip_packet.h>`

Inheritance diagram for ip_packet:

## Public Member Functions

| ip_packet ()
| Constructor.
void | setIPSAddress (string)
| Saves the source IP address in std string format. More...
void | setIPDAddress (string)
| Saves the destination IP address in std string format. More...
void | setIPProto (char)
| Saves the IP protocol to (TCP|UDP) More...
void | setIPSPort (unsigned short)
| Saves the source port. More...
void | setIPDPort (unsigned short)
| Saves the destinaation port. More...
void | setPayload (char *, int)
| Saves the payload string of bytes into a string. More...
string | getIPSAddress ()
| Returns the source IP address. More...
string | getIPDAddress ()
| Returns the destination IP address. More...
string | getPayload ()
| Returns the IP packet payload. More...
char | getIPProto ()
| Returns the IP protocol type. More...
unsigned short | getIPSPort ()
| Returns the source port. More...
unsigned short | getIPDPort ()
| Returns the destination port. More...
Public Member Functions inherited from ethernet_packet
| ethernet_packet ()
| Constructor, does nothing.
void | setEtherDHost (u_char[])
| Receives the array of 6 bytes of a destination host. More...
void | setEtherSHost (u_char[])
| Receives the array of 6 bytes of a source host. More...
void | setEtherType (u_short)
| Set the Ethernet type. More...
string | getEtherDHost ()
| Returns the destination HA in string format. More...
string | getEtherSHost ()
| Returns the source HA in string format. More...
u_short | getEtherType ()
| Returns the Ethernet type. More...

## Private Attributes

string | ip_src
string | ip_dst
char | ip_p
unsigned short | d_port
unsigned short | s_port
string | payload

## Detailed Description

The ip_packet class contains the information extracted from a packet received using pcap for packets that are IP/TCP or IP/UDP. We only save src and dst addresses and ports, and type of Transport protocol. The class hinerates the fields hardware address field because every IP packet is part of a ethernet packet. The remaining packet is stored as payload.

## Member Function Documentation

string ip_packet::getIPDAddress | ( |  | ) |

Returns the destination IP address.

Returns
  the destination IP address

unsigned short ip_packet::getIPDPort | ( |  | ) |

Returns the destination port.

Returns
  the destination port

Devuelve el puerto destino

Returns
  el puerto destino

char ip_packet::getIPProto | ( |  | ) |

Returns the IP protocol type.

Returns
  the IP protocol

string ip_packet::getIPSAddress | ( |  | ) |

Returns the source IP address.

Returns
  the source IP address

unsigned short ip_packet::getIPSPort | ( |  | ) |

Returns the source port.

Returns
  the source port

Devuelve el puerto fuente

Returns
  el puerto fuente

string ip_packet::getPayload | ( |  | ) |

Returns the IP packet payload.

Returns
  the IP packet payload

void ip_packet::setIPDAddress | ( | string | addr | ) |

Saves the destination IP address in std string format.

Parameters

  addr | destination IP address

void ip_packet::setIPDPort | ( | unsigned short | port | ) |

Saves the destinaation port.

Parameters

  port | destination port

void ip_packet::setIPProto | ( | char | proto | ) |

Saves the IP protocol to (TCP|UDP)

Parameters

  proto | protocol number (6 | 17)

void ip_packet::setIPSAddress | ( | string | addr | ) |

Saves the source IP address in std string format.

Parameters

  addr | source IP address

void ip_packet::setIPSPort | ( | unsigned short | port | ) |

Saves the source port.

Parameters

  port | source port

void ip_packet::setPayload | ( | char * | pl,
|  | int | len
| ) |  |

Saves the payload string of bytes into a string.

Parameters

  pl | the packet payload
  len | length of the payload

## Member Data Documentation

unsigned short ip_packet::d_port

private

destination port / puerto destino

string ip_packet::ip_dst

private

source and dest address / direccion fuente y destino

char ip_packet::ip_p

private

type of transport protocol (TCP|UDP) | tipo de protocolo de transporte (TCP|UDP)

string ip_packet::payload

private

Data payload (content of the packet) / carga del paquete

unsigned short ip_packet::s_port

private

source port / puerto fuente

The documentation for this class was generated from the following files:

- ip_packet.h
- ip_packet.cpp