Esempio n. 1
0
static void stdin_process(char c){
    switch (c){
        case 'p':
            printf("Connecting to PTS at %s...\n", bd_addr_to_str(pts_addr));
            bnep_connect(&packet_handler, pts_addr, bnep_l2cap_psm, bnep_src_uuid, bnep_dest_uuid);
            break;
        case 'e':
            printf("Sending general ethernet packet\n");
            send_ethernet_packet(0,0);
            break;
        case 'c':
            printf("Sending compressed ethernet packet\n");
            send_ethernet_packet(1,1);
            break;
        case 's':
            printf("Sending src only compressed ethernet packet\n");
            send_ethernet_packet(0,1);
            break;
        case 'd':
            printf("Sending dst only ethernet packet\n");
            send_ethernet_packet(1,0);
            break;
        case 'f':
            printf("Setting network protocol filter\n");
            set_network_protocol_filter();
            break;
        case 'm':
            printf("Setting multicast filter\n");
            set_multicast_filter();
            break;
        case '1':
            printf("Sending ICMP Ping via IPv4\n");
            send_ping_request_ipv4();
            break;
        case '2':
            printf("Sending ICMP Ping via IPv6\n");
            send_ping_request_ipv6();
            break;
        case '4':
            printf("Sending IPv4 ARP Probe\n");
            send_arp_probe_ipv4();
            break;
        case '6':
            printf("Sending IPv6 ARP Probe\n");
            send_ndp_probe_ipv6();
            break;
        case '7':
            printf("Sending IPv4 LLMNR Request\n");
            send_llmnr_request_ipv4();
            break;
        case '8':
            printf("Sending IPv6 LLMNR Request\n");
            send_llmnr_request_ipv6();
            break;
        default:
            show_usage();
            break;

    }
}
Esempio n. 2
0
static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
{
	struct network_conn *nc = data;
	int perr;

	if (err) {
		error("%s", err->message);
		goto failed;
	}

	perr = bnep_connect(nc);
	if (perr < 0) {
		error("bnep connect(): %s (%d)", strerror(-perr), -perr);
		goto failed;
	}

	return;

failed:
	cancel_connection(nc, -EIO);
}
Esempio n. 3
0
static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
{
    struct pan_device *dev = data;
    uint16_t l_role, r_role;
    int perr, sk;

    DBG("");

    if (err) {
        error("%s", err->message);
        goto fail;
    }

    l_role = (local_role == HAL_PAN_ROLE_NAP) ? BNEP_SVC_NAP :
             BNEP_SVC_PANU;
    r_role = (dev->role == HAL_PAN_ROLE_NAP) ? BNEP_SVC_NAP : BNEP_SVC_PANU;

    sk = g_io_channel_unix_get_fd(dev->io);

    dev->session = bnep_new(sk, l_role, r_role, BNEP_PANU_INTERFACE);
    if (!dev->session)
        goto fail;

    perr = bnep_connect(dev->session, bnep_conn_cb, bnep_disconn_cb, dev,
                        dev);
    if (perr < 0) {
        error("bnep connect req failed: %s", strerror(-perr));
        goto fail;
    }

    if (dev->io) {
        g_io_channel_unref(dev->io);
        dev->io = NULL;
    }

    return;

fail:
    bt_pan_notify_conn_state(dev, HAL_PAN_STATE_DISCONNECTED);
}
Esempio n. 4
0
static void connect_cb(GIOChannel *chan, GError *err, gpointer data)
{
	struct network_conn *nc = data;
	int sk, perr;

	if (err) {
		error("%s", err->message);
		goto failed;
	}

	sk = g_io_channel_unix_get_fd(nc->io);
	perr = bnep_connect(sk, BNEP_SVC_PANU, nc->id, bnep_conn_cb, nc);
	if (perr < 0) {
		error("bnep connect(): %s (%d)", strerror(-perr), -perr);
		goto failed;
	}

	return;

failed:
	cancel_connection(nc, -EIO);
}