library/src/network/BP-Network.cc
// Converts an ip protocol to an ascii string.  String must be freed on return.
Converts an ip protocol to an ascii string.  String must be freed on return.
Converts an ip protocol to an ascii string . String must be freed on return .
char * BP_NetIPProtoToAscii(size_t ip_proto)
{
	if(ip_proto >= IPPROTO_MAX)
		return NULL;
	switch(ip_proto)
	{
		case IPPROTO_IP:
			return strdup("IPPROTO_IP or IPPROTO_HOPOPTS or ZERO/UNSET");
			break;
		case IPPROTO_ICMP:
			return strdup("IPPROTO_ICMP");
			break;
		case IPPROTO_IGMP:
			return strdup("IPPROTO_IGMP");
			break;
		case IPPROTO_IPIP:
			return strdup("IPPROTO_IPIP");
			break;
		case IPPROTO_TCP:
			return strdup("IPPROTO_TCP");
			break;
		case IPPROTO_EGP:
			return strdup("IPPROTO_EGP");
			break;
		case IPPROTO_PUP:
			return strdup("IPPROTO_PUP");
			break;
		case IPPROTO_UDP:
			return strdup("IPPROTO_UDP");
			break;
		case IPPROTO_IDP:
			return strdup("IPPROTO_IDP");
			break;
		case IPPROTO_TP:
			return strdup("IPPROTO_TP");
			break;
		case IPPROTO_DCCP:
			return strdup("IPPROTO_DCCP");
			break;
		case IPPROTO_IPV6:
			return strdup("IPPROTO_IPV6");
			break;
		case IPPROTO_ROUTING:
			return strdup("IPPROTO_ROUTING");
			break;
		case IPPROTO_FRAGMENT:
			return strdup("IPPROTO_FRAGMENT");
			break;
		case IPPROTO_RSVP:
			return strdup("IPPROTO_RSVP");
			break;
		case IPPROTO_GRE:
			return strdup("IPPROTO_GRE");
			break;
		case IPPROTO_ESP:
			return strdup("IPPROTO_ESP");
			break;
		case IPPROTO_AH:
			return strdup("IPPROTO_AH");
			break;
		case IPPROTO_ICMPV6:
			return strdup("IPPROTO_ICMPV6");
			break;
		case IPPROTO_NONE:
			return strdup("IPPROTO_NONE");
			break;
		case IPPROTO_DSTOPTS:
			return strdup("IPPROTO_DSTOPTS");
			break;
		case IPPROTO_MTP:
			return strdup("IPPROTO_MTP");
			break;
		case IPPROTO_ENCAP:
			return strdup("IPPROTO_ENCAP");
			break;
		case IPPROTO_PIM:
			return strdup("IPPROTO_PIM");
			break;
		case IPPROTO_COMP:
			return strdup("IPPROTO_COMP");
			break;
		case IPPROTO_SCTP:
			return strdup("IPPROTO_SCTP");
			break;
		case IPPROTO_UDPLITE:
			return strdup("IPPROTO_UDPLITE");
			break;
		case IPPROTO_RAW:
			return strdup("IPPROTO_RAW");
			break;
		default:
			break;
	}
}
char * BP_NetIPProtoToAscii ( size_t ip_proto ) { if ( ip_proto >= IPPROTO_MAX ) return NULL ; switch ( ip_proto ) { case IPPROTO_IP : return strdup ( " " ) ; break ; case IPPROTO_ICMP : return strdup ( " " ) ; break ; case IPPROTO_IGMP : return strdup ( " " ) ; break ; case IPPROTO_IPIP : return strdup ( " " ) ; break ; case IPPROTO_TCP : return strdup ( " " ) ; break ; case IPPROTO_EGP : return strdup ( " " ) ; break ; case IPPROTO_PUP : return strdup ( " " ) ; break ; case IPPROTO_UDP : return strdup ( " " ) ; break ; case IPPROTO_IDP : return strdup ( " " ) ; break ; case IPPROTO_TP : return strdup ( " " ) ; break ; case IPPROTO_DCCP : return strdup ( " " ) ; break ; case IPPROTO_IPV6 : return strdup ( " " ) ; break ; case IPPROTO_ROUTING : return strdup ( " " ) ; break ; case IPPROTO_FRAGMENT : return strdup ( " " ) ; break ; case IPPROTO_RSVP : return strdup ( " " ) ; break ; case IPPROTO_GRE : return strdup ( " " ) ; break ; case IPPROTO_ESP : return strdup ( " " ) ; break ; case IPPROTO_AH : return strdup ( " " ) ; break ; case IPPROTO_ICMPV6 : return strdup ( " " ) ; break ; case IPPROTO_NONE : return strdup ( " " ) ; break ; case IPPROTO_DSTOPTS : return strdup ( " " ) ; break ; case IPPROTO_MTP : return strdup ( " " ) ; break ; case IPPROTO_ENCAP : return strdup ( " " ) ; break ; case IPPROTO_PIM : return strdup ( " " ) ; break ; case IPPROTO_COMP : return strdup ( " " ) ; break ; case IPPROTO_SCTP : return strdup ( " " ) ; break ; case IPPROTO_UDPLITE : return strdup ( " " ) ; break ; case IPPROTO_RAW : return strdup ( " " ) ; break ; default : break ; } }
Converts an ip protocol to an ascii string.
Converts an ip protocol to an ascii string .
// ensure the protocol isn't at or above cap /* Dummy protocol for TCP.  */ /* Internet Control Message Protocol.  */ /* Internet Group Management Protocol. */ /* IPIP tunnels (older KA9Q tunnels use 94).  */ /* Transmission Control Protocol.  */ /* Exterior Gateway Protocol.  */ /* PUP protocol.  */ /* User Datagram Protocol.  */ /* XNS IDP protocol.  */ /* SO Transport Protocol Class 4.  */ /* Datagram Congestion Control Protocol.  */ /* IPv6 header.  */ /* IPv6 routing header.  */ /* IPv6 fragmentation header.  */ /* Reservation Protocol.  */ /* General Routing Encapsulation.  */ /* encapsulating security payload.  */ /* authentication header.  */ /* ICMPv6.  */ /* IPv6 no next header.  */ /* IPv6 destination options.  */ /* Multicast Transport Protocol.  */ /* Encapsulation Header.  */ /* Protocol Independent Multicast.  */ /* Compression Header Protocol.  */ /* Stream Control Transmission Protocol.  */ /* UDP-Lite protocol.  */ /* Raw IP packets.  */ // bad value