BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB-UTIL Reference

Data Structures

struct  pj_pcap_udp_hdr
struct  pj_pcap_filter

Typedefs

typedef struct pj_pcap_file pj_pcap_file

Enumerations

enum  pj_pcap_link_type { PJ_PCAP_LINK_TYPE_ETH = 1 }
enum  pj_pcap_proto_type { PJ_PCAP_PROTO_TYPE_UDP = 17 }

Functions

void pj_pcap_filter_default (pj_pcap_filter *filter)
pj_status_t pj_pcap_open (pj_pool_t *pool, const char *path, pj_pcap_file **p_file)
pj_status_t pj_pcap_close (pj_pcap_file *file)
pj_status_t pj_pcap_set_filter (pj_pcap_file *file, const pj_pcap_filter *filter)
pj_status_t pj_pcap_read_udp (pj_pcap_file *file, pj_pcap_udp_hdr *udp_hdr, pj_uint8_t *udp_payload, pj_size_t *udp_payload_size)

Detailed Description

This module describes simple utility to read PCAP file. It is not intended to support all PCAP features (that's what libpcap is for!), but it can be useful for example to playback or stream PCAP contents.


Typedef Documentation

typedef struct pj_pcap_file pj_pcap_file

Opaque declaration for PCAP file


Enumeration Type Documentation

Enumeration to describe supported data link types.

Enumerator:
PJ_PCAP_LINK_TYPE_ETH 

Ethernet data link

Enumeration to describe supported protocol types.

Enumerator:
PJ_PCAP_PROTO_TYPE_UDP 

UDP protocol


Function Documentation

pj_status_t pj_pcap_close ( pj_pcap_file file)

Close PCAP file.

Parameters:
filePCAP file handle.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
void pj_pcap_filter_default ( pj_pcap_filter filter)

Initialize filter with default values. The default value is to allow any packets.

Parameters:
filterFilter to be initialized.
pj_status_t pj_pcap_open ( pj_pool_t pool,
const char *  path,
pj_pcap_file **  p_file 
)

Open PCAP file.

Parameters:
poolPool to allocate memory.
pathFile/path name.
p_filePointer to receive PCAP file handle.
Returns:
PJ_SUCCESS if file can be opened successfully.
pj_status_t pj_pcap_read_udp ( pj_pcap_file file,
pj_pcap_udp_hdr udp_hdr,
pj_uint8_t udp_payload,
pj_size_t udp_payload_size 
)

Read UDP payload from the next packet in the PCAP file. Optionally it can return the UDP header, if caller supplies it.

Parameters:
filePCAP file handle.
udp_hdrOptional buffer to receive UDP header.
udp_payloadBuffer to receive the UDP payload.
udp_payload_sizeOn input, specify the size of the buffer. On output, it will be filled with the actual size of the payload as read from the packet.
Returns:
PJ_SUCCESS on success, or the appropriate error code.
pj_status_t pj_pcap_set_filter ( pj_pcap_file file,
const pj_pcap_filter filter 
)

Configure filter for reading the file. When filter is configured, only packets matching all the filter settings will be returned.

Parameters:
filePCAP file handle.
filterThe filter.
Returns:
PJ_SUCCESS on success, or the appropriate error code.

 


PJLIB-UTIL Open Source, small footprint, and portable asynchronous/caching DNS resolver, text scanner, STUN client, and XML library
Copyright (C) 2006-2009 Teluu Inc.