📄 print-l2tp.c
字号:
print_octets(dat, 16); /* XXX length should be 16? */}static voidl2tp_assnd_sess_id_print(const u_char *dat, u_int length){ print_short((u_short *)dat);}static voidl2tp_call_ser_num_print(const u_char *dat, u_int length){ print_int((u_int *)dat);}static voidl2tp_minimum_bps_print(const u_char *dat, u_int length){ print_int((u_int *)dat);}static voidl2tp_maximum_bps_print(const u_char *dat, u_int length){ print_int((u_int *)dat);}static voidl2tp_bearer_type_print(const u_char *dat, u_int length){ u_int *ptr = (u_int *)dat; if (ntohl(*ptr) & L2TP_BEARER_TYPE_ANALOG_MASK) { printf("A"); } if (ntohl(*ptr) & L2TP_BEARER_TYPE_DIGITAL_MASK) { printf("D"); }}static voidl2tp_framing_type_print(const u_char *dat, u_int length){ u_int *ptr = (u_int *)dat; if (ntohl(*ptr) & L2TP_FRAMING_TYPE_ASYNC_MASK) { printf("A"); } if (ntohl(*ptr) & L2TP_FRAMING_TYPE_SYNC_MASK) { printf("S"); }}static voidl2tp_packet_proc_delay_print(const u_char *dat, u_int length){ printf("obsolete");}static voidl2tp_called_number_print(const u_char *dat, u_int length){ print_string(dat, length);}static voidl2tp_calling_number_print(const u_char *dat, u_int length){ print_string(dat, length);}static voidl2tp_sub_address_print(const u_char *dat, u_int length){ print_string(dat, length);}static voidl2tp_tx_conn_speed_print(const u_char *dat, u_int length){ print_int((u_int *)dat);}static voidl2tp_phy_channel_id_print(const u_char *dat, u_int length){ print_int((u_int *)dat);}static voidl2tp_ini_recv_lcp_print(const u_char *dat, u_int length){ print_octets(dat, length);}static voidl2tp_last_sent_lcp_print(const u_char *dat, u_int length){ print_octets(dat, length);}static voidl2tp_last_recv_lcp_print(const u_char *dat, u_int length){ print_octets(dat, length);}static voidl2tp_proxy_auth_type_print(const u_char *dat, u_int length){ u_short *ptr = (u_short *)dat; switch (ntohs(*ptr)) { case L2TP_AUTHEN_TYPE_RESERVED: printf("Reserved"); break; case L2TP_AUTHEN_TYPE_TEXTUAL: printf("Textual"); break; case L2TP_AUTHEN_TYPE_CHAP: printf("CHAP"); break; case L2TP_AUTHEN_TYPE_PAP: printf("PAP"); break; case L2TP_AUTHEN_TYPE_NO_AUTH: printf("No Auth"); break; case L2TP_AUTHEN_TYPE_MSCHAP: printf("MS-CHAP"); break; default: printf("unknown"); }}static voidl2tp_proxy_auth_name_print(const u_char *dat, u_int length){ print_octets(dat, length);}static voidl2tp_proxy_auth_chal_print(const u_char *dat, u_int length){ print_octets(dat, length);}static voidl2tp_proxy_auth_id_print(const u_char *dat, u_int length){ u_short *ptr = (u_short *)dat; printf("%u", ntohs(*ptr) & L2TP_PROXY_AUTH_ID_MASK);}static voidl2tp_proxy_auth_resp_print(const u_char *dat, u_int length){ print_octets(dat, length);}static voidl2tp_call_errors_print(const u_char *dat, u_int length){ struct l2tp_call_errors *ptr = (struct l2tp_call_errors *)dat; printf("CRCErr=%d FrameErr=%d HardOver=%d BufOver=%d ", ptr->crc_errs, ptr->framing_errs, ptr->hardware_overruns, ptr->buffer_overruns); printf("Timeout=%d AlingErr=%d", ptr->timeout_errs, ptr->alignment_errs);}static voidl2tp_accm_print(const u_char *dat, u_int length){ struct l2tp_accm *ptr = (struct l2tp_accm *)dat; printf("send=%x recv=%x", ptr->send_accm, ptr->recv_accm);}static voidl2tp_random_vector_print(const u_char *dat, u_int length){ print_octets(dat, length);}static voidl2tp_private_grp_id_print(const u_char *dat, u_int length){ print_string(dat, length); /* XXX print_octets is more appropriate?? */}static voidl2tp_rx_conn_speed_print(const u_char *dat, u_int length){ print_int((u_int *)dat);}static voidl2tp_seq_required_print(const u_char *dat, u_int length){ return;}static voidl2tp_avp_print(const u_char *dat, u_int length){ u_int len; const u_short *ptr = (u_short *)dat; int hidden = FALSE; printf(" "); if (length > 0 && (snapend - dat) >= 2) { /* there must be at least two octets for the length to be decoded */ if ((len = (ntohs(*ptr) & L2TP_AVP_HDR_LEN_MASK)) <= (snapend - dat)) { if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) { printf("*"); } if (ntohs(*ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) { hidden = TRUE; printf("?"); } } else { printf("|..."); return; } ptr++; if (ntohs(*ptr)) { /* Vendor Specific Attribute */ printf("VENDOR%04x:", ntohs(*ptr)); ptr++; printf("ATTR%04x", ntohs(*ptr)); printf("("); print_octets((u_char *)ptr+2, len-6); printf(")"); } else { /* IETF-defined Attribute */ ptr++; if (ntohs(*ptr) < L2TP_MAX_AVP_INDEX) { printf("%s", l2tp_avp[ntohs(*ptr)].name); printf("("); if (!hidden) { (l2tp_avp[ntohs(*ptr)].print) ((u_char *)ptr+2, len-6); } else { printf("???"); } printf(")"); } else { printf(" invalid AVP %u", ntohs(*ptr)); } } l2tp_avp_print(dat + len, length - len); } else if (length == 0) { return; } else { printf("|..."); }}voidl2tp_print(const u_char *dat, u_int length){ const u_short *ptr = (u_short *)dat; u_int cnt = 0; /* total octets consumed */ u_short pad; int flag_t, flag_l, flag_s, flag_o, flag_p; u_short l2tp_len; flag_t = flag_l = flag_s = flag_o = flag_p = FALSE; if (min(length, snapend - dat) - 6 < 0) { /* flag/ver, tunnel_id, session_id must be present for this packet to be properly decoded */ printf("%s", tstr); return; } if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) { printf(" l2tp:"); } else if ((ntohs(*ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) { printf(" l2f:"); return; /* nothing to do */ } else { printf(" Unknown Version, neither L2F(1) nor L2TP(2)"); return; /* nothing we can do */ } printf("["); if (ntohs(*ptr) & L2TP_FLAG_TYPE) { flag_t = TRUE; printf("T"); } if (ntohs(*ptr) & L2TP_FLAG_LENGTH) { flag_l = TRUE; printf("L"); } if (ntohs(*ptr) & L2TP_FLAG_SEQUENCE) { flag_s = TRUE; printf("S"); } if (ntohs(*ptr) & L2TP_FLAG_OFFSET) { flag_o = TRUE; printf("O"); } if (ntohs(*ptr) & L2TP_FLAG_PRIORITY) { flag_p = TRUE; printf("P"); } printf("]"); ptr++; cnt += 2; if (flag_l) { l2tp_len = ntohs(*ptr++); /* XXX need to consider truncation ?? */ cnt += 2; } else { l2tp_len = 0; } printf("(%u/", ntohs(*ptr++)); /* Tunnel ID */ printf("%u)", ntohs(*ptr++)); /* Session ID */ cnt += 4; if (flag_s) { printf("Ns=%u,", ntohs(*ptr++)); printf("Nr=%u", ntohs(*ptr++)); cnt += 4; } if (flag_o) { pad = ntohs(*ptr++); ptr += pad / sizeof(*ptr); cnt += (2 + pad); } if (flag_t) { if (length - cnt == 0) { printf(" ZLB"); } else { l2tp_avp_print((u_char *)ptr, length - cnt); } } else { printf(" {"); ppp_print((u_char *)ptr, length - cnt); printf("}"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -