2016-01-12 14:27:42 +09:00

78 lines
2.1 KiB
C

#include <pcap.h>
#include <gst/gst.h>
static gchar *_omvs_net_dev;
static gchar *_omvs_output = "omvs_out.txt";
static gint _omvs_jobs = 1;
static gint _omvs_sleep = 1000;
static gint _omvs_timeout = 10000;
static GOptionEntry _omvs_entries[] =
{
{ "interface", 'i', 0, G_OPTION_ARG_STRING, &_omvs_net_dev,
"Network device interface", "dev" },
{ "jobs", 'j', 0, G_OPTION_ARG_INT, &_omvs_jobs,
"Number of jobs", "jobs" },
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &_omvs_output,
"Output filename", "filename" },
{ "sleep", 's', 0, G_OPTION_ARG_INT, &_omvs_sleep,
"Sleep time(milliseconds) between scans", "ms" },
{ "timeout", 't', 0, G_OPTION_ARG_INT, &_omvs_timeout,
"Timeout time(milliseconds) in each scan", "ms" },
{ NULL }
};
typedef struct _OMVSPort {
gint port;
gint type;
} OMVSPort;
typedef struct _OMVSIPAddr {
guint32 addr;
OMVSPort *ports;
gint num_ports;
} OMVSIPAddr;
typedef struct _OMVSScanner {
OMVSIPAddr *ipaddrs;
gint num_ipaddrs;
gint scan_ipaddr_idx;
gint scan_port_idx;
} OMVSScanner;
int main(int argc, char *argv[]) {
GError *error = NULL;
GOptionContext *context;
int ret = 0;
context = g_option_context_new("<multicast ip address or net ... [#N]>");
g_option_context_set_summary(context,
"omvs scans to find free video streaming multicast ip addresses."
);
g_option_context_set_description(context,
"Oh! Multicast Video Scanner " OMVS_VERSION " is"
" Written by Taeho Oh <ohhara@postech.edu>.\n"
"http://ohhara.sarang.net");
g_option_context_add_main_entries(context, _omvs_entries, NULL);
g_option_context_add_group(context, gst_init_get_option_group());
if (!g_option_context_parse(context, &argc, &argv, &error)) {
g_print("option parsing failed: %s\n", error->message);
ret = -1;
goto finish_return;
}
if (argc < 2) {
gchar *help_msg;
help_msg = g_option_context_get_help(context, TRUE, NULL);
g_print("%s", help_msg);
g_free(help_msg);
ret = -2;
goto finish_return;
}
finish_return:
g_option_context_free(context);
return ret;
}