segmentation error (core dumped) Linux in c
Hello HKO,
i did one mistake from my previous code. this code after modification that part basically that was like.
int
main(int argc, char *argv[])
{
int c;
u_char flags;
char *device;
char *capture_file;
struct descry_pack *gp;
printf("Descry 1.0 [TCP port scan detection tool]\n");
flags = 0;
device = NULL;
capture_file = NULL;
while ((c = getopt(argc, argv,"ahf:i:vs]")) != EOF) <previous was "afi:vs:h and if use while ((c ==getopt(argc, argv,"ahf:i:vs]")) then no SEG PROB but not getting result behest of choice >
{
switch (c)
{
case 'a':
flags |= ALL_HOSTS;
break;
case 'f':
capture_file = optarg; [in here i cant undestood from ur feedback feedback, pls do explain. i am not very good in c]
break;
case 'i':
device = optarg;
break;
case 'v':
break;
case 's':
flags |= DO_SYSLOG;
break;
case 'h':
default:
usage(argv[0]);
return (EXIT_FAILURE);
}
}
/* either read from a capture file OR run on the network */
if (capture_file && device)
{
usage(argv[0]);
return (EXIT_FAILURE);
}
if (descry_init(&gp, device, capture_file, flags) == 0)
{
fprintf(stderr, "descry_init(): catastrophic failure\n");
return (EXIT_FAILURE);
}
while (pcap_dispatch(gp->p, 0, (pcap_handler)descry, (u_char*)gp));
descry_destroy(gp);
return (EXIT_SUCCESS);
}
Last edited by nasim751; 01-27-2008 at 01:48 AM.
|