| 1 | /* |
| 2 | * Copyright (C) 2004-2005 by Objective Systems, Inc. |
| 3 | * |
| 4 | * This software is furnished under an open source license and may be |
| 5 | * used and copied only in accordance with the terms of this license. |
| 6 | * The text of the license may generally be found in the root |
| 7 | * directory of this installation in the COPYING file. It |
| 8 | * can also be viewed online at the following URL: |
| 9 | * |
| 10 | * http://www.obj-sys.com/open/license.html |
| 11 | * |
| 12 | * Any redistributions of this file including modified versions must |
| 13 | * maintain this copyright notice. |
| 14 | * |
| 15 | *****************************************************************************/ |
| 16 | |
| 17 | /** |
| 18 | * @file ooports.h |
| 19 | * This file contains functions to manage ports used by the stack. |
| 20 | */ |
| 21 | |
| 22 | #ifndef _OOPORTS_H_ |
| 23 | #define _OOPORTS_H_ |
| 24 | |
| 25 | #include "ootypes.h" |
| 26 | |
| 27 | typedef enum OOH323PortType { |
| 28 | OOTCP, OOUDP, OORTP |
| 29 | } OOH323PortType; |
| 30 | |
| 31 | |
| 32 | #ifdef __cplusplus |
| 33 | extern "C" { |
| 34 | #endif |
| 35 | |
| 36 | #ifndef EXTERN |
| 37 | #ifdef MAKE_DLL |
| 38 | #define EXTERN __declspec(dllexport) |
| 39 | #else |
| 40 | #define EXTERN |
| 41 | #endif /* MAKE_DLL */ |
| 42 | #endif /* EXTERN */ |
| 43 | |
| 44 | /** |
| 45 | * Get the next port of type TCP/UDP/RTP from the corresponding range. |
| 46 | * When max value for the range is reached, it starts again from the |
| 47 | * first port number of the range. |
| 48 | * |
| 49 | * @param ep Reference to the H323 Endpoint structure. |
| 50 | * @param type Type of the port to be retrieved(OOTCP/OOUDP/OORTP). |
| 51 | * |
| 52 | * @return The next port number for the specified type is returned. |
| 53 | */ |
| 54 | EXTERN int ooGetNextPort (OOH323PortType type); |
| 55 | |
| 56 | /** |
| 57 | * Bind socket to a port within the port range specified by the |
| 58 | * application at the startup. |
| 59 | * |
| 60 | * @param ep Reference to H323 Endpoint structure. |
| 61 | * @param type Type of the port required for the socket. |
| 62 | * @param socket The socket to be bound. |
| 63 | * @param ip Dotted Ip address to bind to. |
| 64 | * |
| 65 | * @return In case of success returns the port number to which |
| 66 | * socket is bound and in case of failure just returns |
| 67 | * a negative value. |
| 68 | */ |
| 69 | EXTERN int ooBindPort (OOH323PortType type, OOSOCKET socket, char *ip); |
| 70 | |
| 71 | /** |
| 72 | * This function is supported for windows version only. |
| 73 | * Windows sockets have problem in reusing the addresses even after |
| 74 | * setting SO_REUSEADDR, hence in windows we just allow os to bind |
| 75 | * to any random port. |
| 76 | * @param socket Socket to be bound. |
| 77 | * @param ip Dotted ip address to bind to. |
| 78 | * |
| 79 | * @return In case of success returns the port number to which |
| 80 | * socket is bound and in case of failure just returns |
| 81 | * a negative value. |
| 82 | */ |
| 83 | #ifdef _WIN32 |
| 84 | EXTERN int ooBindOSAllocatedPort(OOSOCKET socket, char *ip); |
| 85 | #endif |
| 86 | |
| 87 | #ifdef __cplusplus |
| 88 | } |
| 89 | #endif |
| 90 | |
| 91 | #endif |