dot3.c

来自「eCos操作系统源码」· C语言 代码 · 共 508 行 · 第 1/2 页

C
508
字号
    }        if ( (IFT_LOOP == ifp->if_type ) ||         (IFT_PROPVIRTUAL == ifp->if_type ) ||         (!supports_dot3)) {        switch(vp->magic) {        case DOT3STATSINDEX:            long_ret = name[(*length)-1];            return (unsigned char *) &long_ret;                    case DOT3STATSETHERCHIPSET:            *var_len = sizeof(nullobjid);            return (unsigned char *) nullobjid;                    case DOT3STATSDUPLEXSTATUS:            long_ret = 1;            return (unsigned char *) &long_ret;                    default:            long_ret = 0; // a dummy value for most of them            return (unsigned char *) &long_ret;        }    }        /* If we got here, the device does support dot3 */    switch(vp->magic) {    case DOT3STATSINDEX:        long_ret = name[(*length)-1];        return (unsigned char *) &long_ret;          case DOT3STATSALIGNMENTERRORS:        long_ret = x.rx_align_errors;        return (unsigned char *) &long_ret;            case DOT3STATSFCSERRORS:        long_ret = x.rx_crc_errors;        return (unsigned char *) &long_ret;            case DOT3STATSSINGLECOLLISIONFRAMES:        long_ret = x.tx_single_collisions;        return (unsigned char *) &long_ret;            case DOT3STATSMULTIPLECOLLISIONFRAMES:        long_ret = x.tx_mult_collisions;        return (unsigned char *) &long_ret;            case DOT3STATSSQETESTERRORS:        long_ret = x.tx_sqetesterrors;        return (unsigned char *) &long_ret;            case DOT3STATSDEFERREDTRANSMISSIONS:        long_ret = x.tx_deferred;        return (unsigned char *) &long_ret;            case DOT3STATSLATECOLLISIONS:        long_ret = x.tx_late_collisions;        return (unsigned char *) &long_ret;            case DOT3STATSEXCESSIVECOLLISIONS:        long_ret = x.tx_max_collisions;        return (unsigned char *) &long_ret;            case DOT3STATSINTERNALMACTRANSMITERRORS:        long_ret = x.tx_underrun;        return (unsigned char *) &long_ret;            case DOT3STATSCARRIERSENSEERRORS:        long_ret = x.tx_carrier_loss;        return (unsigned char *) &long_ret;          case DOT3STATSFRAMETOOLONGS:        long_ret = x.rx_too_long_frames;        return (unsigned char *) &long_ret;          case DOT3STATSINTERNALMACRECEIVEERRORS:        long_ret = x.rx_overrun_errors +            x.rx_resource_errors;        return (unsigned char *) &long_ret;          case DOT3STATSSYMBOLERRORS:        long_ret = x.rx_symbol_errors;        return (unsigned char *) &long_ret;            case DOT3STATSETHERCHIPSET:        i = 0;        while ( i < sizeof(etherobjid) ) {            if ( 0 == (etherobjid[i] = x.snmp_chipset[i]) )                break;            i++;        }        if (i)        {            *var_len = i;            return (unsigned char *) etherobjid;        }        else        {            *var_len = sizeof(nullobjid);            return (unsigned char *) nullobjid;        }            case DOT3STATSDUPLEXSTATUS:        long_ret = x.duplex;        if ( 1 > long_ret || 3 < long_ret )            long_ret = 1;        return (unsigned char *) &long_ret;          default:        ERROR_MSG("");        return NULL;    }}#if 0 // UNSUPPORTED: we do not have the information for these tables./* * var_dot3ControlTable(): *   Handle this table separately from the scalar value case. *   The workings of this are basically the same as for var_dot3ControlTable above. */unsigned char *var_dot3ControlTable(struct variable *vp,            oid     *name,            size_t  *length,            int     exact,            size_t  *var_len,            WriteMethod **write_method){    /* variables we may use later */    static long long_ret;    static unsigned char string[SPRINT_MAX_LEN];    static oid objid[MAX_OID_LEN];    static struct counter64 c64;    if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE)        == MATCH_FAILED )        return NULL;    switch(vp->magic) {    case DOT3CONTROLFUNCTIONSSUPPORTED:        long_ret = 1;        return &long_ret;    case DOT3CONTROLINUNKNOWNOPCODES:        long_ret = 0;        return (unsigned char *) &long_ret;    default:      ERROR_MSG("");    }    return NULL;}/* * var_dot3PauseTable(): *   Handle this table separately from the scalar value case. *   The workings of this are basically the same as for var_dot3PauseTable above. */unsigned char *var_dot3PauseTable(struct variable *vp,            oid     *name,            size_t  *length,            int     exact,            size_t  *var_len,            WriteMethod **write_method){    /* variables we may use later */    static long long_ret;    static unsigned char string[SPRINT_MAX_LEN];    static oid objid[MAX_OID_LEN];    static struct counter64 c64;    if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE)        == MATCH_FAILED )        return NULL;        switch(vp->magic) {    case DOT3PAUSEADMINMODE:        *write_method = write_dot3PauseAdminMode;        long_ret = 0;        return (unsigned char *) &long_ret;    case DOT3PAUSEOPERMODE:        long_ret = 0;        return (unsigned char *) &long_ret;    case DOT3INPAUSEFRAMES:        long_ret = 0;        return (unsigned char *) &long_ret;    case DOT3OUTPAUSEFRAMES:        long_ret = 0;        return (unsigned char *) &long_ret;    default:        ERROR_MSG("");    }    return NULL;}intwrite_dot3PauseAdminMode(int      action,            u_char   *var_val,            u_char   var_val_type,            size_t   var_val_len,            u_char   *statP,            oid      *name,            size_t   name_len){    static long *long_ret;    int size;    switch ( action ) {    case RESERVE1:        if (var_val_type != ASN_INTEGER){            fprintf(stderr, "write to dot3PauseAdminMode not ASN_INTEGER\n");            return SNMP_ERR_WRONGTYPE;        }        if (var_val_len > sizeof(long_ret)){            fprintf(stderr,"write to dot3PauseAdminMode: bad length\n");            return SNMP_ERR_WRONGLENGTH;        }        break;            case RESERVE2:        size = var_val_len;        long_ret = (long *) var_val;        break;            case FREE:        /* Release any resources that have been allocated */        break;            case ACTION:        /* The variable has been stored in long_ret for           you to use, and you have just been asked to do something with           it.  Note that anything done here must be reversable in the UNDO case */        break;            case UNDO:        /* Back out any changes made in the ACTION case */        break;            case COMMIT:        /* Things are working well, so it's now safe to make the change           permanently.  Make sure that anything done here can't fail! */        break;    }    return SNMP_ERR_NOERROR;}#endif // UNSUPPORTED// EOF dot3.c

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?