⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 print-rsvp.c

📁 TCPDUMP的C语言源代码,是在数据链路层的应用
💻 C
📖 第 1 页 / 共 5 页
字号:
static const struct tok rsvp_obj_rro_flag_values[] = {    { 0x01,	              "Local protection available" },    { 0x02,                   "Local protection in use" },    { 0x04,                   "Bandwidth protection" },    { 0x08,                   "Node protection" },    { 0, NULL}};static const struct tok rsvp_resstyle_values[] = {    { 17,	              "Wildcard Filter" },    { 10,                     "Fixed Filter" },    { 18,                     "Shared Explicit" },    { 0, NULL}};#define RSVP_OBJ_INTSERV_GUARANTEED_SERV 2#define RSVP_OBJ_INTSERV_CONTROLLED_LOAD 5static const struct tok rsvp_intserv_service_type_values[] = {    { 1,                                "Default/Global Information" },    { RSVP_OBJ_INTSERV_GUARANTEED_SERV, "Guaranteed Service" },    { RSVP_OBJ_INTSERV_CONTROLLED_LOAD,	"Controlled Load" },    { 0, NULL}};static const struct tok rsvp_intserv_parameter_id_values[] = {    { 4,                     "IS hop cnt" },    { 6,                     "Path b/w estimate" },    { 8,                     "Minimum path latency" },    { 10,                    "Composed MTU" },    { 127,                   "Token Bucket TSpec" },    { 130,                   "Guaranteed Service RSpec" },    { 133,                   "End-to-end composed value for C" },    { 134,                   "End-to-end composed value for D" },    { 135,                   "Since-last-reshaping point composed C" },    { 136,                   "Since-last-reshaping point composed D" },    { 0, NULL}};static struct tok rsvp_session_attribute_flag_values[] = {    { 0x01,	              "Local Protection desired" },    { 0x02,                   "Label Recording desired" },    { 0x04,                   "SE Style desired" },    { 0x08,                   "Bandwidth protection desired" }, /* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */    { 0x10,                   "Node protection desired" },      /* draft-ietf-mpls-rsvp-lsp-fastreroute-02.txt */    { 0, NULL}};static struct tok rsvp_obj_prop_tlv_values[] = {    { 0x01,                   "Cos" },    { 0x02,                   "Metric 1" },    { 0x04,                   "Metric 2" },    { 0x08,                   "CCC Status" },    { 0x10,                   "Path Type" },    { 0, NULL}};#define RSVP_OBJ_ERROR_SPEC_CODE_ROUTING 24#define RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY  25#define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE 28#define RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD 125static struct tok rsvp_obj_error_code_values[] = {    { RSVP_OBJ_ERROR_SPEC_CODE_ROUTING, "Routing Problem" },    { RSVP_OBJ_ERROR_SPEC_CODE_NOTIFY,  "Notify Error" },    { RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE, "Diffserv TE Error" },    { RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD, "Diffserv TE Error (Old)" },    { 0, NULL}};static struct tok rsvp_obj_error_code_routing_values[] = {    { 1,                      "Bad EXPLICIT_ROUTE object" },    { 2,                      "Bad strict node" },    { 3,                      "Bad loose node" },    { 4,                      "Bad initial subobject" },    { 5,                      "No route available toward destination" },    { 6,                      "Unacceptable label value" },    { 7,                      "RRO indicated routing loops" },    { 8,                      "non-RSVP-capable router in the path" },    { 9,                      "MPLS label allocation failure" },    { 10,                     "Unsupported L3PID" },    { 0, NULL}};static struct tok rsvp_obj_error_code_diffserv_te_values[] = {    { 1,                      "Unexpected CT object" },    { 2,                      "Unsupported CT" },    { 3,                      "Invalid CT value" },    { 4,                      "CT/setup priority do not form a configured TE-Class" },    { 5,                      "CT/holding priority do not form a configured TE-Class" },    { 6,                      "CT/setup priority and CT/holding priority do not form a configured TE-Class" },    { 7,                      "Inconsistency between signaled PSC and signaled CT" },     { 8,                      "Inconsistency between signaled PHBs and signaled CT" },   { 0, NULL}};/* rfc3473 / rfc 3471 */static const struct tok rsvp_obj_admin_status_flag_values[] = {    { 0x80000000, "Reflect" },    { 0x00000004, "Testing" },    { 0x00000002, "Admin-down" },    { 0x00000001, "Delete-in-progress" },    { 0, NULL}};/* label set actions - rfc3471 */#define LABEL_SET_INCLUSIVE_LIST  0#define LABEL_SET_EXCLUSIVE_LIST  1#define LABEL_SET_INCLUSIVE_RANGE 2#define LABEL_SET_EXCLUSIVE_RANGE 3static const struct tok rsvp_obj_label_set_action_values[] = {    { LABEL_SET_INCLUSIVE_LIST, "Inclusive list" },    { LABEL_SET_EXCLUSIVE_LIST, "Exclusive list" },    { LABEL_SET_INCLUSIVE_RANGE, "Inclusive range" },    { LABEL_SET_EXCLUSIVE_RANGE, "Exclusive range" },    { 0, NULL}};/* OIF RSVP extensions UNI 1.0 Signaling, release 2 */#define RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS	    1#define RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS 2#define RSVP_GEN_UNI_SUBOBJ_DIVERSITY		    3#define RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL            4#define RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL           5static const struct tok rsvp_obj_generalized_uni_values[] = {    { RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS, "Source TNA address" },    { RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS, "Destination TNA address" },    { RSVP_GEN_UNI_SUBOBJ_DIVERSITY, "Diversity" },    { RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL, "Egress label" },    { RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL, "Service level" },    { 0, NULL}};static int rsvp_intserv_print(const u_char *, u_short);/*  * this is a dissector for all the intserv defined * specs as defined per rfc2215 * it is called from various rsvp objects; * returns the amount of bytes being processed */static intrsvp_intserv_print(const u_char *tptr, u_short obj_tlen) {    int parameter_id,parameter_length;    union {	float f;	u_int32_t i;    } bw;    if (obj_tlen < 4)        return 0;    parameter_id = *(tptr);    parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */    printf("\n\t      Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",           tok2str(rsvp_intserv_parameter_id_values,"unknown",parameter_id),           parameter_id,           parameter_length,           *(tptr+1));    if (obj_tlen < parameter_length+4)        return 0;    switch(parameter_id) { /* parameter_id */    case 4:       /*        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |    4 (e)      |    (f)        |           1 (g)               |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |        IS hop cnt (32-bit unsigned integer)                   |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        */        if (parameter_length == 4)            printf("\n\t\tIS hop count: %u", EXTRACT_32BITS(tptr+4));        break;    case 6:       /*        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |    6 (h)      |    (i)        |           1 (j)               |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |  Path b/w estimate  (32-bit IEEE floating point number)       |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        */        if (parameter_length == 4) {            bw.i = EXTRACT_32BITS(tptr+4);            printf("\n\t\tPath b/w estimate: %.10g Mbps", bw.f/125000);        }        break;    case 8:       /*        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |     8 (k)     |    (l)        |           1 (m)               |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |        Minimum path latency (32-bit integer)                  |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        */        if (parameter_length == 4) {            printf("\n\t\tMinimum path latency: ");            if (EXTRACT_32BITS(tptr+4) == 0xffffffff)                printf("don't care");            else                printf("%u", EXTRACT_32BITS(tptr+4));        }        break;    case 10:       /*        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |     10 (n)    |      (o)      |           1 (p)               |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |      Composed MTU (32-bit unsigned integer)                   |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        */        if (parameter_length == 4)            printf("\n\t\tComposed MTU: %u bytes", EXTRACT_32BITS(tptr+4));        break;    case 127:       /*         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |   127 (e)     |    0 (f)      |             5 (g)             |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |  Token Bucket Rate [r] (32-bit IEEE floating point number)    |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |  Token Bucket Size [b] (32-bit IEEE floating point number)    |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |  Peak Data Rate [p] (32-bit IEEE floating point number)       |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |  Minimum Policed Unit [m] (32-bit integer)                    |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |  Maximum Packet Size [M]  (32-bit integer)                    |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        */        if (parameter_length == 20) {            bw.i = EXTRACT_32BITS(tptr+4);            printf("\n\t\tToken Bucket Rate: %.10g Mbps", bw.f/125000);            bw.i = EXTRACT_32BITS(tptr+8);            printf("\n\t\tToken Bucket Size: %.10g bytes", bw.f);            bw.i = EXTRACT_32BITS(tptr+12);            printf("\n\t\tPeak Data Rate: %.10g Mbps", bw.f/125000);            printf("\n\t\tMinimum Policed Unit: %u bytes", EXTRACT_32BITS(tptr+16));            printf("\n\t\tMaximum Packet Size: %u bytes", EXTRACT_32BITS(tptr+20));        }        break;    case 130:       /*         * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |     130 (h)   |    0 (i)      |            2 (j)              |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |  Rate [R]  (32-bit IEEE floating point number)                |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        * |  Slack Term [S]  (32-bit integer)                             |        * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+        */        if (parameter_length == 8) {            bw.i = EXTRACT_32BITS(tptr+4);            printf("\n\t\tRate: %.10g Mbps", bw.f/125000);            printf("\n\t\tSlack Term: %u", EXTRACT_32BITS(tptr+8));        }        break;    case 133:    case 134:    case 135:    case 136:        if (parameter_length == 4)            printf("\n\t\tValue: %u", EXTRACT_32BITS(tptr+4));        break;    default:        if (vflag <= 1)            print_unknown_data(tptr+4,"\n\t\t",parameter_length);    }    return (parameter_length+4); /* header length 4 bytes */}static intrsvp_obj_print (const u_char *tptr, const char *ident, u_int tlen) {    const struct rsvp_object_header *rsvp_obj_header;    const u_char *obj_tptr;    union {        const struct rsvp_obj_integrity_t *rsvp_obj_integrity;        const struct rsvp_obj_frr_t *rsvp_obj_frr;    } obj_ptr;    u_short rsvp_obj_len,rsvp_obj_ctype,obj_tlen,intserv_serv_tlen;    int hexdump,processed,padbytes,error_code,error_value,i;    union {	float f;	u_int32_t i;    } bw;    u_int8_t namelen;    u_int action, subchannel;    while(tlen>=sizeof(struct rsvp_object_header)) {        /* did we capture enough for fully decoding the object header ? */        if (!TTEST2(*tptr, sizeof(struct rsvp_object_header)))            goto trunc;        rsvp_obj_header = (const struct rsvp_object_header *)tptr;        rsvp_obj_len=EXTRACT_16BITS(rsvp_obj_header->length);        rsvp_obj_ctype=rsvp_obj_header->ctype;        if(rsvp_obj_len % 4) {            printf("%sERROR: object header size %u not a multiple of 4", ident, rsvp_obj_len);            return -1;        }        if(rsvp_obj_len < sizeof(struct rsvp_object_header)) {            printf("%sERROR: object header too short %u < %lu", ident, rsvp_obj_len,                   (unsigned long)sizeof(const struct rsvp_object_header));            return -1;        }        printf("%s%s Object (%u) Flags: [%s",               ident,               tok2str(rsvp_obj_values,                       "Unknown",                       rsvp_obj_header->class_num),               rsvp_obj_header->class_num,               ((rsvp_obj_header->class_num)&0x80) ? "ignore" : "reject");

⌨️ 快捷键说明

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