예제 #1
0
int main(void)
{
    const unsigned int FrameLen = 36;
    unsigned char *macframe = malloc(FrameLen);  // alloc MAC header until frame body
    
    // fill header with junk, to make this more interesting
    for (unsigned int i = 0; i < FrameLen; i++) {
        macframe[i] = 0xde;
    }
    
    set_proto_version(macframe, 0);
    set_type(macframe, 1);
    set_subtype(macframe, 1);
    set_to_ds(macframe, 1);
    set_from_ds(macframe, 0);
    set_retry(macframe, 0);
    set_more_data(macframe, 0);
    
    print_header(macframe);
    
    printf("Protocol version: %d\n", get_proto_version(macframe));
    printf("Type: %d\n", get_type(macframe));
    printf("Subtype: %d\n", get_subtype(macframe));
    printf("Flags: To DS: %d  From DS: %d  Retry: %d  More Data: %d\n",
            get_to_ds(macframe) != 0, get_from_ds(macframe) != 0,
            get_retry(macframe) != 0, get_more_data(macframe) != 0);
    
    free(macframe);
}
예제 #2
0
파일: task.cpp 프로젝트: shengofsun/rDSN
void timer_task::exec()
{
    if (dsn_likely(_cb != nullptr)) {
        _cb();
    }
    // valid interval, we reset task state to READY
    if (dsn_likely(_interval_milliseconds > 0)) {
        dassert(set_retry(true),
                "timer task set retry failed, with state = %s",
                enum_to_string(state()));
        set_delay(_interval_milliseconds);
    }
}