Home --> Documentations --> PJLIB-UTIL Reference
00001 /* $Id: pcap.h 3553 2011-05-05 06:14:19Z nanang $ */ 00002 /* 00003 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 00004 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 #ifndef __PJLIB_UTIL_PCAP_H__ 00021 #define __PJLIB_UTIL_PCAP_H__ 00022 00028 #include <pj/types.h> 00029 00030 PJ_BEGIN_DECL 00031 00044 typedef enum pj_pcap_link_type 00045 { 00047 PJ_PCAP_LINK_TYPE_ETH = 1 00048 00049 } pj_pcap_link_type; 00050 00051 00055 typedef enum pj_pcap_proto_type 00056 { 00058 PJ_PCAP_PROTO_TYPE_UDP = 17 00059 00060 } pj_pcap_proto_type; 00061 00062 00067 typedef struct pj_pcap_udp_hdr 00068 { 00069 pj_uint16_t src_port; 00070 pj_uint16_t dst_port; 00071 pj_uint16_t len; 00072 pj_uint16_t csum; 00073 } pj_pcap_udp_hdr; 00074 00075 00081 typedef struct pj_pcap_filter 00082 { 00086 pj_pcap_link_type link; 00087 00091 pj_pcap_proto_type proto; 00092 00098 pj_uint32_t ip_src; 00099 00105 pj_uint32_t ip_dst; 00106 00112 pj_uint16_t src_port; 00113 00119 pj_uint16_t dst_port; 00120 00121 } pj_pcap_filter; 00122 00123 00125 typedef struct pj_pcap_file pj_pcap_file; 00126 00127 00134 PJ_DECL(void) pj_pcap_filter_default(pj_pcap_filter *filter); 00135 00145 PJ_DECL(pj_status_t) pj_pcap_open(pj_pool_t *pool, 00146 const char *path, 00147 pj_pcap_file **p_file); 00148 00156 PJ_DECL(pj_status_t) pj_pcap_close(pj_pcap_file *file); 00157 00167 PJ_DECL(pj_status_t) pj_pcap_set_filter(pj_pcap_file *file, 00168 const pj_pcap_filter *filter); 00169 00183 PJ_DECL(pj_status_t) pj_pcap_read_udp(pj_pcap_file *file, 00184 pj_pcap_udp_hdr *udp_hdr, 00185 pj_uint8_t *udp_payload, 00186 pj_size_t *udp_payload_size); 00187 00188 00193 PJ_END_DECL 00194 00195 #endif /* __PJLIB_UTIL_PCAP_H__ */ 00196