Show misc_network.h syntax highlighted
/*
*
* Copyright (c) 2003 The Regents of the University of California. All
* rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Neither the name of the University nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* $Id: misc_network.h,v 1.9 2004/11/01 23:38:53 girod Exp $ */
/**
* \file misc_network.h network-related functions
*
*/
#ifndef __MISC_NETWORK__
#define __MISC_NETWORK__
#include <netinet/in.h>
/** \brief lookup a hostname, return address, in network order */
int misc_lookup_host(char *address, struct in_addr *addr);
/**
* \brief attempt to find the fqdn
*
* \param servername is usually some version of what we are trying to resolve
* \returns the fqdn. The user must free this char*
**/
char* misc_get_fqdn(char* servername);
/** \brief printable output of a network address */
char *net_unparse_address(struct sockaddr_in *addr);
/*
* UDP Tools
*/
int udp_listen(int port);
int udp_listen_if(int port, struct in_addr *bind_addr);
int get_ifaddr_by_name(char *name, struct in_addr *addr,
struct in_addr *bcast);
/**
* read a UDP packet off the wire, returning the data, the address it
* came from, and a kernel-generated timestamp of when the packet
* arrived.
*
* \a fd - file descriptor for reading
* \a buf - the buffer to return the data
* \a len - size of buf; on return, set to length of data inside it
* \a addr - (internet) address packet came from
* \a tv - kernel-generated timestamp.
*
* \note for this to work, the caller must have setsockopt'd the
* socket with SOL_TIMESTAMP when it was opened.
*/
int udp_read_with_timestamp(int fd, char *buf, int *len,
struct sockaddr_in *addr, struct timeval *tv);
#endif
See more files for this project here