RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src / router / udpxy / ifaddr.h
blob34831ecdfcc592f11337d18660ce4d1140824f7c
1 /* @(#) definition of packet-io functions for udpxy
3 * Copyright 2008-2011 Pavel V. Cherenkov (pcherenkov@gmail.com)
5 * This file is part of udpxy.
7 * udpxy is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * udpxy is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with udpxy. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef IFADDR_UDPXY_0102081930
22 #define IFADDR_UDPXY_0102081930
24 #include <sys/types.h>
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
30 struct sockaddr;
32 /* retrieve IPv4 address of the given network interface
34 * @param ifname name of the network interface
35 * @param addr pointer to socket address structure
36 * @param addrlen socket structure size
38 * @return 0 if success, -1 otherwise
40 int
41 if2addr( const char* ifname,
42 struct sockaddr *addr, size_t addrlen );
45 /* convert input parameter into an IPv4-address string
47 * @param s input text string
48 * @param buf buffer for the destination string
49 * @param len size of the string buffer
51 * @return 0 if success, -1 otherwise
53 int
54 get_ipv4_address( const char* s, char* buf, size_t len );
57 /* split input string into IP address and port
59 * @param s input text string
60 * @param addr IP address (string) destination buffer
61 * @param len buffer length
62 * @param port address of port variable
64 * @return 0 in success, !=0 otherwise
66 int
67 get_addrport( const char* s, char* addr, size_t len, int* port );
70 #ifdef __cplusplus
72 #endif
74 #endif /* IFADDR_UDPXY_0102081930 */
76 /* __EOF__ */