void capture_init(size_t limit, bool rtp_capture) { capture_cfg.limit = limit; capture_cfg.rtp_capture = rtp_capture; capture_cfg.sources = vector_create(1, 1); capture_cfg.tcp_reasm = vector_create(0, 10); capture_cfg.ip_reasm = vector_create(0, 10); // Fixme if (setting_has_value(SETTING_CAPTURE_STORAGE, "none")) { capture_cfg.storage = CAPTURE_STORAGE_NONE; } else if (setting_has_value(SETTING_CAPTURE_STORAGE, "memory")) { capture_cfg.storage = CAPTURE_STORAGE_MEMORY; } else if (setting_has_value(SETTING_CAPTURE_STORAGE, "disk")) { capture_cfg.storage = CAPTURE_STORAGE_DISK; } // Initialize calls lock pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); #if defined(PTHREAD_MUTEX_RECURSIVE) || defined(__FreeBSD__) || defined(BSD) || defined (__OpenBSD__) || defined(__DragonFly__) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); #else pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); #endif pthread_mutex_init(&capture_cfg.lock, &attr); }
int call_raw_print_msg(PANEL *panel, sip_msg_t *msg) { call_raw_info_t *info; int payload_lines, i, column, height, width; // Message ngrep style Header char header[256]; char payload[2048]; int color = 0; // Get panel information if (!(info = call_raw_info(panel))) return -1; // Get the pad window WINDOW *pad = info->pad; // Get current pad dimensions getmaxyx(pad, height, width); // Get message payload strcpy(payload, msg_get_payload(msg)); // Check how many lines we well need to draw this message payload_lines = 0; column = 0; for (i = 0; i < strlen(payload); i++) { if (column == width || payload[i] == '\n') { payload_lines++; column = 0; continue; } column++; } // Check if we have enough space in our huge pad to store this message if (info->padline + payload_lines > height) { // Create a new pad with more lines! pad = newpad(height + 500, COLS); // And copy all previous information overwrite(info->pad, pad); // Delete previous pad delwin(info->pad); // And store the new pad info->pad = pad; } // Color the message { if (setting_has_value(SETTING_COLORMODE, "request")) { // Determine arrow color if (msg_is_request(msg)) { color = CP_RED_ON_DEF; } else { color = CP_GREEN_ON_DEF; } } else if (info->group && setting_has_value(SETTING_COLORMODE, "callid")) { // Color by call-id color = call_group_color(info->group, msg->call); } else if (setting_has_value(SETTING_COLORMODE, "cseq")) { // Color by CSeq within the same call color = msg->cseq % 7 + 1; } // Turn on the message color wattron(pad, COLOR_PAIR(color)); // Print msg header wattron(pad, A_BOLD); mvwprintw(pad, info->padline++, 0, "%s", sip_get_msg_header(msg, header)); wattroff(pad, A_BOLD); // Print msg payload info->padline += draw_message_pos(pad, msg, info->padline); // Extra line between messages info->padline++; // Set this as the last printed message info->last = msg; return 0; }
int setting_disabled(int id) { return setting_has_value(id, "off") || setting_has_value(id, "no"); }
int setting_enabled(int id) { return setting_has_value(id, "on") || setting_has_value(id, "yes"); }
int ncurses_init() { int bg, fg; const char *term; // Set Locale setlocale(LC_CTYPE, ""); // Initialize curses if (!initscr()) { fprintf(stderr, "Unable to initialize ncurses mode.\n"); return -1; } // Check if user wants a black background if (setting_has_value(SETTING_BACKGROUND, "dark")) { assume_default_colors(COLOR_WHITE, COLOR_BLACK); } else { use_default_colors(); } // Enable Colors start_color(); cbreak(); // Dont write user input on screen noecho(); // Hide the cursor curs_set(0); // Only delay ESC Sequences 25 ms (we dont want Escape sequences) ESCDELAY = 25; // Redefine some keys term = getenv("TERM"); if (term && (!strcmp(term, "xterm") || !strcmp(term, "xterm-color") || !strcmp(term, "vt220"))) { define_key("\033[H", KEY_HOME); define_key("\033[F", KEY_END); define_key("\033OP", KEY_F(1)); define_key("\033OQ", KEY_F(2)); define_key("\033OR", KEY_F(3)); define_key("\033OS", KEY_F(4)); define_key("\033[11~", KEY_F(1)); define_key("\033[12~", KEY_F(2)); define_key("\033[13~", KEY_F(3)); define_key("\033[14~", KEY_F(4)); define_key("\033[17;2~", KEY_F(18)); } if (setting_has_value(SETTING_BACKGROUND, "dark")) { fg = COLOR_WHITE; bg = COLOR_BLACK; } else { fg = COLOR_DEFAULT; bg = COLOR_DEFAULT; } // Initialize colorpairs init_pair(CP_CYAN_ON_DEF, COLOR_CYAN, bg); init_pair(CP_YELLOW_ON_DEF, COLOR_YELLOW, bg); init_pair(CP_MAGENTA_ON_DEF, COLOR_MAGENTA, bg); init_pair(CP_GREEN_ON_DEF, COLOR_GREEN, bg); init_pair(CP_RED_ON_DEF, COLOR_RED, bg); init_pair(CP_BLUE_ON_DEF, COLOR_BLUE, bg); init_pair(CP_WHITE_ON_DEF, COLOR_WHITE, bg); init_pair(CP_DEF_ON_CYAN, fg, COLOR_CYAN); init_pair(CP_DEF_ON_BLUE, fg, COLOR_BLUE); init_pair(CP_WHITE_ON_BLUE, COLOR_WHITE, COLOR_BLUE); init_pair(CP_BLACK_ON_CYAN, COLOR_BLACK, COLOR_CYAN); init_pair(CP_WHITE_ON_CYAN, COLOR_WHITE, COLOR_CYAN); init_pair(CP_YELLOW_ON_CYAN, COLOR_YELLOW, COLOR_CYAN); init_pair(CP_BLUE_ON_CYAN, COLOR_BLUE, COLOR_CYAN); init_pair(CP_BLUE_ON_WHITE, COLOR_BLUE, COLOR_WHITE); init_pair(CP_CYAN_ON_WHITE, COLOR_CYAN, COLOR_WHITE); init_pair(CP_CYAN_ON_BLACK, COLOR_CYAN, COLOR_BLACK); return 0; }