Compare commits

..

2 Commits

Author SHA1 Message Date
karthikmv b0c97d889e organized into directories 2022-10-02 21:42:04 +05:30
karthikmv f5f8eb0fef changed dir structure 2022-10-02 21:00:24 +05:30
41 changed files with 91 additions and 150 deletions

View File

@ -47,47 +47,32 @@ FILE6 = iPDC.desktop
CC = gcc CC = gcc
LIBS = -lpthread LIBS = -lpthread
LDLIBS=`pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0` LDLIBS=`pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0`
CFLAGS=-g -fcommon `pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0` CFLAGS=-g -I./inc -fcommon `pkg-config --cflags --libs gtk+-3.0 osmgpsmap-1.0`
SOURCES = \
ipdc.c \
recreate.c recreate.h \
connections.c connections.h \
new_pmu_or_pdc.c new_pmu_or_pdc.h \
parser.c parser.h \
dallocate.c dallocate.h \
align_sort.c align_sort.h \
ipdcGui.c ipdcGui.h \
attack_detection.c attack_detection.h \
data_vis.c data_vis.h \
utility_tools.c utility_tools.h \
Attack_detect.c Attack_detect.h
OBJECTS = ipdc.c recreate.o connections.o new_pmu_or_pdc.o parser.o dallocate.o align_sort.o ipdcGui.o attack_detection.o data_vis.o utility_tools.o Attack_detect.o
CLEAN_OBJECTS = recreate.o connections.o new_pmu_or_pdc.o parser.o dallocate.o align_sort.o ipdcGui.o ~iPDC.xml
PROGRAM = iPDC PROGRAM = iPDC
SOURCE_FILES = $(wildcard src/*.c)
OBJECT_FILES = $(patsubst src/%.c, bin/%.o, $(SOURCE_FILES))
CLEAN_OBJECTS = $(wildcard bin/*.o) $(PROGRAM)
COMPILE = $(CC) all: $(PROGRAM)
$(PROGRAM): $(OBJECTS) $(PROGRAM): $(OBJECT_FILES)
$(CC) $(OBJECTS) $(LDLIBS) $(LIBS) -o $@ $(CC) $(CFLAGS) $(OBJECT_FILES) -o $(PROGRAM) $(LDLIBS)
bin/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.c
$(COMPILE) $(CFLAGS) -c $<
install: $(PROGRAM) install: $(PROGRAM)
gtk-builder-convert iPDC.glade iPDC.xml gtk-builder-convert assets/iPDC.glade assets/iPDC.xml
mkdir -p $(CREATE_DIR)iPDC/$ mkdir -p $(CREATE_DIR)iPDC/$
cp -f $(FILE1) $(CREATE_DIR)iPDC/$(FILE1) cp -f assets/$(FILE1) $(CREATE_DIR)iPDC/$(FILE1)
cp -f images/$(FILE2) $(CREATE_DIR)iPDC/$(FILE2) cp -f assets/$(FILE2) $(CREATE_DIR)iPDC/$(FILE2)
cp -f images/$(FILE3) $(CREATE_DIR)iPDC/$(FILE3) cp -f assets/$(FILE3) $(CREATE_DIR)iPDC/$(FILE3)
cp -f images/$(FILE4) $(CREATE_DIR)iPDC/$(FILE4) cp -f assets/$(FILE4) $(CREATE_DIR)iPDC/$(FILE4)
cp -f images/$(FILE5) $(CREATE_DIR)iPDC/$(FILE5) cp -f assets/$(FILE5) $(CREATE_DIR)iPDC/$(FILE5)
cp -f images/$(FILE6) $(DESKTOP_DIR)/$(FILE6) cp -f assets/$(FILE6) $(DESKTOP_DIR)/$(FILE6)
cp $(PROGRAM) $(INSTALL_PREFIX)bin/$(PROGRAM) cp $(PROGRAM) $(INSTALL_PREFIX)bin/$(PROGRAM)
# rm -f $(CLEAN_OBJECTS) $(PROGRAM)
uninstall: uninstall:
rm -f $(INSTALL_PREFIX)bin/$(PROGRAM) rm -f $(INSTALL_PREFIX)bin/$(PROGRAM)

View File

Before

Width:  |  Height:  |  Size: 266 KiB

After

Width:  |  Height:  |  Size: 266 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

10
iPDC/inc/map_vis.h Normal file
View File

@ -0,0 +1,10 @@
#include<gtk/gtk.h>
#include<osm-gps-map.h>
typedef struct{
OsmGpsMap *util_map;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
} myParameters;
gboolean update_images(gpointer* pars);

View File

@ -50,7 +50,7 @@
#include "utility_tools.h" #include "utility_tools.h"
/* Common fixed path for storage of few common files */ /* Common fixed path for storage of few common files */
#define UI_fILE "./iPDC.ui" #define UI_fILE "./assets/iPDC.ui"
//#define UI_fILE "/usr/local/share/iPDC/iPDC.xml" //#define UI_fILE "/usr/local/share/iPDC/iPDC.xml"

View File

@ -5,12 +5,6 @@
#include "osm-gps-map.h" #include "osm-gps-map.h"
#include "Attack_detect.h" #include "Attack_detect.h"
typedef struct{
OsmGpsMap *util_map;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
} myParameters;
gboolean update_images(gpointer* pars){ gboolean update_images(gpointer* pars){
myParameters* parameters = (myParameters*) pars; myParameters* parameters = (myParameters*) pars;
@ -42,7 +36,7 @@ gboolean update_images(gpointer* pars){
if (green){ if (green){
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image); parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
}else{ }else{
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image); parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_red_image);
} }
} }

62
iPDC/src/utility_tools.c Normal file
View File

@ -0,0 +1,62 @@
#include<gtk/gtk.h>
#include "align_sort.h"
#include "parser.h"
#include "osm-gps-map.h"
#include "map_vis.h"
#define UI_fILE "./assets/utility_tools.ui"
#define RED_IMAGE "./assets/red.png"
#define GREEN_IMAGE "./assets/green.png"
// void change_image(OsmGpsMap *map, float lat, float lon, OsmGpsMapImage *image)
// {
// if (g_last_image)
// osm_gps_map_image_remove(map, g_last_image);
// osm_gps_map_image_add(map, lat, lon, image);
// }
void utility_tools(GtkButton *but, gpointer udata)
{
OsmGpsMap *util_map;
GtkWidget *window;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
// -------------------
GtkBuilder *builder;
GError *error = NULL;
builder = gtk_builder_new();
if(!gtk_builder_add_from_file(builder, UI_fILE, &error))
{
g_warning("%s", error->message);
g_free(error);
}
g_red_image = gdk_pixbuf_new_from_file_at_size (RED_IMAGE, 24,24,NULL);
g_green_image = gdk_pixbuf_new_from_file_at_size (GREEN_IMAGE, 24,24,NULL);
window = GTK_WIDGET(gtk_builder_get_object(builder, "util_window"));
GtkContainer *map_container = GTK_CONTAINER(gtk_builder_get_object(builder, "map_layout"));
util_map = g_object_new (OSM_TYPE_GPS_MAP,
"map-source", OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID,
"tile-cache", "/tmp/",
NULL);
osm_gps_map_set_center_and_zoom (util_map, 15.4589, 75.0078, 10);
g_last_image = osm_gps_map_image_add(util_map,15.4589, 75.0078, g_red_image);
g_last_image = osm_gps_map_image_add(util_map,15.518597, 74.925584, g_green_image);
myParameters parameters = {util_map, g_red_image, g_green_image, g_last_image};
gpointer data = (gpointer) &parameters;
g_timeout_add(20, (GSourceFunc) update_images, data);
gtk_widget_set_size_request(GTK_WIDGET(util_map), 600, 500);
gtk_container_add(map_container, GTK_WIDGET(util_map));
g_signal_connect(window, "destroy", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_widget_show_all(window);
gtk_main();
}

View File

@ -1,105 +0,0 @@
#include<gtk/gtk.h>
#include "utility_tools.h"
#include "align_sort.h"
#include "parser.h"
#include "Attack_detect.h"
#define UI_fILE "./utility_tools.ui"
// void change_image(OsmGpsMap *map, float lat, float lon, OsmGpsMapImage *image)
// {
// if (g_last_image)
// osm_gps_map_image_remove(map, g_last_image);
// osm_gps_map_image_add(map, lat, lon, image);
// }
typedef struct{
OsmGpsMap *util_map;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
} myParameters;
gboolean update_images(gpointer* pars){
myParameters* parameters = (myParameters*) pars;
struct data_frame *df = TSB[0].first_data_frame;
if(parameters->g_green_image == NULL){
return FALSE;
}
if (parameters->util_map == NULL){
return FALSE;
}
if (df == NULL){
return FALSE;
}
int freq = to_intconvertor(df->dpmu[0]->freq);
gboolean green =attack_detect(df,&START,&COUNT,&SUM_OF_FREQUENCY);
if(parameters->util_map != NULL){
// if(parameters->g_last_image != 0){
// osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
// }
// if (freq > 300){
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
// }else{
// parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
// }
if(parameters->g_last_image != 0){
osm_gps_map_image_remove(parameters->util_map, parameters->g_last_image);
}
if (green){
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_green_image);
}else{
parameters->g_last_image = osm_gps_map_image_add(parameters->util_map,15.518597, 74.925584, parameters->g_red_image);
}
}
gtk_widget_queue_draw(GTK_WIDGET(parameters->util_map));
return TRUE;
}
void utility_tools(GtkButton *but, gpointer udata)
{
OsmGpsMap *util_map;
GtkWidget *window;
GdkPixbuf *g_red_image;
GdkPixbuf *g_green_image;
OsmGpsMapImage *g_last_image;
// -------------------
GtkBuilder *builder;
GError *error = NULL;
builder = gtk_builder_new();
if(!gtk_builder_add_from_file(builder, UI_fILE, &error))
{
g_warning("%s", error->message);
g_free(error);
}
g_red_image = gdk_pixbuf_new_from_file_at_size ("red.png", 24,24,NULL);
g_green_image = gdk_pixbuf_new_from_file_at_size ("green.png", 24,24,NULL);
window = GTK_WIDGET(gtk_builder_get_object(builder, "util_window"));
GtkContainer *map_container = GTK_CONTAINER(gtk_builder_get_object(builder, "map_layout"));
util_map = g_object_new (OSM_TYPE_GPS_MAP,
"map-source", OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID,
"tile-cache", "/tmp/",
NULL);
osm_gps_map_set_center_and_zoom (util_map, 15.4589, 75.0078, 10);
g_last_image = osm_gps_map_image_add(util_map,15.4589, 75.0078, g_red_image);
g_last_image = osm_gps_map_image_add(util_map,15.518597, 74.925584, g_green_image);
myParameters parameters = {util_map, g_red_image, g_green_image, g_last_image};
gpointer data = (gpointer) &parameters;
g_timeout_add(20, (GSourceFunc) update_images, data);
gtk_widget_set_size_request(GTK_WIDGET(util_map), 600, 500);
gtk_container_add(map_container, GTK_WIDGET(util_map));
g_signal_connect(window, "destroy", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_widget_show_all(window);
gtk_main();
}

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
</interface>