Ejemplo n.º 1
0
/*===========================================================================
FUNCTION REXDIAG_INIT

DESCRIPTION
============================================================================*/
void rexdiag_init (void)
{
  DIAGPKT_DISPATCH_TABLE_REGISTER ((word)DIAG_SUBSYS_REX, rex_diag_tbl);
}
Ejemplo n.º 2
0
int32_t main(int32_t argc, char *argv[])
{
    int res =0;
    uint8_t *eventbuf = NULL;
    uint8_t *dbgbuf = NULL;
    int32_t c;
    struct dbglog_slot *slot;
    int cnss_intf_len = strlen(CNSS_INTF) +  1;
    pthread_t thd_id;

    progname = argv[0];
    uint16_t diag_type = 0;
    int32_t option_index = 0;
    static struct option long_options[] = {
        {"logfile", 1, NULL, 'f'},
        {"reclimit", 1, NULL, 'r'},
        {"console", 0, NULL, 'c'},
        {"qxdm", 0, NULL, 'q'},
        {"silent", 0, NULL, 's'},
        {"debug", 0, NULL, 'd'},
        { 0, 0, 0, 0}
    };

    while (1) {
        c = getopt_long (argc, argv, "f:scqdr:", long_options, &option_index);
        if (c == -1) break;

        switch (c) {
            case 'f':
                memset(dbglogoutfile, 0, PATH_MAX);
                memcpy(dbglogoutfile, optarg, strlen(optarg));
                optionflag |= LOGFILE_FLAG;
            break;

            case 'c':
                optionflag |= CONSOLE_FLAG;
            break;

            case 'q':
                optionflag |= QXDM_FLAG;
            break;

            case 'r':
                rec_limit = strtoul(optarg, NULL, 0);
            break;

            case 's':
                optionflag |= SILENT_FLAG;
            break;

            case 'd':
                optionflag |= DEBUG_FLAG;
            break;
            default:
                usage();
        }
    }

    if (!(optionflag & (LOGFILE_FLAG | CONSOLE_FLAG | QXDM_FLAG | SILENT_FLAG
           | DEBUG_FLAG))) {
        usage();
        return -1;
    }

    if (optionflag & QXDM_FLAG) {
        /* Intialize the fd required for diag APIs */
        if (TRUE != Diag_LSM_Init(NULL))
        {
             perror("Failed on Diag_LSM_Init\n");
             return -1;
        }
         /* Register CALLABACK for QXDM input data */
        DIAGPKT_DISPATCH_TABLE_REGISTER(DIAG_SUBSYS_WLAN, cnss_wlan_tbl);
#ifdef ANDROID
        if(cnssdiagservice_cap_handle()) {
            printf("Cap bouncing failed EXIT!!!");
            exit(1);
        }
#endif
    }

    pthread_create(&thd_id, NULL, &cnss_intf_wait_receive, NULL);

    sock_fd = create_nl_socket();
    if (sock_fd < 0) {
        fprintf(stderr, "Socket creation failed sock_fd 0x%x \n", sock_fd);
        return -1;
    }

    if (is_interface(CNSS_INTF, cnss_intf_len)) {
        initialize(sock_fd);
        cnssdiag_register_kernel_logging(sock_fd, nlh);
    }

    signal(SIGINT, stop);
    signal(SIGTERM, stop);

    if (optionflag & LOGFILE_FLAG) {

        if (rec_limit < RECLEN) {
            fprintf(stderr, "Too small maximum length (has to be >= %d)\n",
                    RECLEN);
            close(sock_fd);
            free(nlh);
            return -1;
        }
        max_records = rec_limit;
        printf("Storing last %d records\n", max_records);

        log_out = fopen(dbglogoutfile, "w");
        if (log_out == NULL) {
            perror("Failed to create output file");
            close(sock_fd);
            free(nlh);
            return -1;
        }

        fwlog_res_file = "./reorder";
    }


    parser_init();

    while ( 1 )  {
        if ((res = recvmsg(sock_fd, &msg, 0)) < 0)
                  continue;
        if ((res >= (int)sizeof(struct dbglog_slot)) ||
                  (nlh->nlmsg_type == WLAN_NL_MSG_CNSS_HOST_EVENT_LOG)) {
            process_cnss_diag_msg((tAniNlHdr *)nlh);
            memset(nlh,0,NLMSG_SPACE(MAX_MSG_SIZE));
        } else {
            /* Ignore other messages that might be broadcast */
            continue;
        }
    }
    /* Release the handle to Diag*/
    Diag_LSM_DeInit();
    if (optionflag & LOGFILE_FLAG)
        cleanup();
    close(sock_fd);
    free(nlh);
    return 0;
}