mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-14 19:16:59 +00:00
working libpcap detection
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@640 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
f0e51dee8c
commit
8f27796167
@ -166,7 +166,7 @@ ISDN_CFLAGS = -D_GNU_SOURCE
|
|||||||
####
|
####
|
||||||
|
|
||||||
###For libpcap
|
###For libpcap
|
||||||
ISDN_LIBS = -lpcap
|
ISDN_LIBS = $(PCAP_LIB_FLAGS)
|
||||||
####
|
####
|
||||||
|
|
||||||
ISDN_SOURCE=\
|
ISDN_SOURCE=\
|
||||||
|
@ -49,9 +49,11 @@
|
|||||||
#define ZAP_SPAN_IS_NT(x) (((zap_isdn_data_t *)(x)->signal_data)->mode == Q921_NT)
|
#define ZAP_SPAN_IS_NT(x) (((zap_isdn_data_t *)(x)->signal_data)->mode == Q921_NT)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBPCAP
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
/*Q931ToPcap functions*/
|
/*Q931ToPcap functions*/
|
||||||
#include <pcap.h>
|
#include <pcap.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SNAPLEN 1522
|
#define SNAPLEN 1522
|
||||||
#define MAX_ETHER_PAYLOAD_SIZE 1500
|
#define MAX_ETHER_PAYLOAD_SIZE 1500
|
||||||
@ -68,6 +70,7 @@
|
|||||||
#define IP_SIZE_OFFSET SIZE_ETHERNET+2
|
#define IP_SIZE_OFFSET SIZE_ETHERNET+2
|
||||||
#define TCP_SEQ_OFFSET SIZE_ETHERNET+SIZE_IP+4
|
#define TCP_SEQ_OFFSET SIZE_ETHERNET+SIZE_IP+4
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBPCAP
|
||||||
/*Some globals*/
|
/*Some globals*/
|
||||||
unsigned long pcapfilesize = 0;
|
unsigned long pcapfilesize = 0;
|
||||||
unsigned long tcp_next_seq_no_send = 0;
|
unsigned long tcp_next_seq_no_send = 0;
|
||||||
@ -236,9 +239,14 @@ static zap_status_t writeQ931PacketToPcap(L3UCHAR* q931buf, L3USHORT q931size, L
|
|||||||
return ZAP_SUCCESS;
|
return ZAP_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
static ZIO_IO_UNLOAD_FUNCTION(close_pcap)
|
static ZIO_IO_UNLOAD_FUNCTION(close_pcap)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_LIBPCAP
|
||||||
return closePcapFile();
|
return closePcapFile();
|
||||||
|
#else
|
||||||
|
return ZAP_SUCCESS;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Q931ToPcap functions DONE*/
|
/*Q931ToPcap functions DONE*/
|
||||||
@ -965,12 +973,15 @@ static int zap_isdn_921_23(void *pvt, Q921DLMsg_t ind, L2UCHAR tei, L2UCHAR *msg
|
|||||||
{
|
{
|
||||||
int ret, offset = (ind == Q921_DL_DATA) ? 4 : 3;
|
int ret, offset = (ind == Q921_DL_DATA) ? 4 : 3;
|
||||||
char bb[4096] = "";
|
char bb[4096] = "";
|
||||||
|
#ifdef HAVE_LIBPCAP
|
||||||
zap_span_t *span = (zap_span_t *) pvt; /*To get access to spanid for Q931ToPcap*/
|
zap_span_t *span = (zap_span_t *) pvt; /*To get access to spanid for Q931ToPcap*/
|
||||||
|
#endif
|
||||||
|
|
||||||
switch(ind) {
|
switch(ind) {
|
||||||
case Q921_DL_DATA:
|
case Q921_DL_DATA:
|
||||||
case Q921_DL_UNIT_DATA:
|
case Q921_DL_UNIT_DATA:
|
||||||
print_hex_bytes(msg + offset, mlen - offset, bb, sizeof(bb));
|
print_hex_bytes(msg + offset, mlen - offset, bb, sizeof(bb));
|
||||||
|
#ifdef HAVE_LIBPCAP
|
||||||
/*Q931ToPcap*/
|
/*Q931ToPcap*/
|
||||||
if(do_q931ToPcap==1){
|
if(do_q931ToPcap==1){
|
||||||
if(writeQ931PacketToPcap(msg + offset, mlen - offset, span->span_id, 1) != ZAP_SUCCESS){
|
if(writeQ931PacketToPcap(msg + offset, mlen - offset, span->span_id, 1) != ZAP_SUCCESS){
|
||||||
@ -978,6 +989,7 @@ static int zap_isdn_921_23(void *pvt, Q921DLMsg_t ind, L2UCHAR tei, L2UCHAR *msg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Q931ToPcap done*/
|
/*Q931ToPcap done*/
|
||||||
|
#endif
|
||||||
zap_log(ZAP_LOG_DEBUG, "READ %d\n%s\n%s\n\n\n", (int)mlen - offset, LINE, bb);
|
zap_log(ZAP_LOG_DEBUG, "READ %d\n%s\n%s\n\n\n", (int)mlen - offset, LINE, bb);
|
||||||
default:
|
default:
|
||||||
ret = Q931Rx23(pvt, ind, tei, msg, mlen);
|
ret = Q931Rx23(pvt, ind, tei, msg, mlen);
|
||||||
@ -1723,7 +1735,9 @@ static int q931_rx_32(void *pvt, Q921DLMsg_t ind, L3UCHAR tei, L3UCHAR *msg, L3I
|
|||||||
{
|
{
|
||||||
int offset = 4;
|
int offset = 4;
|
||||||
char bb[4096] = "";
|
char bb[4096] = "";
|
||||||
|
#ifdef HAVE_LIBPCAP
|
||||||
zap_span_t *span = (zap_span_t *) pvt; /*To get access to span_id for Q931ToPcap*/
|
zap_span_t *span = (zap_span_t *) pvt; /*To get access to span_id for Q931ToPcap*/
|
||||||
|
#endif
|
||||||
|
|
||||||
switch(ind) {
|
switch(ind) {
|
||||||
case Q921_DL_UNIT_DATA:
|
case Q921_DL_UNIT_DATA:
|
||||||
@ -1731,6 +1745,7 @@ static int q931_rx_32(void *pvt, Q921DLMsg_t ind, L3UCHAR tei, L3UCHAR *msg, L3I
|
|||||||
|
|
||||||
case Q921_DL_DATA:
|
case Q921_DL_DATA:
|
||||||
print_hex_bytes(msg + offset, mlen - offset, bb, sizeof(bb));
|
print_hex_bytes(msg + offset, mlen - offset, bb, sizeof(bb));
|
||||||
|
#ifdef HAVE_LIBPCAP
|
||||||
/*Q931ToPcap*/
|
/*Q931ToPcap*/
|
||||||
if(do_q931ToPcap==1){
|
if(do_q931ToPcap==1){
|
||||||
if(writeQ931PacketToPcap(msg + offset, mlen - offset, span->span_id, 0) != ZAP_SUCCESS){
|
if(writeQ931PacketToPcap(msg + offset, mlen - offset, span->span_id, 0) != ZAP_SUCCESS){
|
||||||
@ -1738,6 +1753,7 @@ static int q931_rx_32(void *pvt, Q921DLMsg_t ind, L3UCHAR tei, L3UCHAR *msg, L3I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Q931ToPcap done*/
|
/*Q931ToPcap done*/
|
||||||
|
#endif
|
||||||
zap_log(ZAP_LOG_DEBUG, "WRITE %d\n%s\n%s\n\n", (int)mlen - offset, LINE, bb);
|
zap_log(ZAP_LOG_DEBUG, "WRITE %d\n%s\n%s\n\n", (int)mlen - offset, LINE, bb);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1908,10 +1924,13 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_isdn_configure_span)
|
|||||||
int32_t digit_timeout = 0;
|
int32_t digit_timeout = 0;
|
||||||
int q921loglevel = -1;
|
int q921loglevel = -1;
|
||||||
int q931loglevel = -1;
|
int q931loglevel = -1;
|
||||||
|
#ifdef HAVE_LIBPCAP
|
||||||
int q931topcap = -1; /*Q931ToPcap*/
|
int q931topcap = -1; /*Q931ToPcap*/
|
||||||
int openPcap = 0; /*Flag: open Pcap file please*/
|
int openPcap = 0; /*Flag: open Pcap file please*/
|
||||||
|
#endif
|
||||||
|
|
||||||
if (span->signal_type) {
|
if (span->signal_type) {
|
||||||
|
#ifdef HAVE_LIBPCAP
|
||||||
/*Q931ToPcap: Get the content of the q931topcap and pcapfilename args given by mod_openzap */
|
/*Q931ToPcap: Get the content of the q931topcap and pcapfilename args given by mod_openzap */
|
||||||
while((var = va_arg(ap, char *))) {
|
while((var = va_arg(ap, char *))) {
|
||||||
if (!strcasecmp(var, "q931topcap")) {
|
if (!strcasecmp(var, "q931topcap")) {
|
||||||
@ -1919,8 +1938,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_isdn_configure_span)
|
|||||||
if(q931topcap==1) {
|
if(q931topcap==1) {
|
||||||
/*PCAP on*/;
|
/*PCAP on*/;
|
||||||
openPcap=1;
|
openPcap=1;
|
||||||
}
|
} else if (q931topcap==0) {
|
||||||
else if(q931topcap==0){
|
|
||||||
/*PCAP off*/
|
/*PCAP off*/
|
||||||
if (closePcapFile() != ZAP_SUCCESS) return ZAP_FAIL;
|
if (closePcapFile() != ZAP_SUCCESS) return ZAP_FAIL;
|
||||||
do_q931ToPcap=0;
|
do_q931ToPcap=0;
|
||||||
@ -1939,7 +1957,7 @@ static ZIO_SIG_CONFIGURE_FUNCTION(zap_isdn_configure_span)
|
|||||||
return ZAP_SUCCESS;
|
return ZAP_SUCCESS;
|
||||||
}
|
}
|
||||||
/*Q931ToPcap done*/
|
/*Q931ToPcap done*/
|
||||||
|
#endif
|
||||||
snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling [%d].", span->signal_type);
|
snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling [%d].", span->signal_type);
|
||||||
return ZAP_FAIL;
|
return ZAP_FAIL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user