blob: 266a785a3cbdfcdec366543fd81135a49927963b [file] [log] [blame]
Benny Prijonob681a2f2007-03-25 18:44:51 +00001/* $Id$ */
2/*
3 * Copyright (C)2003-2007 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJ_IP_ROUTE_H__
20#define __PJ_IP_ROUTE_H__
21
22/**
23 * @file ip_helper.h
24 * @brief IP helper API
25 */
26
27#include <pj/sock.h>
28
29PJ_BEGIN_DECL
30
31/**
32 * @defgroup pj_ip_helper IP Interface and Routing Helper
33 * @ingroup PJ_IO
34 * @{
35 *
36 * This module provides functions to query local host's IP interface and
37 * routing table.
38 */
39
40/**
41 * This structure describes IP routing entry.
42 */
43typedef union pj_ip_route_entry
44{
45 /** IP routing entry for IP version 4 routing */
46 struct
47 {
48 pj_in_addr if_addr; /**< Local interface IP address. */
49 pj_in_addr dst_addr; /**< Destination IP address. */
50 pj_in_addr mask; /**< Destination mask. */
51 } ipv4;
52} pj_ip_route_entry;
53
54
55/**
Benny Prijono62b86eb2007-12-01 08:52:57 +000056 * Enumerate the local IP interfaces currently active in the host.
Benny Prijonob681a2f2007-03-25 18:44:51 +000057 *
Benny Prijono62b86eb2007-12-01 08:52:57 +000058 * @param af Family of the address to be retrieved. Application
59 * may specify pj_AF_UNSPEC() to retrieve all addresses,
60 * or pj_AF_INET() or pj_AF_INET6() to retrieve interfaces
61 * with specific address family.
Benny Prijonob681a2f2007-03-25 18:44:51 +000062 * @param count On input, specify the number of entries. On output,
63 * it will be filled with the actual number of entries.
Benny Prijono62b86eb2007-12-01 08:52:57 +000064 * @param ifs Array of socket addresses, which address part will
65 * be filled with the interface address. The address
66 * family part will be initialized with the address
67 * family of the IP address.
Benny Prijonob681a2f2007-03-25 18:44:51 +000068 *
69 * @return PJ_SUCCESS on success, or the appropriate error code.
70 */
Benny Prijono62b86eb2007-12-01 08:52:57 +000071PJ_DECL(pj_status_t) pj_enum_ip_interface(int af,
72 unsigned *count,
73 pj_sockaddr ifs[]);
Benny Prijonob681a2f2007-03-25 18:44:51 +000074
75
76/**
77 * Enumerate the IP routing table for this host.
78 *
79 * @param count On input, specify the number of routes entries. On output,
80 * it will be filled with the actual number of route entries.
81 * @param routes Array of IP routing entries.
82 *
83 * @return PJ_SUCCESS on success, or the appropriate error code.
84 */
85PJ_DECL(pj_status_t) pj_enum_ip_route(unsigned *count,
86 pj_ip_route_entry routes[]);
87
88
89
90/** @} */
91
92PJ_END_DECL
93
94
95#endif /* __PJ_IP_ROUTE_H__ */
96