2007-03-06 00:28:55 +03:00
#!/usr/bin/perl
# Bootstrap Samba and run a number of tests against it.
# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org>
2009-03-25 17:40:39 +03:00
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2007-03-06 00:28:55 +03:00
package SocketWrapper ;
use Exporter ;
@ ISA = qw( Exporter ) ;
@ EXPORT_OK = qw( setup_dir setup_pcap set_default_iface ) ;
use strict ;
2019-12-07 12:37:00 +03:00
use warnings ;
2007-03-06 00:28:55 +03:00
use FindBin qw( $RealBin ) ;
2007-04-19 12:04:35 +04:00
sub setup_dir ($$)
2007-03-06 00:28:55 +03:00
{
2007-04-19 12:04:35 +04:00
my ( $ dir , $ pcap ) = @ _ ;
my $ pcap_dir = undef ;
2007-03-12 03:24:03 +03:00
if ( defined ( $ dir ) ) {
if ( - d $ dir ) {
unlink <$dir/*> ;
} else {
2007-04-20 15:40:44 +04:00
mkdir ( $ dir , 0777 ) ;
2007-03-12 03:24:03 +03:00
}
2007-04-19 12:04:35 +04:00
if ( $ pcap ) {
$ pcap_dir = $ dir . "/pcap" ;
if ( - d $ pcap_dir ) {
unlink <$pcap_dir/*> ;
} else {
2007-04-20 15:40:44 +04:00
mkdir ( $ pcap_dir , 0777 ) ;
2007-04-19 12:04:35 +04:00
}
}
2007-03-12 03:24:03 +03:00
}
2007-04-19 18:51:46 +04:00
if ( defined ( $ pcap_dir ) ) {
$ ENV { SOCKET_WRAPPER_PCAP_DIR } = $ pcap_dir ;
} else {
delete $ ENV { SOCKET_WRAPPER_PCAP_DIR } ;
}
if ( defined ( $ dir ) ) {
$ ENV { SOCKET_WRAPPER_DIR } = $ dir ;
} else {
delete $ ENV { SOCKET_WRAPPER_DIR } ;
}
2007-03-06 00:28:55 +03:00
return $ dir ;
}
sub setup_pcap ($)
{
my ( $ pcap_file ) = @ _ ;
2007-04-04 18:24:44 +04:00
$ ENV { SOCKET_WRAPPER_PCAP_FILE } = $ pcap_file ;
2007-03-06 00:28:55 +03:00
}
sub set_default_iface ($)
{
my ( $ i ) = @ _ ;
$ ENV { SOCKET_WRAPPER_DEFAULT_IFACE } = $ i ;
}
1 ;