"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/capture/capctl.c" between
etherape-0.9.17.tar.gz and etherape-0.9.18.tar.gz

About: EtherApe is a GNOME/pcap-based graphical network monitor (etherman clone).

capctl.c  (etherape-0.9.17):capctl.c  (etherape-0.9.18)
skipping to change at line 264 skipping to change at line 264
{ {
g_free(data); g_free(data);
} }
void free_capture_interfaces(GList *ifs) void free_capture_interfaces(GList *ifs)
{ {
g_list_foreach(ifs, interface_list_free_cb, NULL); g_list_foreach(ifs, interface_list_free_cb, NULL);
g_list_free(ifs); g_list_free(ifs);
} }
static void pktpipe_read_cb(gpointer data, gint source, GdkInputCondition cond) static gboolean pktpipe_read_cb(GIOChannel *source, GIOCondition condition,
gpointer data)
{ {
struct pcap_pkthdr pkthdr; struct pcap_pkthdr pkthdr;
char pktdata[MAXCAPSIZE]; char pktdata[MAXCAPSIZE];
set_fd_nonblock(pktpipe, 0); set_fd_nonblock(pktpipe, 0);
pkt_recv(&pkthdr, sizeof(pkthdr)); pkt_recv(&pkthdr, sizeof(pkthdr));
g_assert(pkthdr.caplen <= MAXCAPSIZE); g_assert(pkthdr.caplen <= MAXCAPSIZE);
pkt_recv(pktdata, pkthdr.caplen); pkt_recv(pktdata, pkthdr.caplen);
set_fd_nonblock(pktpipe, 1); set_fd_nonblock(pktpipe, 1);
appdata.now = pkthdr.ts; appdata.now = pkthdr.ts;
packet_acquired((guint8*)pktdata, pkthdr.caplen, pkthdr.len); packet_acquired((guint8*)pktdata, pkthdr.caplen, pkthdr.len);
return TRUE;
} }
static gchar *start_live_capture(unsigned int *linktype, int *select_fd) static gchar *start_live_capture(unsigned int *linktype, int *select_fd)
{ {
struct capctl_req_t req; struct capctl_req_t req;
struct capctl_resp_t resp; struct capctl_resp_t resp;
gchar *new_devname; gchar *new_devname;
zeroreq(&req); zeroreq(&req);
skipping to change at line 476 skipping to change at line 478
} }
else if (appdata.mode == LINK6 && !has_linklevel()) else if (appdata.mode == LINK6 && !has_linklevel())
return g_strdup_printf(_("This device does not support link-layer mode. " return g_strdup_printf(_("This device does not support link-layer mode. "
"Please use IP or TCP modes.")); "Please use IP or TCP modes."));
if (pref.filter) if (pref.filter)
set_filter(pref.filter); set_filter(pref.filter);
capture_status = PLAY; capture_status = PLAY;
if (appdata.source.type == ST_LIVE) if (appdata.source.type == ST_LIVE) {
capture_source = gdk_input_add(select_fd, GDK_INPUT_READ, pktpipe_read_cb, GIOChannel *channel = g_io_channel_unix_new(select_fd);
NULL); capture_source = g_io_add_watch(channel,
G_IO_IN | G_IO_HUP | G_IO_ERR,
pktpipe_read_cb,
NULL);
g_io_channel_unref(channel);
}
else else
capture_source = g_timeout_add_full(G_PRIORITY_DEFAULT, 1, capture_source = g_timeout_add_full(G_PRIORITY_DEFAULT, 1,
filecap_get_packet, NULL, filecap_get_packet, NULL,
filecap_timeout_destroy); filecap_timeout_destroy);
return err; return err;
} }
gchar *pause_capture(void) gchar *pause_capture(void)
{ {
skipping to change at line 516 skipping to change at line 523
static gchar *stop_live_capture(void) static gchar *stop_live_capture(void)
{ {
struct capctl_req_t req; struct capctl_req_t req;
struct capctl_resp_t resp; struct capctl_resp_t resp;
g_assert(appdata.source.type == ST_LIVE); g_assert(appdata.source.type == ST_LIVE);
zeroreq(&req); zeroreq(&req);
gdk_input_remove(capture_source); g_source_remove(capture_source);
req.type = CRQ_STOPCAP; req.type = CRQ_STOPCAP;
sendreq(&req); sendreq(&req);
recvresp(&resp); recvresp(&resp);
if (resp.status == CRP_ERR) if (resp.status == CRP_ERR)
return recvstr(resp.err.msglen); return recvstr(resp.err.msglen);
g_assert(resp.status == CRP_OK); g_assert(resp.status == CRP_OK);
skipping to change at line 589 skipping to change at line 596
return err; return err;
} }
static gchar *cleanup_live_capture(void) static gchar *cleanup_live_capture(void)
{ {
struct capctl_req_t req; struct capctl_req_t req;
struct capctl_resp_t resp; struct capctl_resp_t resp;
int pktcap_status; int pktcap_status;
pid_t pid; pid_t pid;
pid_t oldpid;
if (pktcap_pid == -1)
return NULL;
zeroreq(&req); zeroreq(&req);
req.type = CRQ_EXIT; req.type = CRQ_EXIT;
sendreq(&req); sendreq(&req);
recvresp(&resp); recvresp(&resp);
if (resp.status == CRP_ERR) if (resp.status == CRP_ERR)
return recvstr(resp.err.msglen); return recvstr(resp.err.msglen);
g_assert(resp.status == CRP_OK); g_assert(resp.status == CRP_OK);
close(ctrlsock); close(ctrlsock);
ctrlsock = -1; ctrlsock = -1;
pid = waitpid(pktcap_pid, &pktcap_status, 0); // always reset pid
if (pid != pktcap_pid) oldpid = pktcap_pid;
pktcap_pid = -1;
pid = waitpid(oldpid, &pktcap_status, 0);
if (pid != oldpid)
return g_strdup_printf("waitpid() returned %d on capture process", pid); return g_strdup_printf("waitpid() returned %d on capture process", pid);
else if (!WIFEXITED(pktcap_status) || WEXITSTATUS(pktcap_status)) else if (!WIFEXITED(pktcap_status) || WEXITSTATUS(pktcap_status))
return g_strdup_printf("capture process exited abnormally"); return g_strdup_printf("capture process exited abnormally");
return NULL; return NULL;
} }
void cleanup_capture(void) void cleanup_capture(void)
{ {
gchar *err = NULL; gchar *err = NULL;
 End of changes. 6 change blocks. 
7 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)