The UDP header struct defined at /usr/include/netinet/udp.h is as follows
struct udphdr { u_int16_t source; u_int16_t dest; u_int16_t len; u_int16_t
I was searching the net for some code which will calculate the udp header (with the pseudo ip header as mentioned above).
Finally I found the open-bsd dhclient packet.c:
https://github.com/openbsd/src/blob/master/sbin/dhclient/packet.c
check out the function assemble_udp_ip_header()
assemble_udp_ip_header()