IPSecCtx.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* ----------------------------------------------------------------------------
  2. * This file was automatically generated by SWIG (http://www.swig.org).
  3. * Version 2.0.9
  4. *
  5. * Do not make changes to this file unless you know what you are doing--modify
  6. * the SWIG interface file instead.
  7. * ----------------------------------------------------------------------------- */
  8. namespace org.doubango.ipsecWRAP {
  9. using System;
  10. using System.Runtime.InteropServices;
  11. public class IPSecCtx : IDisposable {
  12. private HandleRef swigCPtr;
  13. protected bool swigCMemOwn;
  14. internal IPSecCtx(IntPtr cPtr, bool cMemoryOwn) {
  15. swigCMemOwn = cMemoryOwn;
  16. swigCPtr = new HandleRef(this, cPtr);
  17. }
  18. internal static HandleRef getCPtr(IPSecCtx obj) {
  19. return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  20. }
  21. ~IPSecCtx() {
  22. Dispose();
  23. }
  24. public virtual void Dispose() {
  25. lock(this) {
  26. if (swigCPtr.Handle != IntPtr.Zero) {
  27. if (swigCMemOwn) {
  28. swigCMemOwn = false;
  29. ipsec_libPINVOKE.delete_IPSecCtx(swigCPtr);
  30. }
  31. swigCPtr = new HandleRef(null, IntPtr.Zero);
  32. }
  33. GC.SuppressFinalize(this);
  34. }
  35. }
  36. public IPSecCtx(tipsec_ipproto_t ipproto, bool use_ipv6, tipsec_mode_t mode, tipsec_ealg_t ealg, tipsec_alg_t alg, tipsec_proto_t protocol) : this(ipsec_libPINVOKE.new_IPSecCtx((int)ipproto, use_ipv6, (int)mode, (int)ealg, (int)alg, (int)protocol), true) {
  37. }
  38. public tipsec_error_t start() {
  39. tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_start(swigCPtr);
  40. return ret;
  41. }
  42. public tipsec_error_t setLocal(string addr_local, string addr_remote, ushort port_uc, ushort port_us) {
  43. tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_setLocal(swigCPtr, addr_local, addr_remote, port_uc, port_us);
  44. return ret;
  45. }
  46. public tipsec_error_t setKeys(IntPtr ik, IntPtr ck) {
  47. tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_setKeys(swigCPtr, ik, ck);
  48. return ret;
  49. }
  50. public tipsec_error_t setRemote(uint spi_pc, uint spi_ps, ushort port_pc, ushort port_ps, ulong lifetime) {
  51. tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_setRemote(swigCPtr, spi_pc, spi_ps, port_pc, port_ps, lifetime);
  52. return ret;
  53. }
  54. public tipsec_error_t stop() {
  55. tipsec_error_t ret = (tipsec_error_t)ipsec_libPINVOKE.IPSecCtx_stop(swigCPtr);
  56. return ret;
  57. }
  58. public uint getSpiUC() {
  59. uint ret = ipsec_libPINVOKE.IPSecCtx_getSpiUC(swigCPtr);
  60. return ret;
  61. }
  62. public uint getSpiUS() {
  63. uint ret = ipsec_libPINVOKE.IPSecCtx_getSpiUS(swigCPtr);
  64. return ret;
  65. }
  66. public uint getSpiPC() {
  67. uint ret = ipsec_libPINVOKE.IPSecCtx_getSpiPC(swigCPtr);
  68. return ret;
  69. }
  70. public uint getSpiPS() {
  71. uint ret = ipsec_libPINVOKE.IPSecCtx_getSpiPS(swigCPtr);
  72. return ret;
  73. }
  74. }
  75. }