/** * \brief output max payload size for a link * * This does a best effort to find the maximum packet size * for the link. In case of uncertainty, it will output a * majorant to be sure avoid the cost of dynamic allocation. * * \param Name of a network interface * \retval 0 in case of error */ int GetIfaceMaxPayloadSize(char *pcap_dev) { int ll_header = GetIfaceMaxHWHeaderLength(pcap_dev); int mtu = GetIfaceMTU(pcap_dev); switch (mtu) { case 0: case -1: return 0; } if (ll_header == -1) { /* be conservative, choose a big one */ ll_header = 16; } return ll_header + mtu; }
/** * \brief output max packet size for a link * * This does a best effort to find the maximum packet size * for the link. In case of uncertainty, it will output a * majorant to be sure avoid the cost of dynamic allocation. * * \param Name of a network interface * \retval 0 in case of error */ int GetIfaceMaxPacketSize(const char *pcap_dev) { if ((pcap_dev == NULL) || strlen(pcap_dev) == 0) return 0; int mtu = GetIfaceMTU(pcap_dev); switch (mtu) { case 0: case -1: return 0; } int ll_header = GetIfaceMaxHWHeaderLength(pcap_dev); if (ll_header == -1) { /* be conservative, choose a big one */ ll_header = 16; } return ll_header + mtu; }