# /* udp_alloc.c */ /* EMACS_MODES: c !fill */ /* User Datagram Protocol layer for the UNIX network system. The * following routines are included: * udp_alloc allocate storage for a udp packet * udp_free free an allocated udp packet */ #include caddr_t udp_alloc (datalen, optlen) /* Allocate the space for a udp packet, with enough space for a data area * of length datalen and enough space for optlen bytes of options. Return * a pointer to the packet or NULL if unable to allocate. Also, set up the * length fields of the internet packet so that the in_head, in_data, and * udp_data macros will work properly. * * Arguments: */ reg int datalen; /* length of data area */ int optlen; /* length of options string */ { reg int len; /* total udp len */ optlen = (optlen + 3) & ~3; /* round option len up */ len = datalen + sizeof (struct udp); len = (len + 1) & ~1; /* round length up */ return (in_alloc (len, optlen)); } udp_free (pkt) /* Free the packet pointed to by pkt. Just call down to internet free routine. * * Arguments: */ caddr_t pkt; /* ptr. to packet to free */ { in_free (pkt); }