⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lookup_gui.c

📁 * A ncurses user interface. * Network statistics to view the amount of packets and data in many
💻 C
字号:
/*  This file is part of sniffer, a packet capture utility and  network moniter  The author can be contacted at <mistral@stev.org>  the lastest version is avilable from   http://stev.org  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 2 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, write to the Free Software  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.*/#include "config.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <pthread.h>#include <curses.h>#include "list.h"#include "locks.h"#include "gui_main.h"#include "log.h"#include "lookup.h"#include "lookup_gui.h"struct gui_menu_t lookup_gui_menu[] = {        {"All Hosts"       , "All hosts",			GUI_MENU_FUNC,	&lookup_gui_all},		{"Active Hosts"		,"Active Hosts",		GUI_MENU_FUNC,	&lookup_gui_active},        {"Hosts to Lookup" , "Hosts to lookup",		GUI_MENU_FUNC,	&lookup_gui_lookups},        {"Failed Lookups"  , "Host with no DNS info",GUI_MENU_FUNC,	&lookup_gui_failed},        {NULL              , NULL		, GUI_MENU_END,				NULL}};void lookup_gui(struct gui_t *p, int y, int x) {	gui_menu(p, lookup_gui_menu, y, x, 6, 17);	return;}void lookup_gui_all(struct gui_t *p, int y, int x) {	lookup_gui_print(p, lookup_list, &lookup_mutex);	return;}void lookup_gui_active(struct gui_t *p, int y, int x) {	lookup_gui_print(p, lookup_active, &lookup_active_mutex);	return;}void lookup_gui_lookups(struct gui_t *p, int y, int x) {	lookup_gui_print(p, lookup_todo, &lookup_todo_mutex);	return;}void lookup_gui_failed(struct gui_t *p, int y, int x) {	lookup_gui_print(p, lookup_failed, &lookup_failed_mutex);	return;}void lookup_gui_print(struct gui_t *p, struct list_t *list, pthread_mutex_t *mutex) {	struct lookup *data;	int i, length, offset = 0, cury;	WINDOW *draw;	char *foot_back, buff[80];	draw = newwin(p->twin->_maxy - 1, p->twin->_maxx - 1, 1, 1);	if (!draw) {		log_s("newwin failed");		return;	}	wbkgd(draw, COLOR_PAIR(COL_BACK));	foot_back = p->footer;	while(1) {		SLOCK(mutex);		werase(draw);		length = list_length(list);		cury = 0;		i = offset;		while(cury < draw->_maxy && i < length) {			data = list_get(list, i);			lookup_gui_dump(draw, data, cury++);			i++;		}		snprintf(&buff[0], 80, "Lookups: %d", list_len(list));		gui_footer(p, &buff[0]);		wrefresh(draw);		SUNLOCK(mutex);		switch(gui_scroll(250, 0, length, &offset)) {			case -1: /* error / timeout */				break;			case 0: /* it did something */				break;			default:				goto get_out;				break;		} /* end of switch gui_utils_scroll */	} /* end while(1) */get_out: /* cleanup / quit */	gui_footer(p, foot_back);	werase(draw);	wrefresh(draw);	delwin(draw);	return;}inline void lookup_gui_dump(WINDOW *draw, struct lookup *data, int y) {	stat_process(&data->in);	stat_process(&data->out);	if (data->name) {		mvwprintw(draw, y, 0, "%.17s\t%6.llu:%6.llu%s\t%6.llu:%6.llu%s\t%s",			data->ip_str, data->in.packets, data->in.readable, data->in.messure,			data->out.packets, data->out.readable, data->out.messure, data->name);	} else {		if (data->failed) {			mvwprintw(draw, y, 0, "%.17s\t%6.llu:%6.llu%s\t%6.llu:%6.llu%s\tFailed %lu",				data->ip_str, data->in.packets, data->in.readable, data->in.messure,				data->out.packets, data->out.readable, data->out.messure, data->failed);		} else {			if (data->working) {				mvwprintw(draw, y, 0, "%.17s\t%6.llu:%6.llu%s\t%6.llu:%6.llu%s\tResolving",					data->ip_str, data->in.packets, data->in.readable, data->in.messure,					data->out.packets, data->out.readable, data->out.messure);			} else {				mvwprintw(draw, y, 0, "%.17s\t%6.llu:%6.llu%s\t%6.llu:%6.llu%s\tStill to Resolv",					data->ip_str, data->in.packets, data->in.readable, data->in.messure,					data->out.packets, data->out.readable, data->out.messure);			}		}	}	return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -