Commit 10b42ee0 authored by 's avatar
Browse files

MAPI error reporting has been improved. Some testing is still needed.

Bug 434 fixed.


git-svn-id: file:///home/svn/mapi/trunk@545 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 3a509086
......@@ -6,7 +6,7 @@ INCLUDE=-I. -I$(DAG_INCLUDE_DIR)
CFLAGS=-g $(C_WARNINGS) $(C_FEATURES)
TARGETS= mapi.so mapid build_tests mapinicdrv.so mapidstdflib.so flist.o list.o parseconf.o priorities.o $(ADMCTRLCL_TARGETS) $(DIMAPI_TARGETS)
TARGETS= mapi.so mapid build_tests mapinicdrv.so mapidstdflib.so flist.o list.o parseconf.o priorities.o mapi_errors.o $(ADMCTRLCL_TARGETS) $(DIMAPI_TARGETS)
DIMAPI_TARGETS=
ifeq ($(WITH_DIMAPI),1)
......@@ -75,10 +75,10 @@ endif
all: $(TARGETS) $(DAG) $(COMBOSIX) $(IPFIX_TARGETS) $(ETHEREAL_TARGETS) $(ANONYMIZATION_TARGETS) $(TRACKING_TARGETS)
mapi.o: mapi.c printfstring.h mapi.h mapiipc.h mapidlib.h mapid.h mapidrv.h mapi_errors.h mapierror.h mapidflib.h parseconf.c $(ADMCTRL_BYTESTREAM_H)
mapi.o: mapi.c printfstring.h mapi.h mapiipc.h mapidlib.h mapid.h mapidrv.h mapidflib.h parseconf.c mapi_errors.o $(ADMCTRL_BYTESTREAM_H)
$(CC) $(CFLAGS) $(KEYNOTE_CFLAGS) $(ADMCTRLCL_CFLAGS) -fPIC -c $<
mapiipc.o: mapiipc.c mapi.h mapiipc.h mapi_errors.h
mapiipc.o: mapiipc.c mapi.h mapiipc.h
$(CC) $(CFLAGS) -fPIC -c $<
mstring.o: mstring.c mstring.h
......@@ -87,15 +87,28 @@ mstring.o: mstring.c mstring.h
mapipktdecoder.o: mapipktdecoder.c mapipktdecoder.h
$(CC) $(CFLAGS) -fPIC -c $<
mapi_errors.h: errors.mapi
cat errors.mapi|grep -v "#" > mapi_errors.dat
cat errors.mapi|grep "#" > mapi_errors.h
mapi.so: mapi.o mapiipc.o mapilibhandler.o fhelp.o flist.o parseconf.o mapipktdecoder.o priorities.o printfstring.o
create_error_files: errors.mapi
# cat errors.mapi|grep -v "#" > mapi_errors.dat
# cat errors.mapi|grep "#" > mapi_errors.h
echo -e "#ifndef _MAPI_ERRORS_H_ \n#define _MAPI_ERRORS_H_\n" > mapi_errors.h
cat errors.mapi|grep "^#" >> mapi_errors.h
echo -e "\ntypedef struct foobar{ \nunsigned int err_no; \nchar *desc; \n} errorstruct; \n" >> mapi_errors.h
echo -e "#endif\n" >> mapi_errors.h
echo -e "#include \"mapi_errors.h\"\n\n const errorstruct Errors[] =\n{" > mapi_errors.c
cat errors.mapi|grep -v "#"| awk -F= '{print "{" $$1 "," $$2 "},"}' >> mapi_errors.c
echo -e "{0,0} };\n\n" >> mapi_errors.c
mapi.so: mapi.o mapiipc.o mapilibhandler.o fhelp.o flist.o parseconf.o mapipktdecoder.o priorities.o printfstring.o mapi_errors.o
$(CC) -shared -o $@ $^ -ldl $(KEYNOTE_LDADD) -lpthread
mapi_errors.o: create_error_files
$(CC) $(CFLAGS) -c mapi_errors.c
mapierror.o: mapierror.c mapi.h mapi_errors.h
$(CC) $(CFLAGS) -c $<
#mapierror.o: mapierror.c mapi.h
# $(CC) $(CFLAGS) -c $<
mapilibhandler.o: mapilibhandler.c mapilibhandler.h
$(CC) $(CFLAGS) -c $<
......@@ -103,10 +116,10 @@ mapilibhandler.o: mapilibhandler.c mapilibhandler.h
mapidlib.o: mapidlib.c flist.h mapidlib.h mapid.h mapidrv.h mapi.h mapi_errors.h mstring.h mapilibhandler.h mapidflib.h priorities.o
$(CC) $(CFLAGS) -fPIC -c $<
mapid.o: mapid.c mapid.h mapiipc.h mapi.h mapi_errors.h $(ADMCTRLCL_HEADERS) $(RESCTRL_HEADERS)
mapid.o: mapid.c mapid.h mapiipc.h mapi.h $(ADMCTRLCL_HEADERS) $(RESCTRL_HEADERS)
$(CC) $(CFLAGS) $(ADMCTRLCL_CFLAGS) $(RESCTRL_CFLAGS) -c $<
mapid: mapid.o mapiipc.o mapierror.o mstring.o flist.o parseconf.o priorities.o printfstring.o $(ADMCTRLCL_OBJS) $(RESCTRL_OBJS)
mapid: mapid.o mapiipc.o mstring.o flist.o parseconf.o priorities.o printfstring.o mapi_errors.o $(ADMCTRLCL_OBJS) $(RESCTRL_OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LIB_DIR) -lpcap -lpthread -ldl $(ADMCTRLCL_LDFLAGS) $(ADMCTRLCL_LDADD) $(RESCTRL_LDFLAGS) $(RESCTRL_LDADD)
fhelp.o: fhelp.c mapi.h fhelp.h mapid.c
......@@ -198,7 +211,7 @@ docs:
clean:
@/bin/rm -f mapidtmp.* *.o *.so *~ $(TARGETS) \
mapi_erorrs.dat mapi_errors.h \
mapi_errors.h mapi_errors.c\
$(DAG) $(COMBOSIX) $(IPFIX_TARGETS) $(ETHEREAL_TARGETS) \
__mapi*sock*__
cd stdlib && make clean
......
......@@ -28,7 +28,7 @@ all: $(BINS)
$(CC) $(CFLAGS) $(INCLUDE) -c $<
agent: agent.o
$(CC) $(CFLAGS) ../mapi.o ../mapiipc.o ../mapilibhandler.o ../fhelp.o ../flist.o ../parseconf.o ../mapipktdecoder.o ../printfstring.o $^ -ldl $(KEYNOTE_LDADD) -lpthread -o $@ $(LDLIBS)
$(CC) $(CFLAGS) ../mapi.o ../mapiipc.o ../mapilibhandler.o ../fhelp.o ../flist.o ../parseconf.o ../mapipktdecoder.o ../printfstring.o ../mapi_errors.o $^ -ldl $(KEYNOTE_LDADD) -lpthread -o $@ $(LDLIBS)
clean:
$(RM) *.o $(BINS)
This diff is collapsed.
......@@ -17,7 +17,7 @@
#include "mapid.h"
#include "mapiipc.h"
#include "mapierror.h"
#include "mapi_errors.h"
#include "flist.h"
#include "parseconf.h"
#include "debug.h"
......@@ -266,7 +266,7 @@ mapid_shutdown (int data)
free(mapidsocket);
/* close error-lookup file */
close_error ();
//close_error ();
running_shutdown = 2;
DEBUG_CMD (printf ("mapid terminated [%s:%d]\n", __FILE__, __LINE__));
exit ((data == 0) ? EXIT_FAILURE : EXIT_SUCCESS);
......@@ -289,9 +289,10 @@ static void
report_error (int err_no, int pid, int sock)
{
struct mapiipcbuf buf;
mapi_set_error (pid, err_no);
//mapi_set_error (pid, err_no);
buf.mtype = pid;
buf.cmd = ERROR_ACK;
buf.remote_errorcode=err_no;
buf.fd = 0;
mapiipc_daemon_write ((struct mapiipcbuf *) &buf, sock);
return;
......@@ -1667,7 +1668,7 @@ cmd_apply_function (struct mapiipcbuf *qbuf, int pid, int sock)
}
/*
static void
cmd_read_error (int loc_err, int pid, int sock)
{
......@@ -1679,8 +1680,8 @@ cmd_read_error (int loc_err, int pid, int sock)
translate_errorcode (mapi_get_error (pid), &err);
else
{
mapi_get_error (pid); /* remove possible other errors for this process */
translate_errorcode (loc_err, &err); /* internal mapi.c error, this unsets pid-error for the process */
mapi_get_error (pid); /* remove possible other errors for this process *
translate_errorcode (loc_err, &err); /* internal mapi.c error, this unsets pid-error for the process *
}
qbuf.mtype = pid;
qbuf.cmd = READ_ERROR_ACK;
......@@ -1691,7 +1692,7 @@ cmd_read_error (int loc_err, int pid, int sock)
mapiipc_daemon_write ((struct mapiipcbuf *) &qbuf, sock);
free_error (&err);
}
*/
static void
cmd_set_authdata (int fd, int pid, MAPI_UNUSED unsigned char *data, int sock)
{
......@@ -2239,8 +2240,8 @@ mapidcom ()
case CLOSE_FLOW_ACK:
case SET_AUTHDATA_ACK:
break;
case READ_ERROR:
cmd_read_error (qbuf.fd, qbuf.pid, s);
/*case READ_ERROR:
cmd_read_error (qbuf.fd, qbuf.pid, s);*/
case READ_ERROR_ACK:
break;
case ERROR_ACK:
......@@ -2652,7 +2653,7 @@ main (int argc, char *argv[])
__LINE__));
exit (EXIT_FAILURE);
}
init_error ("mapi_errors.dat");
//init_error ("mapi_errors.dat");
// Grab some signals so we can mapid_shutdown gracefully
signal (SIGTERM, mapid_shutdown);
......
......@@ -14,7 +14,7 @@
#define MAX_SEND_SIZE 8192//1024
#define FUNCTARGS_BUF_SIZE 7168
#define DATA_SIZE 7168
#define DIMAPI_DATA_SIZE 50000
#define DIMAPI_DATA_SIZE 7168
#define FUNCT_NAME_LENGTH 256
#define ARG_LENGTH 32
#define MAPIDSOCKHOME "%s/.mapid.sock"
......@@ -99,6 +99,7 @@ struct mapiipcbuf {
uid_t uid; //UID of the user running the application
unsigned char data[DATA_SIZE];
unsigned char argdescr[ARG_LENGTH];
int remote_errorcode;
};
//IPC calls
......@@ -168,6 +169,9 @@ typedef struct remote_flowdescr {
struct mapipkt* pkt;
flist_t* function_res;
unsigned char is_connected; // This should be 1 if the flow is connected 0 otherwise
/* int error;
char errstr[MAPI_ERRORSTR_LENGTH];
*/
#ifdef WITH_AUTHENTICATION
unsigned char is_authenticated;
char *username;
......
......@@ -6,7 +6,7 @@
#include <stdio.h>
#include <string.h>
#include "mapierror.h"
#include "mapi_errors.h"
#include "mapi.h"
#include "mapipktdecoder.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment