PageRenderTime 43ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/servers/jain-slee/resources/diameter-s6a/events/src/main/java/net/java/slee/resource/diameter/s6a/events/avp/PDNType.java

http://mobicents.googlecode.com/
Java | 113 lines | 50 code | 11 blank | 52 comment | 2 complexity | e418db64c5498078f6d7503a9ec3f6f8 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package net.java.slee.resource.diameter.s6a.events.avp;
  23. import java.io.Serializable;
  24. import net.java.slee.resource.diameter.base.events.avp.Enumerated;
  25. /**
  26. * Java class representing the PDN-Type enumerated type.
  27. * From the Diameter S6a Reference Point Protocol Details (3GPP TS 29.272 V9.6.0) specification:
  28. *
  29. * <pre>
  30. * 7.3.62 PDN-Type
  31. *
  32. * The PDN-Type AVP is of type Enumerated and indicates the address type of PDN. The following values are defined:
  33. * IPv4 (0)
  34. * This value shall be used to indicate that the PDN can be accessed only in IPv4 mode.
  35. *
  36. * IPv6 (1)
  37. * This value shall be used to indicate that the PDN can be accessed only in IPv6 mode.
  38. *
  39. * IPv4v6 (2)
  40. * This value shall be used to indicate that the PDN can be accessed both in IPv4 mode, in IPv6
  41. * mode, and also from UEs supporting dualstack IPv4v6.
  42. *
  43. * IPv4_OR_IPv6 (3)
  44. * This value shall be used to indicate that the PDN can be accessed either in IPv4 mode, or in
  45. * IPv6 mode, but not from UEs supporting dualstack IPv4v6. It should be noted that this value
  46. * will never be used as a requested PDN Type from the UE, since UEs will only use one of their
  47. * supported PDN Types, i.e., IPv4 only, IPv6 only or IPv4v6 (dualstack). This value is only used
  48. * as part of the APN subscription context, as an authorization mechanism between HSS and MME.
  49. * </pre>
  50. *
  51. * @author <a href="mailto:brainslog@gmail.com"> Alexandre Mendonca </a>
  52. * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a>
  53. * @author <a href="mailto:richard.good@smilecoms.com"> Richard Good </a>
  54. * @author <a href="mailto:paul.carter-brown@smilecoms.com"> Paul Carter-Brown </a>
  55. */
  56. public class PDNType implements Enumerated, Serializable {
  57. private static final long serialVersionUID = 1L;
  58. public static final int _IPv4 = 0;
  59. public static final int _IPv6 = 1;
  60. public static final int _IPv4v6 = 2;
  61. public static final int _IPv4_OR_IPv6 = 3;
  62. public static final PDNType IPv4 = new PDNType(_IPv4);
  63. public static final PDNType IPv6 = new PDNType(_IPv6);
  64. public static final PDNType IPv4v6 = new PDNType(_IPv4v6);
  65. public static final PDNType IPv4_OR_IPv6 = new PDNType(_IPv4_OR_IPv6);
  66. private int value = -1;
  67. private PDNType(int value) {
  68. this.value = value;
  69. }
  70. public static PDNType fromInt(int type) {
  71. switch (type) {
  72. case _IPv4:
  73. return IPv4;
  74. case _IPv6:
  75. return IPv6;
  76. case _IPv4v6:
  77. return IPv4v6;
  78. case _IPv4_OR_IPv6:
  79. return IPv4_OR_IPv6;
  80. default:
  81. throw new IllegalArgumentException("Invalid value: " + type);
  82. }
  83. }
  84. public int getValue() {
  85. return value;
  86. }
  87. @Override
  88. public String toString() {
  89. switch (value) {
  90. case _IPv4:
  91. return "IPv4";
  92. case _IPv6:
  93. return "IPv6";
  94. case _IPv4v6:
  95. return "IPv4v6";
  96. case _IPv4_OR_IPv6:
  97. return "IPv4_OR_IPv6";
  98. default:
  99. return "<Invalid Value>";
  100. }
  101. }
  102. }