Skip to content

Commit

Permalink
v1.0.90.4, minor patch for ipv4/interface metadata params bug; disabl…
Browse files Browse the repository at this point in the history
…ed promiscuous mode in capturer; small edits to comments/debug in other files; moved testing executable test.c
  • Loading branch information
jreed47 authored and Jonathan Reed committed Jul 2, 2013
1 parent 9423e23 commit 94e09a7
Show file tree
Hide file tree
Showing 22 changed files with 195 additions and 116 deletions.
4 changes: 2 additions & 2 deletions obj/stack.cfg
Expand Up @@ -5,7 +5,7 @@ version = "1.0";
stack:
{
modules = (
{ id = 0;
{ id = 0; #id=0 must be switch
lib = "switch";
name = "switch_1";
flows = []; #no output
Expand Down Expand Up @@ -42,7 +42,7 @@ stack:
flows = [1515, 1616, 1717]; #[ipv4, icmp, daemon]
params = {}; },
{ id = 7;
lib = "daemon"; #replace with daemon
lib = "daemon";
name = "daemon_1";
flows = [1818, 1919, 2020]; #[icmp, tcp, udp]
params = {}; },
Expand Down
57 changes: 0 additions & 57 deletions obj/test.c

This file was deleted.

30 changes: 9 additions & 21 deletions settings.finsmk
Expand Up @@ -14,6 +14,9 @@ BUILD_FOR_LINUX := "If uncommented, the FINS source will build for linux"
ifdef BUILD_FOR_ANDROID_ARM
TARGET_PLATFORM := "Android arch-ARM"

FOLDER_LIST := trunk #tests
EXECS_LIST := capturer console core wedge launcher

#CC :=/home/bucknell/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=/home/bucknell/android-ndk/platforms/android-8/arch-arm
#INCLS := -I/home/bucknell/android/external/libpcap -I/home/bucknell/android/external/libconfig-1.4.7/lib -I/home/bucknell/android/external/libpcap/pcap -I/home/bucknell/android/bionic/libc/include -I/home/bucknell/android/bionic/libc/arch-arm/include -I/home/bucknell/android/bionic/libc/ -I/home/bucknell/android/bionic/libc/kernel/common -I/home/bucknell/android/bionic/libc/kernel/arch-arm
#LIBPATHS := -L/home/bucknell/android/out/target/product/crespo/system/lib
Expand All @@ -39,18 +42,9 @@ LDOPTS += -Wl,--entry=main,-rpath-link=$(USR)/lib,--dynamic-linker=/system/bin/l
LIBPATHS := -L$(USR)/lib
#LIBPATHS += -L$(ANDROID_NDK_ROOT)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3
#LIBPATHS += -L$(ANDROID_NDK_ROOT)/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.6
LIBS := -lc -lgcc -llog -lm #-lc -lgcc #-lrt
LIBS := -lc -lgcc -llog -lm

GDB_CLIENT := $(BIN)/arm-eabi-gdb

FOLDER_LIST := trunk #tests
EXECS_LIST := capturer launcher wedge

COMMON_LIBS := libconfig
CAPTURER_LIBS := libglue libpcap
LAUNCHER_LIBS :=
WEDGE_LIBS :=

INSTALL_DIR := /data/local/fins
endif

Expand All @@ -59,8 +53,8 @@ endif

###### build for android x86 ######
ifdef BUILD_FOR_ANDROID_X86

TARGET_PLATFORM := "Android arch-x86"

FOLDER_LIST := trunk examples tests
EXECS_LIST := common libs capturer core

Expand All @@ -81,25 +75,19 @@ endif
ifdef BUILD_FOR_LINUX
TARGET_PLATFORM := "Linux x86"

FOLDER_LIST := trunk examples tests
EXECS_LIST := capturer console core wedge

CC := gcc
CCOPTS := -g -O0 -Wall #flags for valgrind
INCLS :=

LD := gcc
LDOPTS := -g -O0 -Wall #flags for valgrind
LIBPATHS :=
#LIBS := -lpthread -lconfig -lpcap -lc -lm -lrt
LIBS := #-lc -ldl -lpthread #-lm -lrt -lconfig -lpcap #added dl for auto config
LIBS :=

GDB_CLIENT := gdb

FOLDER_LIST := trunk examples tests
EXECS_LIST := capturer core wedge

COMMON_LIBS :=
CAPTURER_LIBS := common
CORE_LIBS := common
WEDGE_LIBS :=
endif


Expand Down
6 changes: 5 additions & 1 deletion tests/Makefile
Expand Up @@ -17,7 +17,7 @@ CFLAGS += $(TESTS_INC)

#add the names of any executables that are added to this directory here. This
#ensures that they will be removed by clean
EXECUTABLES = server_icmp client_icmp server_tcp client_tcp server_udp client_udp server_forks
EXECUTABLES = server_icmp client_icmp server_tcp client_tcp server_udp client_udp server_forks test

#This is an autogenerated list of includes used in this project.
INCLUDES = $(foreach DIR_NAME, $(subst -I,, $(strip $(TESTS_INC))), $(addprefix $(DIR_NAME)/, $(shell ls $(DIR_NAME)| grep \\.h)))
Expand Down Expand Up @@ -58,6 +58,10 @@ server_forks:server_forks.c
@$(CC) $(CFLAGS) -c $<
@$(LD) $@.o $(LDFLAGS) -o $@

test:test.c
@$(CC) $(CFLAGS) -c $<
@$(LD) $@.o $(LDFLAGS) -o $@

userspace_tests:
@cd Userspace_tests; make all

Expand Down
144 changes: 144 additions & 0 deletions tests/test.c
@@ -0,0 +1,144 @@

//#include <signal.h>
//#include <stddef.h>
//#include <sys/prctl.h>
//#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
//#include <ctype.h>
//#include <limits.h>
#include <linux/if_ether.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
//#include <sys/un.h>

#include <unistd.h>
#include <linux/if.h>
#include <linux/sockios.h>
#include <stdio.h>
#include <sys/ioctl.h>

#define DEBUG
#define IMPORTANT
#define ERROR

#ifdef DEBUG
#define PRINT_DEBUG(format, args...) printf("DEBUG(%s, %s, %d):"format"\n",__FILE__, __FUNCTION__, __LINE__, ##args);fflush(stdout)
#else
#define PRINT_DEBUG(format, args...)
#endif

#ifdef IMPORTANT
#define PRINT_IMPORTANT(format, args...) printf("IMPORTANT(%s, %s, %d):"format"\n",__FILE__, __FUNCTION__, __LINE__, ##args);fflush(stdout)
#else
#define PRINT_IMPORTANT(format, args...)
#endif

#ifdef ERROR
#define PRINT_ERROR(format, args...) printf("ERROR(%s, %s, %d):"format"\n",__FILE__, __FUNCTION__, __LINE__, ##args);fflush(stdout)
#else
#define PRINT_ERROR(format, args...)
#endif

int main(int argc, char *argv[]) {
PRINT_IMPORTANT("Entered");

int ret;

PRINT_IMPORTANT("Gaining su status");
if ((ret = system("su"))) {
PRINT_ERROR("SU failure: ret=%d, errno=%u, str='%s'", ret, errno, strerror(errno));
}

if (1) { //tests socket creation
char recv_data[4000];
while (1) {
gets(recv_data);
//sleep(15);
errno = 0;
int fd1 = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
PRINT_IMPORTANT("fd1=%d, errno=%u, str='%s'", fd1, errno, strerror(errno));
int fd2 = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));
PRINT_IMPORTANT("fd2=%d, errno=%u, str='%s'", fd2, errno, strerror(errno));
int fd3 = socket(PF_INET, SOCK_PACKET, htons(ETH_P_ALL));
PRINT_IMPORTANT("fd3=%d, errno=%u, str='%s'", fd3, errno, strerror(errno));
int fd4 = socket(PF_UNIX, SOCK_STREAM, 0);
PRINT_IMPORTANT("fd4=%d, errno=%u, str='%s'", fd4, errno, strerror(errno));
int fd5 = socket(PF_INET, SOCK_DGRAM, 0);
PRINT_IMPORTANT("fd5=%d, errno=%u, str='%s'", fd5, errno, strerror(errno));
int fd6 = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
PRINT_IMPORTANT("fd6=%d, errno=%u, str='%s'", fd6, errno, strerror(errno));
int fd7 = socket(PF_INET, SOCK_DGRAM | O_NONBLOCK, IPPROTO_UDP);
PRINT_IMPORTANT("fd7=%d, errno=%u, str='%s'", fd7, errno, strerror(errno));
int fd8 = socket(PF_INET, SOCK_STREAM, 0);
PRINT_IMPORTANT("fd8=%d, errno=%u, str='%s'", fd8, errno, strerror(errno));
int fd9 = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
PRINT_IMPORTANT("fd9=%d, errno=%u, str='%s'", fd9, errno, strerror(errno));
int fd10 = socket(PF_INET, SOCK_STREAM | O_NONBLOCK, IPPROTO_TCP);
PRINT_IMPORTANT("fd10=%d, errno=%u, str='%s'", fd10, errno, strerror(errno));
int fd11 = socket(PF_INET, SOCK_RAW, 0);
PRINT_IMPORTANT("fd11=%d, errno=%u, str='%s'", fd11, errno, strerror(errno));
int fd12 = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP);
PRINT_IMPORTANT("fd12=%d, errno=%u, str='%s'", fd12, errno, strerror(errno));
int fd13 = socket(PF_INET, SOCK_RAW | O_NONBLOCK, IPPROTO_ICMP);
PRINT_IMPORTANT("fd13=%d, errno=%u, str='%s'", fd13, errno, strerror(errno));
}
}

if (0) { //test assembly instructions (replaced in glue.h)
uint32_t test1 = 7;
uint32_t test2 = 2;
PRINT_IMPORTANT("test1=%d", test1/test2);
test1 = 9;
test2 = 3;
PRINT_IMPORTANT("test2=%d", test1/test2);
test1 = 4;
test2 = 5;
PRINT_IMPORTANT("test3=%d", test1/test2);

int32_t test3 = 7;
int32_t test4 = 2;
PRINT_IMPORTANT("test4=%d", test3/test4);
test3 = 9;
test4 = 3;
PRINT_IMPORTANT("test5=%d", test3/test4);
test3 = 4;
test4 = 5;
PRINT_IMPORTANT("test6=%d", test3/test4);

double test5 = 7;
double test6 = 2;
PRINT_IMPORTANT("test7=%f", test5/test6);
test5 = 9;
test6 = 3;
PRINT_IMPORTANT("test8=%f", test5/test6);
test5 = 4;
test6 = 5;
PRINT_IMPORTANT("test9=%f", test5/test6);
}

if (0) { //test interfaces
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);

struct ifreq ifr;
int num;
for (num = 0; num < 20; num++) {
ifr.ifr_ifindex = num;
ret = ioctl(fd, SIOCGIFNAME, &ifr);
PRINT_IMPORTANT("ifr_ifindex=%d, ifr_name='%s'", ifr.ifr_ifindex, ifr.ifr_name);
//printf("ifr_ifindex=%d, ifr_name='%s'\n", ifr.ifr_ifindex, ifr.ifr_name);
}

close(fd);
printf("FIN, waiting\n");
while (1)
;
return 0;
}
return 0;
}
2 changes: 1 addition & 1 deletion trunk/execs/capturer/wifistub.c
Expand Up @@ -264,7 +264,7 @@ void inject_init(char *device) {
char errbuf[PCAP_ERRBUF_SIZE]; /* error buffer */

/** Setup the Injection Interface */
if ((inject_handle = pcap_open_live((char *) dev, BUFSIZ, 1, -1, errbuf)) == NULL) {
if ((inject_handle = pcap_open_live((char *) dev, BUFSIZ, 0, -1, errbuf)) == NULL) {
PRINT_ERROR( "Error: '%s'", errbuf);
exit(1);
}
Expand Down
1 change: 1 addition & 0 deletions trunk/execs/capturer/wifistub.h
Expand Up @@ -82,6 +82,7 @@ extern int server_inject_fd;

#define MAX_FILTER_LEN 500

//TODO these definitions need to be gathered
#ifdef BUILD_FOR_ANDROID
#define FINS_TMP_ROOT "/data/data/com.BU_VT.FINS/files"
//#define FINS_TMP_ROOT "/data/data/com.BU_VT.FINS"
Expand Down
8 changes: 4 additions & 4 deletions trunk/execs/console/console.c
Expand Up @@ -32,7 +32,7 @@
#define UNIX_PATH_MAX 108
#endif

//ADDED mrd015 !!!!! (this crap really needs to be gathered into one header.)
//TODO these definitions need to be gathered
#ifdef BUILD_FOR_ANDROID
//#define FINS_TMP_ROOT "/data/data/fins"
#define FINS_TMP_ROOT "/data/data/com.BU_VT.FINS/files"
Expand Down Expand Up @@ -93,16 +93,16 @@ int main() {

int console_fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (console_fd < 0) {
printf("\nsocket error: capture_fd=%d, errno=%u, str='%s'", console_fd, errno, strerror(errno));
printf("\nsocket error: console_fd=%d, errno=%u, str='%s'", console_fd, errno, strerror(errno));
return 0;
}

printf("\nconnecting to: addr='%s'", RTM_PATH);
if (connect(console_fd, (struct sockaddr *) &addr, size) != 0) {
printf("\nconnect error: capture_fd=%d, errno=%u, str='%s'", console_fd, errno, strerror(errno));
printf("\nconnect error: console_fd=%d, errno=%u, str='%s'", console_fd, errno, strerror(errno));
return 0;
}
printf("\nconnected at: capture_fd=%d, addr='%s'", console_fd, addr.sun_path);
printf("\nconnected at: console_fd=%d, addr='%s'", console_fd, addr.sun_path);
//*/

//TODO fork for recv process that or do nonblocking read on STDIN
Expand Down
4 changes: 2 additions & 2 deletions trunk/execs/core/core.c
Expand Up @@ -193,7 +193,7 @@ void core_main(uint8_t *envi_name, uint8_t *stack_name) {

status = config_read_file(meta_envi, (char *) envi_name);
if (status == META_FALSE) {
PRINT_ERROR("%s:%d - %s\n", config_error_file(meta_envi), config_error_line(meta_envi), config_error_text(meta_envi));
PRINT_ERROR("file='%s', %s:%d - %s\n", envi_name, config_error_file(meta_envi), config_error_line(meta_envi), config_error_text(meta_envi));
metadata_destroy(meta_envi);
PRINT_ERROR("todo error");
exit(-1);
Expand Down Expand Up @@ -605,7 +605,7 @@ void core_main(uint8_t *envi_name, uint8_t *stack_name) {

status = config_read_file(meta_stack, (char *) stack_name);
if (status == META_FALSE) {
PRINT_ERROR("%s:%d - %s\n", config_error_file(meta_stack), config_error_line(meta_stack), config_error_text(meta_stack));
PRINT_ERROR("file='%s', %s:%d - %s\n", stack_name, config_error_file(meta_stack), config_error_line(meta_stack), config_error_text(meta_stack));
metadata_destroy(meta_stack);
PRINT_ERROR("todo error");
exit(-1);
Expand Down
2 changes: 1 addition & 1 deletion trunk/execs/core/core.h
Expand Up @@ -8,7 +8,7 @@
#ifndef CORE_H_
#define CORE_H_

//ADDED mrd015 !!!!!
//TODO these definitions need to be gathered
#ifdef BUILD_FOR_ANDROID
#define FINS_TMP_ROOT "/data/data/com.BU_VT.FINS/files"
#else
Expand Down
11 changes: 0 additions & 11 deletions trunk/execs/core/test/test.c

This file was deleted.

0 comments on commit 94e09a7

Please sign in to comment.