PGEN-IO has many IO-functions. It absorbs the difference of each OS.


Function List


pgen_open();                 –> Open PGEN-discripter available handling network interface

pgen_open_offline();         –> Open PGEN-discripter available handling pcap file

pgen_close();                –> Close PGEN-discripter

pgen_sendpacket_handle();    –> Send binary with PGEN-discripter

pgen_sendpacket_L3();        –> Send binary to L3 network interface from device-name

pgen_sendpacket_L2();        –> send binary to L2 network interface from device-name

pgen_perror();             –> print custom error message

More information, please see below.


pgen_send_to_netif ();       –> Send binary to network-interface with datalink socket

pgen_recv_from_netif_to();   –> Recv binary from network-interface with datalink socket

pgen_recv_from_netif();      –> Timeout recv binary from network-interface with datalink socket

pgen_getipbydev();           –> Get IP address from network-interface

pgen_getmaskbydev();         –> Get NetMask from network-interface

pgen_getmacbydev();          –> Get Mac address from network-interface

pgen_port2service();         –> Get service from port-number

More information, please see PGEN-Netutil.


pgen_send_to_pcap();         –> Send binary to file with file pointer

pgen_recv_from_pcap();       –> Recv binary from file with file pointer

pgen_hex();                  –> Hexdump function

More information, please see PGEN-Util.


pgen_strerror();             –> Get error message that is char* string from error number

More information, please see PGEN-Error.


PGEN-IO Function Usage


pgen_open — open PGEN descripter that operates network interfaces.
pgen_open_offline — open PGEN descripter that operates pcap files.
pgen_close   — closing PGEN descripter

pgen_sendpacket_L2   — send binary to interface

pgen_perror  — print error message




pgen_open() allocates a new PGEN descriptor that operates network interfaces.

device, 1st argument is device name. For example, “wlan0”, “en0”, “eth0”.. etc.
nouse, 2nd arugment is not implemented yet. Please assign NULL.

pgen_open_offline() allocates a new PGEN descriptor that operates pcap files.

filename, 1st argment is file name, users open.
open_type, 2nd argument is type READ-mode or WRITE-mode. This function can not allow READ/WRITE-mode.

open_type, There are some macros defined for users.
PCAP_READ   –> READ-mode

pgen_close() closes PGEN descriptor that allocated by pgen_open() and pgen_open_offline().

pgen_sendpacket_handle() sends binary to interface that opened PGEN descriptor.
pgen_sendpacket_L3() sends binary to interface that opened PGEN descriptor.

fd, 1st argment of pgen_sendpacket_handle is PGEN descriptor.
device, 1st argment of pgen_sendpacket_L2 is name of network interface.
buf, 2nd argment is buffer’s pointer.
len, 3rd argment is length of buffer.

pgen_perror() print the custom error message like perror().

msg, 1st argument is custom message that is char* string.

Return Value

pgen_open() and pgen_open_offline() return PGEN descriptor’s pointer, if that succeed to allocate PGEN descriptor. Else they return NULL.

pgen_sendpacket_handle() and pgen_sendpacket_L2() return  send length.


Comments are closed.