diff options
author | Denis Ovsienko <infrastation@yandex.ru> | 2014-04-01 17:29:55 +0400 |
---|---|---|
committer | Denis Ovsienko <infrastation@yandex.ru> | 2014-04-01 19:46:05 +0400 |
commit | 51670d19496d42a99ced7358dab6fbdce94b7708 (patch) | |
tree | c2bfe0c173742d552c30e5c3efe0a8ba0033abc6 | |
parent | 4708c526a30c1e5c1d574b8f6c62c0af569b7a16 (diff) | |
download | tcpdump-51670d19496d42a99ced7358dab6fbdce94b7708.tar.gz |
NDOize safeputs() and safeputchar()
-rw-r--r-- | interface.h | 3 | ||||
-rw-r--r-- | netdissect.h | 4 | ||||
-rw-r--r-- | print-cfm.c | 6 | ||||
-rw-r--r-- | print-decnet.c | 2 | ||||
-rw-r--r-- | print-eap.c | 4 | ||||
-rw-r--r-- | print-fr.c | 2 | ||||
-rw-r--r-- | print-icmp6.c | 6 | ||||
-rw-r--r-- | print-isakmp.c | 2 | ||||
-rw-r--r-- | print-ldp.c | 2 | ||||
-rw-r--r-- | print-lldp.c | 24 | ||||
-rw-r--r-- | print-lwres.c | 2 | ||||
-rw-r--r-- | print-ospf.c | 2 | ||||
-rw-r--r-- | print-ppp.c | 10 | ||||
-rw-r--r-- | print-rsvp.c | 2 | ||||
-rw-r--r-- | print-sip.c | 2 | ||||
-rw-r--r-- | print-syslog.c | 2 | ||||
-rw-r--r-- | print-tcp.c | 2 | ||||
-rw-r--r-- | print-vqp.c | 2 | ||||
-rw-r--r-- | smbutil.c | 2 | ||||
-rw-r--r-- | util.c | 20 |
20 files changed, 47 insertions, 54 deletions
diff --git a/interface.h b/interface.h index 6a0978e1..47f03500 100644 --- a/interface.h +++ b/interface.h @@ -144,9 +144,6 @@ extern void warning(const char *, ...) extern char *read_infile(char *); extern char *copy_argv(char **); -extern void safeputchar(int); -extern void safeputs(const char *, int); - extern const char *isonsap_string(const u_char *, register u_int); extern const char *protoid_string(const u_char *); extern const char *ipxsap_string(u_short); diff --git a/netdissect.h b/netdissect.h index 9a34e622..1cfc6fd9 100644 --- a/netdissect.h +++ b/netdissect.h @@ -278,8 +278,8 @@ extern char *copy_argv(netdissect_options *, char **); #define ND_ISGRAPH(c) ((c) > 0x20 && (c) <= 0x7E) #define ND_TOASCII(c) ((c) & 0x7F) -extern void safeputchar(int); -extern void safeputs(const char *, int); +extern void safeputchar(netdissect_options *, const u_char); +extern void safeputs(netdissect_options *, const u_char *, const u_int); #ifdef LBL_ALIGN /* diff --git a/print-cfm.c b/print-cfm.c index 2dba46a7..2f43d613 100644 --- a/print-cfm.c +++ b/print-cfm.c @@ -372,7 +372,7 @@ cfm_print(register const u_char *pptr, register u_int length) { switch (msg_ptr.cfm_ccm->md_nameformat) { case CFM_CCM_MD_FORMAT_DNS: case CFM_CCM_MD_FORMAT_CHAR: - safeputs((const char *)msg_ptr.cfm_ccm->md_name, msg_ptr.cfm_ccm->md_namelength); + safeputs(gndo, msg_ptr.cfm_ccm->md_name, msg_ptr.cfm_ccm->md_namelength); break; case CFM_CCM_MD_FORMAT_MAC: @@ -405,7 +405,7 @@ cfm_print(register const u_char *pptr, register u_int length) { printf("\n\t MA Name: "); switch (*ma_nameformat) { case CFM_CCM_MA_FORMAT_CHAR: - safeputs((const char *)ma_name, *ma_namelength); + safeputs(gndo, ma_name, *ma_namelength); break; /* FIXME add printers for those MA formats - hexdump for now */ @@ -582,7 +582,7 @@ cfm_print(register const u_char *pptr, register u_int length) { case CFM_CHASSIS_ID_LOCAL: case CFM_CHASSIS_ID_CHASSIS_COMPONENT: case CFM_CHASSIS_ID_PORT_COMPONENT: - safeputs((const char *)tptr+1, chassis_id_length); + safeputs(gndo, tptr + 1, chassis_id_length); break; default: diff --git a/print-decnet.c b/print-decnet.c index 83c1518c..6a21684e 100644 --- a/print-decnet.c +++ b/print-decnet.c @@ -886,7 +886,7 @@ pdata(u_char *dp, u_int maxlen) while (x-- > 0) { c = *dp++; - safeputchar(c); + safeputchar(gndo, c); } } #endif diff --git a/print-eap.c b/print-eap.c index 7b58851b..fba40e27 100644 --- a/print-eap.c +++ b/print-eap.c @@ -209,14 +209,14 @@ eap_print(netdissect_options *ndo _U_, case EAP_TYPE_IDENTITY: if (len - 5 > 0) { printf(", Identity: "); - safeputs((const char *)tptr+5, len-5); + safeputs(gndo, tptr + 5, len - 5); } break; case EAP_TYPE_NOTIFICATION: if (len - 5 > 0) { printf(", Notification: "); - safeputs((const char *)tptr+5, len-5); + safeputs(gndo, tptr + 5, len - 5); } break; @@ -461,7 +461,7 @@ mfr_print(netdissect_options *ndo, case MFR_CTRL_IE_LINK_ID: for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) { if (*(tptr+idx) != 0) /* don't print null termination */ - safeputchar(*(tptr+idx)); + safeputchar(ndo, *(tptr + idx)); else break; } diff --git a/print-icmp6.c b/print-icmp6.c index 7b5f3f3c..a29a4f76 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -1556,7 +1556,7 @@ dnsname_print(netdissect_options *ndo, const u_char *cp, const u_char *ep) break; } while (i-- && cp < ep) { - safeputchar(*cp); + safeputchar(ndo, *cp); cp++; } if (cp + 1 < ep && *cp) @@ -1678,7 +1678,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp, cp++; ND_PRINT((ndo,", \"")); while (cp < ep) { - safeputchar(*cp); + safeputchar(ndo, *cp); cp++; } ND_PRINT((ndo,"\"")); @@ -1774,7 +1774,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp, cp++; ND_PRINT((ndo,", \"")); while (cp < ep) { - safeputchar(*cp); + safeputchar(ndo, *cp); cp++; } ND_PRINT((ndo,"\"")); diff --git a/print-isakmp.c b/print-isakmp.c index 2ebe083b..09e3c544 100644 --- a/print-isakmp.c +++ b/print-isakmp.c @@ -1397,7 +1397,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, int i; ND_PRINT((ndo," len=%d ", len)); for (i = 0; i < len; i++) - safeputchar(data[i]); + safeputchar(ndo, data[i]); len = 0; break; } diff --git a/print-ldp.c b/print-ldp.c index d699db04..c7e6baf9 100644 --- a/print-ldp.c +++ b/print-ldp.c @@ -433,7 +433,7 @@ ldp_tlv_print(netdissect_options *ndo, case LDP_FEC_MARTINI_IFPARM_DESC: ND_PRINT((ndo, ": ")); for (idx = 2; idx < vc_info_tlv_len; idx++) - safeputchar(*(tptr+idx)); + safeputchar(ndo, *(tptr + idx)); break; case LDP_FEC_MARTINI_IFPARM_VCCV: diff --git a/print-lldp.c b/print-lldp.c index e6cad7eb..f569da1e 100644 --- a/print-lldp.c +++ b/print-lldp.c @@ -679,7 +679,7 @@ lldp_private_8021_print(const u_char *tptr, u_int tlv_len) return hexdump; } printf("\n\t vlan name: "); - safeputs((const char *)tptr+7, sublen); + safeputs(gndo, tptr + 7, sublen); break; case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY: if (tlv_len < 5) { @@ -690,7 +690,7 @@ lldp_private_8021_print(const u_char *tptr, u_int tlv_len) return hexdump; } printf("\n\t protocol identity: "); - safeputs((const char *)tptr+5, sublen); + safeputs(gndo, tptr + 5, sublen); break; case LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION: if(tlv_len<LLDP_PRIVATE_8021_SUBTYPE_CONGESTION_NOTIFICATION_LENGTH){ @@ -1006,7 +1006,7 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len) *(tptr+6)); /* Country code */ - safeputs((const char *)(tptr+7), 2); + safeputs(gndo, tptr + 7, 2); lci_len = lci_len-3; tptr = tptr + 9; @@ -1034,7 +1034,7 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len) return hexdump; } - safeputs((const char *)tptr, ca_len); + safeputs(gndo, tptr, ca_len); tptr += ca_len; lci_len -= ca_len; } @@ -1042,7 +1042,7 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len) case LLDP_TIA_LOCATION_DATA_FORMAT_ECS_ELIN: printf("\n\t ECS ELIN id "); - safeputs((const char *)tptr+5, tlv_len-5); + safeputs(gndo, tptr + 5, tlv_len - 5); break; default: @@ -1079,7 +1079,7 @@ lldp_private_tia_print(const u_char *tptr, u_int tlv_len) case LLDP_PRIVATE_TIA_SUBTYPE_INVENTORY_ASSET_ID: printf("\n\t %s ", tok2str(lldp_tia_inventory_values, "unknown", subtype)); - safeputs((const char *)tptr+4, tlv_len-4); + safeputs(gndo, tptr + 4, tlv_len - 4); break; default: @@ -1352,7 +1352,7 @@ lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) { } if (oid_len) { printf("\n\t OID length %u", oid_len); - safeputs((const char *)tptr+1, oid_len); + safeputs(gndo, tptr + 1, oid_len); } } @@ -1427,7 +1427,7 @@ lldp_print(register const u_char *pptr, register u_int len) { case LLDP_CHASSIS_CHASSIS_COMP_SUBTYPE: case LLDP_CHASSIS_INTF_ALIAS_SUBTYPE: case LLDP_CHASSIS_PORT_COMP_SUBTYPE: - safeputs((const char *)tptr+1, tlv_len-1); + safeputs(gndo, tptr + 1, tlv_len - 1); break; case LLDP_CHASSIS_NETWORK_ADDR_SUBTYPE: @@ -1468,7 +1468,7 @@ lldp_print(register const u_char *pptr, register u_int len) { case LLDP_PORT_AGENT_CIRC_ID_SUBTYPE: case LLDP_PORT_INTF_ALIAS_SUBTYPE: case LLDP_PORT_PORT_COMP_SUBTYPE: - safeputs((const char *)tptr+1, tlv_len-1); + safeputs(gndo, tptr + 1, tlv_len - 1); break; case LLDP_PORT_NETWORK_ADDR_SUBTYPE: @@ -1498,7 +1498,7 @@ lldp_print(register const u_char *pptr, register u_int len) { case LLDP_PORT_DESCR_TLV: if (vflag) { printf(": "); - safeputs((const char *)tptr, tlv_len); + safeputs(gndo, tptr, tlv_len); } break; @@ -1508,13 +1508,13 @@ lldp_print(register const u_char *pptr, register u_int len) { * similar to the CDP printer. */ printf(": "); - safeputs((const char *)tptr, tlv_len); + safeputs(gndo, tptr, tlv_len); break; case LLDP_SYSTEM_DESCR_TLV: if (vflag) { printf("\n\t "); - safeputs((const char *)tptr, tlv_len); + safeputs(gndo, tptr, tlv_len); } break; diff --git a/print-lwres.c b/print-lwres.c index 6272ae2d..e4e80c75 100644 --- a/print-lwres.c +++ b/print-lwres.c @@ -200,7 +200,7 @@ lwres_printname(size_t l, const char *p0) printf(" "); for (i = 0; i < l; i++) - safeputchar(*p++); + safeputchar(gndo, *p++); p++; /* skip terminating \0 */ return p - p0; diff --git a/print-ospf.c b/print-ospf.c index 23fb1ce0..b36a61b5 100644 --- a/print-ospf.c +++ b/print-ospf.c @@ -1110,7 +1110,7 @@ ospf_print(register const u_char *bp, register u_int length, case OSPF_AUTH_SIMPLE: printf("\n\tSimple text password: "); - safeputs((const char *)op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN); + safeputs(gndo, op->ospf_authdata, OSPF_AUTH_SIMPLE_LEN); break; case OSPF_AUTH_MD5: diff --git a/print-ppp.c b/print-ppp.c index c442cb5f..4c07bb63 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -880,7 +880,7 @@ handle_chap(const u_char *p, int length) printf(", Name "); for (i = 0; i < name_size; i++) { TCHECK(*p); - safeputchar(*p++); + safeputchar(gndo, *p++); } break; case CHAP_SUCC: @@ -889,7 +889,7 @@ handle_chap(const u_char *p, int length) printf(", Msg "); for (i = 0; i< msg_size; i++) { TCHECK(*p); - safeputchar(*p++); + safeputchar(gndo, *p++); } break; } @@ -955,7 +955,7 @@ handle_pap(const u_char *p, int length) printf(", Peer "); for (i = 0; i < peerid_len; i++) { TCHECK(*p); - safeputchar(*p++); + safeputchar(gndo, *p++); } if (length - (p - p0) < 1) @@ -968,7 +968,7 @@ handle_pap(const u_char *p, int length) printf(", Name "); for (i = 0; i < passwd_len; i++) { TCHECK(*p); - safeputchar(*p++); + safeputchar(gndo, *p++); } break; case PAP_AACK: @@ -983,7 +983,7 @@ handle_pap(const u_char *p, int length) printf(", Msg "); for (i = 0; i< msg_len; i++) { TCHECK(*p); - safeputchar(*p++); + safeputchar(gndo, *p++); } break; } diff --git a/print-rsvp.c b/print-rsvp.c index 8d2f0264..adf1829b 100644 --- a/print-rsvp.c +++ b/print-rsvp.c @@ -1143,7 +1143,7 @@ _U_ return-1; printf("%s Session Name: ", ident); for (i = 0; i < namelen; i++) - safeputchar(*(obj_tptr+4+i)); + safeputchar(gndo, *(obj_tptr + 4 + i)); printf("%s Setup Priority: %u, Holding Priority: %u, Flags: [%s] (%#x)", ident, (int)*obj_tptr, diff --git a/print-sip.c b/print-sip.c index a73e70a1..71d1bc34 100644 --- a/print-sip.c +++ b/print-sip.c @@ -39,7 +39,7 @@ sip_print(register const u_char *pptr, register u_int len) for (idx = 0; idx < len; idx++) { TCHECK2(*(pptr+idx), 2); if (EXTRACT_16BITS(pptr+idx) != 0x0d0a) { /* linefeed ? */ - safeputchar(*(pptr+idx)); + safeputchar(gndo, *(pptr + idx)); } else { printf("\n\t"); idx+=1; diff --git a/print-syslog.c b/print-syslog.c index 40c8a924..d332f67f 100644 --- a/print-syslog.c +++ b/print-syslog.c @@ -133,7 +133,7 @@ syslog_print(register const u_char *pptr, register u_int len) /* print the syslog text in verbose mode */ for (; msg_off < len; msg_off++) { TCHECK2(*(pptr+msg_off), 1); - safeputchar(*(pptr+msg_off)); + safeputchar(gndo, *(pptr + msg_off)); } if (vflag > 1) diff --git a/print-tcp.c b/print-tcp.c index 32ea7246..4e970038 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -777,7 +777,7 @@ print_tcp_rst_data(register const u_char *sp, u_int length) putchar(' '); while (length-- && sp <= snapend) { c = *sp++; - safeputchar(c); + safeputchar(gndo, c); } putchar(']'); } diff --git a/print-vqp.c b/print-vqp.c index bf25bf7a..e583f445 100644 --- a/print-vqp.c +++ b/print-vqp.c @@ -179,7 +179,7 @@ vqp_print(netdissect_options *ndo, register const u_char *pptr, register u_int l case VQP_OBJ_VLAN_NAME: case VQP_OBJ_VTP_DOMAIN: case VQP_OBJ_ETHERNET_PKT: - safeputs((const char *)tptr, vqp_obj_len); + safeputs(ndo, tptr, vqp_obj_len); break; /* those objects have similar semantics - fall through */ case VQP_OBJ_MAC_ADDRESS: @@ -245,7 +245,7 @@ print_asc(const unsigned char *buf, int len) { int i; for (i = 0; i < len; i++) - safeputchar(buf[i]); + safeputchar(gndo, buf[i]); } static const char * @@ -578,27 +578,23 @@ read_infile(char *fname) } void -safeputs(const char *s, int maxlen) +safeputs(netdissect_options *ndo, + const u_char *s, const u_int maxlen) { - int idx = 0; + u_int idx = 0; while (*s && idx < maxlen) { - safeputchar(*s); - idx++; + safeputchar(ndo, *s); + idx++; s++; } } void -safeputchar(int c) +safeputchar(netdissect_options *ndo, + const u_char c) { - unsigned char ch; - - ch = (unsigned char)(c & 0xff); - if (ch < 0x80 && ND_ISPRINT(ch)) - printf("%c", ch); - else - printf("\\0x%02x", ch); + ND_PRINT((ndo, (c < 0x80 && ND_ISPRINT(c)) ? "%c" : "\\0x%02x", c)); } #ifdef LBL_ALIGN |