Retrieve MTU and source address of BSD send failure

Hi,

If I am sending a UDP packet or ICMP packet through an unbound BSD socket, and I have the don't fragment bit enabled on those packets, is there a way to get the source IP address and interface MTU of whatever packet that was sent?

I am specifically looking the case where the packet fails to leave the device I am using, due to the packet size being larger than the interface MTU. The way that this is indicated to me is the send operation returning EMSGSIZE.

This is useful with PMTU discovery for example on a cellular interface, where the MTU can be around ~1430.

Thank you.

Retrieve MTU and source address of BSD send failure
 
 
Q