Skip to content
This repository has been archived by the owner on Jan 30, 2021. It is now read-only.

Commit

Permalink
Patch courtesy of Brian Behrens <bbehrens@cyberserious.net>
Browse files Browse the repository at this point in the history
  • Loading branch information
deri committed Jan 17, 2012
1 parent 91f2eab commit 6e52b64
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 15 deletions.
1 change: 1 addition & 0 deletions globals-core.h
Expand Up @@ -489,6 +489,7 @@ extern void delPrefsValue(char *key);
extern void delPwValue(char *key);
extern void processStrPref(char *key, char *value, char **globalVar, bool savePref);
extern void processIntPref(char *key, char *value, int *globalVar, bool savePref);
extern void processUIntPref(char *key, char *value, u_int *globalVar, bool savePref);
extern void processBoolPref(char *key, bool value, bool *globalVar, bool savePref);
extern bool processNtopPref(char *key, char *value, bool savePref, UserPref *pref);
extern void initUserPrefs(UserPref *pref);
Expand Down
2 changes: 1 addition & 1 deletion globals-structtypes.h
Expand Up @@ -1442,7 +1442,7 @@ typedef struct ntopInterface {

IpFragment *fragmentList;
IPSession **sessions;
u_short numSessions, maxNumSessions;
u_int numSessions, maxNumSessions;

/* ************************** */

Expand Down
2 changes: 1 addition & 1 deletion ntop_darwin.c
Expand Up @@ -97,7 +97,7 @@ struct dlopen_handle {
struct dlopen_handle *next;
};
static struct dlopen_handle *dlopen_handles = NULL;
static const struct dlopen_handle main_program_handle = {NULL};
static const struct dlopen_handle main_program_handle = { NULL };
static char *dlerror_pointer = NULL;

/*
Expand Down
28 changes: 22 additions & 6 deletions prefs.c
Expand Up @@ -490,7 +490,7 @@ int parseOptions(int argc, char* argv[]) {

case 'x':
//myGlobals.runningPref.maxNumHashEntries = atoi(optarg);
myGlobals.runningPref.maxNumHashEntries = strtoul(optarg,NULL,0);
myGlobals.runningPref.maxNumHashEntries = strtoul(optarg, NULL, 0);
break;

case 'z':
Expand Down Expand Up @@ -576,7 +576,7 @@ int parseOptions(int argc, char* argv[]) {

case 'X':
//myGlobals.runningPref.maxNumSessions = atoi(optarg);
myGlobals.runningPref.maxNumSessions = strtoul(optarg,NULL,0);
myGlobals.runningPref.maxNumSessions = strtoul(optarg, NULL, 0);
break;

#ifdef HAVE_OPENSSL
Expand Down Expand Up @@ -1041,6 +1041,22 @@ void processIntPref(char *key, char *value, int *globalVar, bool savePref)

/* ******************************** */

void processUIntPref(char *key, char *value, u_int *globalVar, bool savePref)
{
char buf[512];

if((key == NULL) || (value == NULL)) return;

*globalVar = strtoul(value, NULL, 0);

if(savePref) {
safe_snprintf(__FILE__, __LINE__, buf, sizeof(buf), "%d", *globalVar);
storePrefsValue(key, buf);
}
}

/* ******************************** */

void processBoolPref(char *key, bool value, bool *globalVar, bool savePref)
{
char buf[512];
Expand Down Expand Up @@ -1219,16 +1235,16 @@ bool processNtopPref(char *key, char *value, bool savePref, UserPref *pref) {
-1);
value = buf;
}
processIntPref(NTOP_PREF_MAXHASH, value,
(int*)&pref->maxNumHashEntries, savePref);
processUIntPref(NTOP_PREF_MAXHASH, value,
(u_int*)&pref->maxNumHashEntries, savePref);
} else if(strcmp(key, NTOP_PREF_MAXSESSIONS) == 0) {
if(value == NULL) {
safe_snprintf (__FILE__, __LINE__, buf, sizeof(buf), "%d",
-1);
value = buf;
}
processIntPref(NTOP_PREF_MAXSESSIONS, value,
(int*)&pref->maxNumSessions, savePref);
processUIntPref(NTOP_PREF_MAXSESSIONS, value,
(u_int*)&pref->maxNumSessions, savePref);
} else if(strcmp(key, NTOP_PREF_MERGEIF) == 0) {
processBoolPref(NTOP_PREF_MERGEIF, value2bool(value),
&pref->mergeInterfaces, savePref);
Expand Down
2 changes: 1 addition & 1 deletion report.c
Expand Up @@ -3924,7 +3924,7 @@ void printActiveSessions(int actualDeviceId, int pageNum, HostTraffic *el) {
#ifdef PRINT_SESSION_DETAILS
char flags_buf[64];
#endif
int numSessions, printedSessions;
u_int numSessions, printedSessions;
char formatBuf[64], formatBuf1[64], formatBuf2[64],
formatBuf4[64], formatBuf5[64], formatBuf6[64], formatBuf7[64];

Expand Down
4 changes: 2 additions & 2 deletions sessions.c
Expand Up @@ -908,7 +908,7 @@ static void handleSCCPSession(const struct pcap_pkthdr *h,
&& (packetDataLength > 200)) {
char *calling_party_name, *calling_party;
char *called_party_name, *called_party;
char caller[1024], called[1024];
char caller[2048], called[2048];

if((rcStr = (char*)malloc(packetDataLength+1)) == NULL) {
traceEvent(CONST_TRACE_WARNING, "handleSCCPSession: Unable to "
Expand Down Expand Up @@ -943,7 +943,7 @@ static void handleSCCPSession(const struct pcap_pkthdr *h,
safe_snprintf(__FILE__, __LINE__, called, sizeof(called), "%s", called_party);

if(theSession->session_info == NULL) {
char tmpStr[1024];
char tmpStr[2048];

safe_snprintf(__FILE__, __LINE__, tmpStr, sizeof(tmpStr), "%s called %s", caller, called);
theSession->session_info = strdup(tmpStr);
Expand Down
8 changes: 4 additions & 4 deletions webInterface.c
Expand Up @@ -787,18 +787,17 @@ void switchNwInterface(int _interface) {
break;
}

printSwitchNwInterfaceHeader();

if(myGlobals.runningPref.mergeInterfaces) {
printSwitchNwInterfaceHeader();
safe_snprintf(__FILE__, __LINE__, buf, sizeof(buf), "Sorry, but you cannot switch among different interfaces "
"unless the -M command line switch is specified at run time.");
sendString(buf);
} else if((mwInterface != -1) &&
((mwInterface >= myGlobals.numDevices) || myGlobals.device[mwInterface].virtualDevice)) {
printSwitchNwInterfaceHeader();
safe_snprintf(__FILE__, __LINE__, buf, sizeof(buf), "Sorry, invalid interface selected.");
sendString(buf);
} else if((myGlobals.numDevices == 1) || (!found)) {
printSwitchNwInterfaceHeader();
safe_snprintf(__FILE__, __LINE__, buf, sizeof(buf), "Sorry, you are currently capturing traffic from only a "
"single/dummy interface [%s].<br><br>"
"</b> This interface switch feature is meaningful only when your ntop "
Expand All @@ -811,14 +810,15 @@ void switchNwInterface(int _interface) {

myGlobals.actualReportDeviceId = (mwInterface)%myGlobals.numDevices;
storePrefsValue("actualReportDeviceId", value);
printSwitchNwInterfaceHeader();

safe_snprintf(__FILE__, __LINE__, buf, sizeof(buf), "The current interface is now [%s].",
myGlobals.device[myGlobals.actualReportDeviceId].name);
sendString(buf);

safe_snprintf(__FILE__, __LINE__, value, sizeof(value), "%d", myGlobals.actualReportDeviceId);
} else {
u_short do_enable;

sendString("Available Network Interfaces:</B><P>\n<FORM ACTION=" CONST_SWITCH_NIC_HTML ">\n");

if(((!myGlobals.device[myGlobals.actualReportDeviceId].virtualDevice)
Expand Down

0 comments on commit 6e52b64

Please sign in to comment.