blob: b34fc9148d39ef258c3ea3067881f42950152dd3 [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001// Copyright (C) 2004-2008 TintaDigital - STI, LDA.
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation; either version 2 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16//
17// As a special exception to the GNU General Public License, permission is
18// granted for additional uses of the text contained in its release
19// of Common C++.
20//
21// The exception is that, if you link the Common C++ library with other files
22// to produce an executable, this does not by itself cause the
23// resulting executable to be covered by the GNU General Public License.
24// Your use of that executable is in no way restricted on account of
25// linking the Common C++ library code into it.
26//
27// This exception does not however invalidate any other reasons why
28// the executable file might be covered by the GNU General Public License.
29//
30// This exception applies only to the code released under the
31// name Common C++. If you copy code from other releases into a copy of
32// Common C++, as the General Public License permits, the exception does
33// not apply to the code that you add in this way. To avoid misleading
34// anyone as to the status of such modified files, you must delete
35// this exception notice from them.
36//
37// If you write modifications of your own for Common C++, it is your choice
38// whether to permit this exception to apply to your modifications.
39// If you do not wish that, delete this exception notice.
40
41/**
42 * @file nat.h
43 * @short Network Address Translation interface functions.
44 * @author Ricardo Gameiro <rgameiro at tintadigital dot com>
45 **/
46
47#ifndef CCXX_NAT_H
48#define CCXX_NAT_H
49
50#ifdef CCXX_NAMESPACES
51namespace ost {
52#endif
53
54#ifndef WIN32
55typedef int SOCKET;
56#endif
57
58enum natResult {
59 natOK = 0,
60 natSearchErr = 1,
61 natNotSupported = 2,
62 natDevUnavail = 3,
63 natSocknameErr = 4,
64 natPeernameErr = 5,
65 natSockTypeErr = 6,
66 natIFaceErr = 7,
67 natUnkownErr = 8
68};
69
70typedef natResult natResult;
71
72/**
73 * Perform NAT address table lookup for the current socket.
74 *
75 * @param sfd socket to get nat info from.
76 * @param nat sockaddr structure to hold results.
77 */
78natResult natv4Lookup( SOCKET sfd, struct sockaddr_in * nat );
79#ifdef CCXX_IPV6
80natResult natv6Lookup( SOCKET sfd, struct sockaddr_in6 * nat );
81#endif
82
83/**
84 * Return descriptive text for the NAT Lookup return error.
85 *
86 * @param res result from NATLookup function.
87 * @return error description.
88 */
89const char * natErrorString( natResult res );
90
91#ifdef CCXX_NAMESPACES
92}
93#endif
94
95#endif
96