static void join_print_po(struct packet_object *po) { int ret; /* check if the object exists */ if (wdg_conndata == NULL || wdg_join == NULL) return; /* if not focused don't refresh it */ if (!(wdg_conndata->flags & WDG_OBJ_FOCUSED)) return; /* check the regex filter */ if (GBL_OPTIONS->regex && regexec(GBL_OPTIONS->regex, (const char*)po->DATA.disp_data, 0, NULL, 0) != 0) { return; } /* use the global to reuse the same memory region */ SAFE_REALLOC(dispbuf, hex_len(po->DATA.disp_len) * sizeof(u_char) + 1); /* format the data */ ret = GBL_FORMAT(po->DATA.disp_data, po->DATA.disp_len, dispbuf); dispbuf[ret] = 0; if (!ip_addr_cmp(&po->L3.src, &curr_conn->L3_addr1)) wdg_scroll_print(wdg_join, EC_COLOR_JOIN1, "%s", dispbuf); else wdg_scroll_print(wdg_join, EC_COLOR_JOIN2, "%s", dispbuf); }
static void split_print_po(struct packet_object *po) { int ret; /* if not open don't refresh it */ if (!data_window) return; /* check the regex filter */ if (GBL_OPTIONS->regex && regexec(GBL_OPTIONS->regex, po->DATA.disp_data, 0, NULL, 0) != 0) { return; } /* use the global to reuse the same memory region */ SAFE_REALLOC(dispbuf, hex_len(po->DATA.disp_len) * sizeof(u_char) + 1); /* format the data */ ret = GBL_FORMAT(po->DATA.disp_data, po->DATA.disp_len, dispbuf); dispbuf[ret] = 0; if (!ip_addr_cmp(&po->L3.src, &curr_conn->L3_addr1)) gtkui_data_print(1, dispbuf, 0); else gtkui_data_print(2, dispbuf, 0); }
void text_print_packet(struct packet_object *po) { /* * keep it static so it is always the same * memory region used for this operation */ static u_char *tmp = NULL; int ret; /* don't display the packet */ if (GBL_OPTIONS->quiet) return; /* * if the regex does not match, the packet is not interesting * * should we put this after the format function ? * in this way we can match e.t.t.e.r.c.a.p in TEXT mode with * the "ettercap" regex */ if (GBL_OPTIONS->regex && regexec(GBL_OPTIONS->regex, po->DATA.disp_data, 0, NULL, 0) != 0) { return; } /* * prepare the buffer, * the max length is hex_fomat * so use its length for the buffer */ SAFE_REALLOC(tmp, hex_len(po->DATA.disp_len) * sizeof(u_char)); /* * format the packet with the function set by the user */ ret = GBL_FORMAT(po->DATA.disp_data, po->DATA.disp_len, tmp); /* print the headers */ display_headers(po); /* print it */ write(fileno(stdout), tmp, ret); printf("\n"); }
static void join_print(u_char *text, size_t len, struct ip_addr *L3_src) { int ret; /* check the regex filter */ if (GBL_OPTIONS->regex && regexec(GBL_OPTIONS->regex, (const char*)text, 0, NULL, 0) != 0) { return; } /* use the global to reuse the same memory region */ SAFE_REALLOC(dispbuf, hex_len(len) * sizeof(u_char) + 1); /* format the data */ ret = GBL_FORMAT(text, len, dispbuf); dispbuf[ret] = 0; if (!ip_addr_cmp(L3_src, &curr_conn->L3_addr1)) wdg_scroll_print(wdg_join, EC_COLOR_JOIN1, "%s", dispbuf); else wdg_scroll_print(wdg_join, EC_COLOR_JOIN2, "%s", dispbuf); }
static void split_print(u_char *text, size_t len, struct ip_addr *L3_src) { int ret; /* check the regex filter */ if (GBL_OPTIONS->regex && regexec(GBL_OPTIONS->regex, text, 0, NULL, 0) != 0) { return; } /* use the global to reuse the same memory region */ SAFE_REALLOC(dispbuf, hex_len(len) * sizeof(u_char) + 1); /* format the data */ ret = GBL_FORMAT(text, len, dispbuf); dispbuf[ret] = 0; if (!ip_addr_cmp(L3_src, &curr_conn->L3_addr1)) gtkui_data_print(1, dispbuf, 0); else gtkui_data_print(2, dispbuf, 0); }