Annotation of libelwix/inc/elwix/anet.h, revision 1.1

1.1     ! misho       1: /*************************************************************************
        !             2: * (C) 2013 AITNET ltd - Sofia/Bulgaria - <misho@aitnet.org>
        !             3: *  by Michael Pounov <misho@elwix.org>
        !             4: *
        !             5: * $Author: misho $
        !             6: * $Id: global.h,v 1.13 2012/08/29 13:51:29 misho Exp $
        !             7: *
        !             8: **************************************************************************
        !             9: The ELWIX and AITNET software is distributed under the following
        !            10: terms:
        !            11: 
        !            12: All of the documentation and software included in the ELWIX and AITNET
        !            13: Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
        !            14: 
        !            15: Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
        !            16:        by Michael Pounov <misho@elwix.org>.  All rights reserved.
        !            17: 
        !            18: Redistribution and use in source and binary forms, with or without
        !            19: modification, are permitted provided that the following conditions
        !            20: are met:
        !            21: 1. Redistributions of source code must retain the above copyright
        !            22:    notice, this list of conditions and the following disclaimer.
        !            23: 2. Redistributions in binary form must reproduce the above copyright
        !            24:    notice, this list of conditions and the following disclaimer in the
        !            25:    documentation and/or other materials provided with the distribution.
        !            26: 3. All advertising materials mentioning features or use of this software
        !            27:    must display the following acknowledgement:
        !            28: This product includes software developed by Michael Pounov <misho@elwix.org>
        !            29: ELWIX - Embedded LightWeight unIX and its contributors.
        !            30: 4. Neither the name of AITNET nor the names of its contributors
        !            31:    may be used to endorse or promote products derived from this software
        !            32:    without specific prior written permission.
        !            33: 
        !            34: THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND
        !            35: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            36: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            37: ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
        !            38: FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            39: DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            40: OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            41: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            42: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            43: OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            44: SUCH DAMAGE.
        !            45: */
        !            46: #ifndef __ANET_H
        !            47: #define __ANET_H
        !            48: 
        !            49: 
        !            50: struct e_ether_addr {
        !            51:        u_int8_t ether_addr_octet[6];
        !            52: };
        !            53: typedef struct e_ether_addr ether_addr_t;
        !            54: 
        !            55: typedef union {
        !            56:        struct sockaddr_storage ss;
        !            57:        struct sockaddr         sa;
        !            58:        struct sockaddr_un      sun;
        !            59:        struct sockaddr_in      sin;
        !            60:        struct sockaddr_in6     sin6;
        !            61:        struct sockaddr_dl      sdl;
        !            62: } sockaddr_t;
        !            63: #define E_SOCKADDR_INIT        { .ss = { 0 } }
        !            64: 
        !            65: 
        !            66: /*
        !            67:  * e_usleep() - usleep() replacement for ELWIX
        !            68:  *
        !            69:  * @usec = microseconds for sleep
        !            70:  * return: -1 interrupted by signal or 0 ok
        !            71:  */
        !            72: inline int e_usleep(unsigned int usec);
        !            73: /*
        !            74:  * e_ether_ntoa() - Convert ethernet address to string
        !            75:  *
        !            76:  * @n = ethernet address structure, like struct ether_addr
        !            77:  * @a = string
        !            78:  * @len = string length
        !            79:  * return: NULL error or !=NULL string a
        !            80:  */
        !            81: inline char *e_ether_ntoa(const struct e_ether_addr *n, char * __restrict a, int len);
        !            82: /*
        !            83:  * e_ether_aton() - Convert string to ethernet address
        !            84:  *
        !            85:  * @a = string
        !            86:  * @e = ethernet address structure, like struct ether_addr
        !            87:  * return: NULL error or !=NULL ethernet address structure
        !            88:  */
        !            89: inline struct e_ether_addr *e_ether_aton(const char *a, struct e_ether_addr *e);
        !            90: /*
        !            91:  * e_n2port() - Extract port from network structure
        !            92:  *
        !            93:  * @addr = Address
        !            94:  * return: 0 not supported family type or port number
        !            95:  */
        !            96: inline unsigned short e_n2port(sockaddr_t * __restrict addr);
        !            97: /*
        !            98:  * e_n2addr() - Extract address from network structure
        !            99:  *
        !           100:  * @addr = Address
        !           101:  * @val = Value for store string address
        !           102:  * return: NULL error or !=NULL string address from val
        !           103:  */
        !           104: const char *e_n2addr(sockaddr_t * __restrict addr, ait_val_t * __restrict val);
        !           105: /*
        !           106:  * e_gethostbyname() - Get host and port and make network structure
        !           107:  *
        !           108:  * @psHost = Hostname
        !           109:  * @port = Port
        !           110:  * @addr = Network address structure
        !           111:  * return: NULL error or !=NULL network structure
        !           112:  */
        !           113: sockaddr_t *e_gethostbyname(const char *psHost, unsigned short port, 
        !           114:                sockaddr_t * __restrict addr);
        !           115: /*
        !           116:  * e_addrcmp() - Compare network addresses
        !           117:  *
        !           118:  * @a = 1st address
        !           119:  * @b = 2nd address
        !           120:  * @p = compare and ports, if family is AF_INET or AF_INET6
        !           121:  * return: 0 is equal or !=0 is different
        !           122:  */
        !           123: int e_addrcmp(sockaddr_t * __restrict a, sockaddr_t * __restrict b, int p);
        !           124: 
        !           125: 
        !           126: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>