gprs-context.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. *
  3. * oFono - Open Source Telephony
  4. *
  5. * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #ifndef __OFONO_GPRS_CONTEXT_H
  22. #define __OFONO_GPRS_CONTEXT_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. #include <ofono/types.h>
  27. struct ofono_gprs_context;
  28. #define OFONO_GPRS_MAX_APN_LENGTH 127
  29. #define OFONO_GPRS_MAX_USERNAME_LENGTH 63
  30. #define OFONO_GPRS_MAX_PASSWORD_LENGTH 255
  31. enum ofono_gprs_proto {
  32. OFONO_GPRS_PROTO_IP = 0,
  33. OFONO_GPRS_PROTO_IPV6,
  34. OFONO_GPRS_PROTO_IPV4V6,
  35. };
  36. enum ofono_gprs_context_type {
  37. OFONO_GPRS_CONTEXT_TYPE_ANY = 0,
  38. OFONO_GPRS_CONTEXT_TYPE_INTERNET,
  39. OFONO_GPRS_CONTEXT_TYPE_MMS,
  40. OFONO_GPRS_CONTEXT_TYPE_WAP,
  41. OFONO_GPRS_CONTEXT_TYPE_IMS,
  42. };
  43. enum ofono_gprs_auth_method {
  44. OFONO_GPRS_AUTH_METHOD_CHAP = 0,
  45. OFONO_GPRS_AUTH_METHOD_PAP,
  46. };
  47. struct ofono_gprs_primary_context {
  48. unsigned int cid;
  49. int direction;
  50. char apn[OFONO_GPRS_MAX_APN_LENGTH + 1];
  51. char username[OFONO_GPRS_MAX_USERNAME_LENGTH + 1];
  52. char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
  53. enum ofono_gprs_proto proto;
  54. enum ofono_gprs_auth_method auth_method;
  55. };
  56. typedef void (*ofono_gprs_context_cb_t)(const struct ofono_error *error,
  57. void *data);
  58. struct ofono_gprs_context_driver {
  59. const char *name;
  60. int (*probe)(struct ofono_gprs_context *gc, unsigned int vendor,
  61. void *data);
  62. void (*remove)(struct ofono_gprs_context *gc);
  63. void (*activate_primary)(struct ofono_gprs_context *gc,
  64. const struct ofono_gprs_primary_context *ctx,
  65. ofono_gprs_context_cb_t cb, void *data);
  66. void (*deactivate_primary)(struct ofono_gprs_context *gc,
  67. unsigned int id,
  68. ofono_gprs_context_cb_t cb, void *data);
  69. void (*detach_shutdown)(struct ofono_gprs_context *gc,
  70. unsigned int id);
  71. void (*read_settings)(struct ofono_gprs_context *gc,
  72. unsigned int cid,
  73. ofono_gprs_context_cb_t cb, void *data);
  74. };
  75. void ofono_gprs_context_deactivated(struct ofono_gprs_context *gc,
  76. unsigned int id);
  77. int ofono_gprs_context_driver_register(
  78. const struct ofono_gprs_context_driver *d);
  79. void ofono_gprs_context_driver_unregister(
  80. const struct ofono_gprs_context_driver *d);
  81. struct ofono_gprs_context *ofono_gprs_context_create(struct ofono_modem *modem,
  82. unsigned int vendor,
  83. const char *driver, void *data);
  84. void ofono_gprs_context_remove(struct ofono_gprs_context *gc);
  85. void ofono_gprs_context_set_data(struct ofono_gprs_context *gc, void *data);
  86. void *ofono_gprs_context_get_data(struct ofono_gprs_context *gc);
  87. struct ofono_modem *ofono_gprs_context_get_modem(struct ofono_gprs_context *gc);
  88. void ofono_gprs_context_set_type(struct ofono_gprs_context *gc,
  89. enum ofono_gprs_context_type type);
  90. enum ofono_gprs_context_type ofono_gprs_context_get_type(
  91. struct ofono_gprs_context *gc);
  92. void ofono_gprs_context_set_interface(struct ofono_gprs_context *gc,
  93. const char *interface);
  94. void ofono_gprs_context_set_ipv4_address(struct ofono_gprs_context *gc,
  95. const char *address,
  96. ofono_bool_t static_ip);
  97. void ofono_gprs_context_set_ipv4_netmask(struct ofono_gprs_context *gc,
  98. const char *netmask);
  99. void ofono_gprs_context_set_ipv4_gateway(struct ofono_gprs_context *gc,
  100. const char *gateway);
  101. void ofono_gprs_context_set_ipv4_dns_servers(struct ofono_gprs_context *gc,
  102. const char **dns);
  103. void ofono_gprs_context_set_ipv6_address(struct ofono_gprs_context *gc,
  104. const char *address);
  105. void ofono_gprs_context_set_ipv6_prefix_length(struct ofono_gprs_context *gc,
  106. unsigned char length);
  107. void ofono_gprs_context_set_ipv6_gateway(struct ofono_gprs_context *gc,
  108. const char *gateway);
  109. void ofono_gprs_context_set_ipv6_dns_servers(struct ofono_gprs_context *gc,
  110. const char **dns);
  111. #ifdef __cplusplus
  112. }
  113. #endif
  114. #endif /* __OFONO_GPRS_CONTEXT_H */