X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibnet.so_src%2Fnet.h;h=d02da0bdf7b3402acb2e3363c32771c6ae080090;hb=100c53216ed83a0ed68e27a5ba457544e0d56a9f;hp=05deb9f99697b8d22bc8ae306d878c0298238cae;hpb=d5834686ad14b66420060192445f06bce85db389;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libnet.so_src/net.h b/Usermode/Libraries/libnet.so_src/net.h index 05deb9f9..d02da0bd 100644 --- a/Usermode/Libraries/libnet.so_src/net.h +++ b/Usermode/Libraries/libnet.so_src/net.h @@ -6,6 +6,12 @@ #ifndef __LIBNET_H_ #define __LIBNET_H_ +enum { + NET_ADDRTYPE_NULL = 0, + NET_ADDRTYPE_IPV4 = 4, + NET_ADDRTYPE_IPV6 = 6 +}; + /** * \brief Parse a string as an IP Address * \param String Input string @@ -14,12 +20,39 @@ */ extern int Net_ParseAddress(const char *String, void *Addr); +/** + * \brief Convert a network address into a string + * \param AddressType Address family as returned by Net_ParseAddress + * \param Address Address data + */ +extern const char *Net_PrintAddress(int AddressType, void *Address); + +/** + * \brief Get the size in bytes of an address type + * \param AddressType Address type returned by Net_ParseAddress + * \return Size of an address in bytes + */ +extern int Net_GetAddressSize(int AddressType); + /** * \brief Get the interface required to reach \a Addr * \param AddrType Addresss Family (4: IPv4, 6: IPv6) * \param Addr Address in binary format * \return Interface number */ -extern int Net_GetInterface(int AddrType, void *Addr); +extern char *Net_GetInterface(int AddrType, void *Addr); + +/** + * \brief Open a network socket file + * \param AddrType Address family + * \param Addr Binary address + * \param SocketName Socket type to open (e.g. tcpc for TCP client) + * If NULL, the node directory is opened + * \return Socket file descriptor (as returned by \a open), or -1 on error + * + * Opens a file using /Devices/ip/routes/:/ + * + */ +extern int Net_OpenSocket(int AddrType, void *Addr, const char *SocketName); #endif