pfd_nat.h

Go to the documentation of this file.
00001 /*
00002  * $Id: pfd_nat.h 346460 2009-11-14 05:06:47Z ssiano $
00003  *
00004  * This code is provided as is by Juniper Networks SDK Developer Support.
00005  * It is provided with no warranties or guarantees, and Juniper Networks
00006  * will not provide support or maintenance of this code in any fashion.
00007  * The code is provided only to help a developer better understand how
00008  * the SDK can be used.
00009  *
00010  * Copyright (c) 2007-2008, Juniper Networks, Inc.
00011  * All rights reserved.
00012  */
00013 
00023 #ifndef __PFD_NAT_H__
00024 #define __PFD_NAT_H__
00025 
00026 #include <netinet/in_systm.h>
00027 #include <netinet/in.h>
00028 #include <netinet/ip.h>
00029 #include <pthread.h>
00030 #include <errno.h>
00031 
00032 /*** Constants ***/
00033 
00037 #define LOCK_MUTEX(lock) \
00038 {   \
00039     int _rc = pthread_mutex_lock((lock)); \
00040     if(_rc == EINVAL) { \
00041         LOG(LOG_EMERG, "%s:%s:%d: pthread_mutex_lock failed with EINVAL " \
00042          "(Mutex %s is invalid)", __FILE__, __func__, __LINE__, #lock); \
00043     } else if(_rc == EDEADLK) { \
00044         LOG(LOG_EMERG, "%s:%s:%d: pthread_mutex_lock failed with EDEADLK " \
00045          "(Deadlocked on mutex %s)", __FILE__, __func__, __LINE__, #lock); \
00046     } else if(_rc) { \
00047         LOG(LOG_EMERG, "%s:%s:%d: pthread_mutex_lock failed with return code " \
00048          "%d (Mutex %s)", __FILE__, __func__, __LINE__, _rc, #lock); \
00049     } \
00050 }
00051 
00052 
00056 #define UNLOCK_MUTEX(lock) \
00057 {   \
00058     int _rc = pthread_mutex_unlock((lock)); \
00059     if(_rc) { \
00060         LOG(LOG_EMERG, "%s:%s:%d: pthread_mutex_unlock failed. Return code " \
00061             "%d (Mutex %s)", __FILE__, __func__, __LINE__, _rc, #lock); \
00062     } \
00063 }
00064 
00065 /*** Data structures ***/
00066 
00070 typedef struct address_bundle_s {
00071     in_addr_t pfd_addr; 
00072     in_addr_t cpd_addr; 
00073 } address_bundle_t;
00074 
00075 
00076 /*** GLOBAL/EXTERNAL Functions ***/
00077 
00078 
00082 void init_nat(void);
00083 
00084 
00088 void terminate_nat(void);
00089 
00090 
00105 boolean nat_packet(struct ip * ip_pkt, address_bundle_t * addresses);
00106 
00120 boolean reverse_nat_packet(struct ip * ip_pkt);
00121 
00122 
00134 void nat_fragment(struct ip * ip_pkt, address_bundle_t * addresses);
00135 
00136 
00137 #endif
00138 

2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:27:07 2010 for SDK Your Net Corporation Policy Manager Example: Packet Filtering Daemon (pfd) 1.0 by Doxygen 1.5.1