~ubuntu-branches/ubuntu/wily/bluez/wily

« back to all changes in this revision

Viewing changes to test/hciemu.c

ImportĀ upstreamĀ versionĀ 4.81

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *  BlueZ - Bluetooth protocol stack for Linux
4
4
 *
5
5
 *  Copyright (C) 2000-2002  Maxim Krasnyansky <maxk@qualcomm.com>
6
 
 *  Copyright (C) 2003-2009  Marcel Holtmann <marcel@holtmann.org>
 
6
 *  Copyright (C) 2003-2010  Marcel Holtmann <marcel@holtmann.org>
7
7
 *
8
8
 *
9
9
 *  This program is free software; you can redistribute it and/or modify
295
295
        he = (void *) ptr; ptr += HCI_EVENT_HDR_SIZE;
296
296
 
297
297
        he->evt  = EVT_CMD_COMPLETE;
298
 
        he->plen = EVT_CMD_COMPLETE_SIZE + plen; 
 
298
        he->plen = EVT_CMD_COMPLETE_SIZE + plen;
299
299
 
300
300
        cc = (void *) ptr; ptr += EVT_CMD_COMPLETE_SIZE;
301
301
 
327
327
        he = (void *) ptr; ptr += HCI_EVENT_HDR_SIZE;
328
328
 
329
329
        he->evt  = EVT_CONN_REQUEST;
330
 
        he->plen = EVT_CONN_REQUEST_SIZE; 
 
330
        he->plen = EVT_CONN_REQUEST_SIZE;
331
331
 
332
332
        cr = (void *) ptr; ptr += EVT_CONN_REQUEST_SIZE;
333
333
 
355
355
        he = (void *) ptr; ptr += HCI_EVENT_HDR_SIZE;
356
356
 
357
357
        he->evt  = EVT_CONN_COMPLETE;
358
 
        he->plen = EVT_CONN_COMPLETE_SIZE; 
 
358
        he->plen = EVT_CONN_COMPLETE_SIZE;
359
359
 
360
360
        cc = (void *) ptr; ptr += EVT_CONN_COMPLETE_SIZE;
361
361
 
459
459
 
460
460
        baswap(&ba, &vdev.bdaddr);
461
461
        sa.sin_family = AF_INET;
462
 
        sa.sin_addr.s_addr = *(uint32_t *) &ba;
 
462
        memcpy(&sa.sin_addr.s_addr, &ba, sizeof(sa.sin_addr.s_addr));
463
463
        sa.sin_port = *(uint16_t *) &ba.b[4];
464
464
        if (bind(sk, (struct sockaddr *) &sa, sizeof(sa))) {
465
465
                syslog(LOG_ERR, "Can't bind socket: %s (%d)",
518
518
 
519
519
        handle = btohs(cp->handle);
520
520
 
521
 
        if (handle - 1 > VHCI_MAX_CONN)
 
521
        if (handle > VHCI_MAX_CONN)
522
522
                return;
523
523
 
524
524
        if (!(conn = vconn[handle-1]))
566
566
 
567
567
        baswap(&ba, &cp->bdaddr);
568
568
        sa.sin_family = AF_INET;
569
 
        sa.sin_addr.s_addr = *(uint32_t *) &ba;
 
569
        memcpy(&sa.sin_addr.s_addr, &ba, sizeof(sa.sin_addr.s_addr));
570
570
        sa.sin_port = *(uint16_t *) &ba.b[4];
571
571
        if (connect(sk, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
572
572
                syslog(LOG_ERR, "Can't connect: %s (%d)",
1172
1172
{
1173
1173
        printf("hciemu - HCI emulator ver %s\n", VERSION);
1174
1174
        printf("Usage: \n");
1175
 
        printf("\thciemu [-n] local_address\n");
 
1175
        printf("\thciemu [options] local_address\n"
 
1176
                "Options:\n"
 
1177
                "\t[-d device] use specified device\n"
 
1178
                "\t[-b bdaddr] emulate specified address\n"
 
1179
                "\t[-s file] create snoop file\n"
 
1180
                "\t[-n] do not detach\n"
 
1181
                "\t[-h] help, you are looking at it\n");
1176
1182
}
1177
1183
 
1178
1184
static struct option main_options[] = {