Example #1
0
static void __init parse_phantom_dev(char *str) {
    const char *s = str;
    unsigned int seg, bus, slot;
    struct phantom_dev phantom;

    if ( !s || !*s || nr_phantom_devs >= ARRAY_SIZE(phantom_devs) )
        return;

    s = parse_pci(s, &seg, &bus, &slot, NULL);
    if ( !s || *s != ',' )
        return;

    phantom.seg = seg;
    phantom.bus = bus;
    phantom.slot = slot;

    switch ( phantom.stride = simple_strtol(s + 1, &s, 0) )
    {
    case 1: case 2: case 4:
        if ( *s )
    default:
            return;
    }

    phantom_devs[nr_phantom_devs++] = phantom;
}
Example #2
0
//-------------------------------------------------------------------------
// parsing functions
//-------------------------------------------------------------------------
// all commands start with $
// $packet <addr> <port> -> <addr> <port>
// $packet -> client
// $packet -> server
// $client <addr> <port>
// $server <addr> <port>
static void parse_command(FileImpl* impl, char* s)
{
    if ( !strncmp(s, "packet -> client", 16) )
        set_c2s(impl, 0);

    else if ( !strncmp(s, "packet -> server", 16) )
        set_c2s(impl, 1);

    else if ( !strncmp(s, "packet ", 7) )
        parse_pci(impl, s+7);

    else if ( !strncmp(s, "client ", 7) )
        parse_host(s+7, &impl->cfg.src_addr, &impl->cfg.src_port);

    else if ( !strncmp(s, "server ", 7) )
        parse_host(s+7, &impl->cfg.dst_addr, &impl->cfg.dst_port);
}