aboutsummaryrefslogtreecommitdiff
path: root/src/mm-modem-helpers.h
blob: 444426584ec6f9e0ff40db6bc2e492ab7a8a7d24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details:
 *
 * Copyright (C) 2008 - 2009 Novell, Inc.
 * Copyright (C) 2009 - 2010 Red Hat, Inc.
 */

#ifndef MM_MODEM_HELPERS_H
#define MM_MODEM_HELPERS_H

#include <ModemManager.h>

#include "mm-modem-cdma.h"
#include "mm-charsets.h"

#define MM_MODEM_CAPABILITY_3GPP_LTE    \
    (MM_MODEM_CAPABILITY_LTE |          \
     MM_MODEM_CAPABILITY_LTE_ADVANCED)

#define MM_MODEM_CAPABILITY_3GPP        \
    (MM_MODEM_CAPABILITY_GSM_UMTS |     \
     MM_MODEM_CAPABILITY_3GPP_LTE)

/* Network scan results expected */
typedef struct {
    MMModem3gppNetworkAvailability status;
    gchar *operator_long;
    gchar *operator_short;
    gchar *operator_code; /* mandatory */
    MMModemAccessTechnology access_tech;
} MM3gppNetworkInfo;

void mm_3gpp_network_info_list_free (GList *info_list);
GList *mm_3gpp_parse_scan_response (const gchar *reply,
                                    GError **error);

/* PDP context query results */
typedef struct {
    guint cid;
    gchar *pdp_type;
    gchar *apn;
} MM3gppPdpContext;

void mm_3gpp_pdp_context_list_free (GList *pdp_list);
GList *mm_3gpp_parse_pdp_query_response (const gchar *reply,
                                         GError **error);

GPtrArray *mm_3gpp_creg_regex_get (gboolean solicited);
void mm_3gpp_creg_regex_destroy (GPtrArray *array);
gboolean mm_3gpp_parse_creg_response (GMatchInfo *info,
                                      MMModem3gppRegistrationState *out_reg_state,
                                      gulong *out_lac,
                                      gulong *out_ci,
                                      MMModemAccessTechnology *out_act,
                                      gboolean *out_cgreg,
                                      GError **error);

GRegex *mm_3gpp_ciev_regex_get (void);

GRegex *mm_3gpp_cusd_regex_get (void);

const char *mm_strip_tag (const char *str, const char *cmd);

gboolean mm_cdma_parse_spservice_response (const char *reply,
                                           MMModemCdmaRegistrationState *out_cdma_1x_state,
                                           MMModemCdmaRegistrationState *out_evdo_state);

gboolean mm_cdma_parse_eri (const char *reply,
                            gboolean *out_roaming,
                            guint32 *out_ind,
                            const char **out_desc);

MMModemCdmaRmProtocol mm_cdma_get_rm_protocol_from_index (guint index,
                                                          GError **error);
guint mm_cdma_get_index_from_rm_protocol (MMModemCdmaRmProtocol protocol,
                                          GError **error);

gboolean mm_cdma_parse_crm_range_response (const gchar *reply,
                                           MMModemCdmaRmProtocol *min,
                                           MMModemCdmaRmProtocol *max,
                                           GError **error);

gboolean mm_gsm_parse_cscs_support_response (const char *reply,
                                             MMModemCharset *out_charsets);

gboolean mm_gsm_parse_clck_test_response (const char *reply,
                                          MMModemGsmFacility *out_facilities);
gboolean mm_gsm_parse_clck_response (const char *reply,
                                     gboolean *enabled);

gchar *mm_3gpp_parse_operator (const gchar *reply,
                               MMModemCharset cur_charset);

char *mm_gsm_get_facility_name (MMModemGsmFacility facility);

MMModemGsmAccessTech mm_gsm_string_to_access_tech (const char *string);

char *mm_create_device_identifier (guint vid,
                                   guint pid,
                                   const char *ati,
                                   const char *ati1,
                                   const char *gsn,
                                   const char *revision,
                                   const char *model,
                                   const char *manf);

typedef struct CindResponse CindResponse;
GHashTable *mm_parse_cind_test_response (const char *reply, GError **error);
const char *cind_response_get_desc      (CindResponse *r);
guint       cind_response_get_index     (CindResponse *r);
gint        cind_response_get_min       (CindResponse *r);
gint        cind_response_get_max       (CindResponse *r);

GByteArray *mm_parse_cind_query_response(const char *reply, GError **error);

#define MM_MODEM_CDMA_SID_UNKNOWN 99999
#define MM_MODEM_CDMA_NID_UNKNOWN 99999

gint  mm_cdma_normalize_class (const gchar *orig_class);
gchar mm_cdma_normalize_band  (const gchar *long_band,
                               gint *out_class);
gint  mm_cdma_convert_sid     (const gchar *sid);

guint mm_count_bits_set (gulong number);

#endif  /* MM_MODEM_HELPERS_H */