Exemple #1
0
        static void Main(string[] args)
        {
            /* Create the context */
            IPSecCtx ipsecCtx = new IPSecCtx(__ipproto, __use_ipv6, __mode, __ealg, __alg, __proto);

            /* Set local */
            Debug.Assert(ipsecCtx.setLocal(__addr_local, __addr_remote, __port_local_out, __port_local_in) == err.tipsec_error_success);

            /* Dump SPIs created by the OS after calling set_local() */
            Console.WriteLine("SPI-UC={0}, SPI-US={1}", ipsecCtx.getSpiUC(), ipsecCtx.getSpiUS());

            /* Set remote */
            Debug.Assert(ipsecCtx.setRemote(__spi_remote_out, __spi_remote_in, __port_remote_out, __port_remote_in, __lifetime) == err.tipsec_error_success);

            /* Set Integrity (IK) and Confidentiality (CK) keys */
            IntPtr keyIK = Marshal.StringToHGlobalAnsi(__key_ik);
            IntPtr keyCK = Marshal.StringToHGlobalAnsi(__key_ck);
            Debug.Assert(ipsecCtx.setKeys(keyIK, keyCK) == err.tipsec_error_success);
            Marshal.FreeHGlobal(keyIK);
            Marshal.FreeHGlobal(keyCK);

            /* Start (Setup) the SAs */
            Debug.Assert(ipsecCtx.start() == err.tipsec_error_success);

            Console.WriteLine("!!! IPSec SAs started (Press any key to stop) !!!");

            Console.ReadLine();

            ipsecCtx.Dispose(); // Not required. GC will collect it when refCount reach zero.

            Console.ReadLine();
        }
Exemple #2
0
 internal static HandleRef getCPtr(IPSecCtx obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Exemple #3
0
 internal static HandleRef getCPtr(IPSecCtx obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }