Error Functions
When something goes wrong inside libpcap, the library provides robust functionality for determining what caused the error. In most cases, when a pcap descriptor is created, if an error occurs within its context, you can call pcap_perror() or pcap_geterr() to give the user information as to why it happened. For functions within libpcap that do not reference a particular descriptor but can exit with an error, you can pass in a character buffer pointer as an argument to contain any possible warnings or errors.
void pcap_perror(pcap_t *p, char *prefix);
pcap_perror() prints to STDERR (standard error) the text of the last error message that happened within the context of the pcap descriptor that p referenced. prefix is a string that will be output before the error message which should be used to provide context to the error condition.
char *pcap_geterr(pcap_t *p);
pcap_geterr() culls the last error message that happened within the context of the pcap descriptor that p referenced and returns the string. If no error has occurred, the function returns NULL.
char *pcap_strerror(int error);
pcap_strerror() is a wrapper to the standard libc function strerror() if the system has it. If not, libpcap implements strerrror() itself.