/* * Active Router Transport Protocol (ARTP) implementation * Copyright (c) 2004, Tomas Rebok * All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the "BSD License" which is * distributed with the software in the file LICENSE. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the BSD * License for more details. */ /** @file * @c ARTP socket address manipulating functions. * @author Tomas Rebok * @date 2004 */ #ifndef ARTP_NET_H #define ARTP_NET_H 1 #include #include #include #include #include /** Supported address families structure. * This structure is used for storing senders and receivers - it MUST contain * all supported address families structures (alocated size is the maximal * size of all specified structures). */ union artp_receiver { /** IPv4 address family */ struct sockaddr_in ip; /** IPv6 address family */ struct sockaddr_in6 ip6; }; /** Compare two socket addresses. * This function is used for comparing two socket addresses. Structures are * compared depending on their address family. * * @param r1 * the pointer to the place where the first address information is stored * * @param r2 * the pointer to the place where the second address information is stored * * @return zero * addresses are equal * * @return nonzero * addresses are different or some error happened (for further information * see documentation of file @c errors.h). */ extern int rcvrcmp(struct sockaddr *r1, struct sockaddr *r2); /** Copy socket address. * This function copies socket address pointed by source_rcvr parameter into the * place pointed by dest_rcvr parameter. * * @param source_rcvr * the pointer to the place where the source socket address is stored. * * @param dest_rcvr * the pointer to the place where the source socket address will be * copied to. * * @return zero * success * * @return nonzero * related error code if something failed (for further information see * documentation of file @c errors.h). */ extern int rcvrcpy(struct sockaddr *dest_rcvr, struct sockaddr *source_rcvr); /** Find out the size of the socket address. * This function finds out the size occupied by given socket address. * * @param rcvr * the pointer to the place where the socket address information is * stored. * * @param rcvr_len * the pointer to the place where the size of given socket address will * be stored. * * @return below zero * related error code if something failed (for further information see * documentation of file @c errors.h). * * @return above zero * the size occupied by given socket address. */ extern int rcvrsz(struct sockaddr *rcvr); #endif /* vim: set ts=4 : */