mobileprovider

package
v0.0.0-...-17244d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

README

mobile-broadband-provider-info XML 配置解析库, 默认配置文件是 /usr/share/mobile-broadband-provider-info/serviceproviders.xml, 可以提 供各国家和地区的移动运营商信息(GSM/CDMA).

Documentation

Index

Constants

View Source
const (
	PlanTypeValuePrepaid  = "prepaid"
	PlanTypeValuePostpaid = "postpaid"
)
View Source
const (
	UsageTypeInternet = "internet"
	UsageTypeMMS      = "mms"
	UsageTypeWAP      = "wap"
)

Variables

This section is empty.

Functions

func GetAPNName

func GetAPNName(apn *APN) (name string)

GetAPNName return apn's default name, if not exist, return empty string.

func GetAPNUsageType

func GetAPNUsageType(apn *APN) (usageType string)

GetAPNUsageType return apn's usage type, if not exist, return empty string.

func GetAllCountryCode

func GetAllCountryCode() (codeList []string, err error)

GetAllCountryCode return all country code that provide mobile service.

func GetDefaultProvider

func GetDefaultProvider(countryCode string) (defaultProvider string, err error)

GetDefaultProvider return the default provider in target country, usually is the first provider.

func GetProviderNames

func GetProviderNames(countryCode string) (names []string, err error)

GetProviderNames return all provider names in target country.

func MarshalPlan

func MarshalPlan(plan Plan) (jsonStr string)

Types

type APN

type APN struct {
	Value    string     `xml:"value,attr"`
	Plan     []*APNPlan `xml:"plan"`
	Usage    *Usage     `xml:"usage"`
	Name     []*Name    `xml:"name"`
	Gateway  string     `xml:"gateway"`
	Username string     `xml:"username"`
	Password string     `xml:"password"`
	DNS      []string   `xml:"dns"`
	MMSC     string     `xml:"mmsc"`
	MMSproxy string     `xml:"mmsproxy"`
}

func GetAPN

func GetAPN(countryCode, providerName, apnValue, apnUsageType string) (apn *APN, err error)

GetAPN return the apn information that match the provided country code, provider name and apn value.

type APNPlan

type APNPlan struct {
	Type string `xml:"type,attr"`
}

type BalanceCheck

type BalanceCheck struct {
	USSD         []*USSD  `xml:"ussd"`
	DTMF         []string `xml:"dtmf"`
	SMS          []*SMS   `xml:"sms"`
	USSDResponse []string `xml:"ussd-response"`
}

type BalanceTopUp

type BalanceTopUp struct {
	USSD []*USSD `xml:"ussd"`
	SMS  []*SMS  `xml:"sms"`
}

type CDMA

type CDMA struct {
	Name     []*Name  `xml:"name"`
	Username string   `xml:"username"`
	Password string   `xml:"password"`
	DNS      []string `xml:"dns"`
	SID      []*SID   `xml:"sid"`
}

func GetCDMA

func GetCDMA(countryCode, providerName string) (cdma *CDMA, err error)

GetCDMA return the cdma information that match the provided country code and provider name.

type Country

type Country struct {
	Code      string      `xml:"code,attr"`
	Providers []*Provider `xml:"provider"`
}

type GSM

type GSM struct {
	NetworkID    []*NetworkID    `xml:"network-id"`
	MsisdnQuery  []*MsisdnQuery  `xml:"msisdn-query"`
	Voicemail    []string        `xml:"voicemail"`
	BalanceCheck []*BalanceCheck `xml:"balance-check"`
	BalanceTopUp []*BalanceTopUp `xml:"balance-top-up"`
	APN          []*APN          `xml:"apn"`
}

func GetGSM

func GetGSM(countryCode, providerName string) (gsm *GSM, err error)

GetGSM return the gsm information that matched the provided country code and provider name.

func GetGSMForNetworkID

func GetGSMForNetworkID(mcc, mnc string) (gsm *GSM, err error)

GetGSMForNetworkID return the gsm information that match the mcc and mnc.

type MobileServiceProviderDatabase

type MobileServiceProviderDatabase struct {
	Format    string     `xml:"format,attr"`
	Countries []*Country `xml:"country"`
}

func GetMobileProviderDatabase

func GetMobileProviderDatabase() (*MobileServiceProviderDatabase, error)

GetMobileProviderDatabase return mobile service provider's database that marshaled from serviceproviders.xml.

type MsisdnQuery

type MsisdnQuery struct {
	USSD []*USSD `xml:"ussd"`
	SMS  []*SMS  `xml:"sms"`
}

type Name

type Name struct {
	XMLLang string `xml:"xml:lang,attr"`
	Body    string `xml:",chardata"`
}

type NetworkID

type NetworkID struct {
	MCC string `xml:"mcc,attr"`
	MNC string `xml:"mnc,attr"`
}

type Plan

type Plan struct {
	IsGSM        bool
	Name         string // apn names for gsm or provider name for cdma
	ProviderName string
	APNValue     string
	APNUsageType string
}

Plan defines the unique information for each plan(gsm or cdma) in provider.

func GetDefaultCDMAPlanForCountry

func GetDefaultCDMAPlanForCountry(countryCode string) (defaultCDMAPlan Plan, err error)

GetDefaultCDMAPlanForCountry return default gsm plan in target country.

func GetDefaultGSMPlanForCountry

func GetDefaultGSMPlanForCountry(countryCode string) (defaultGSMPlan Plan, err error)

GetDefaultGSMPlanForCountry return default gsm plan in target country.

func GetDefaultPlan

func GetDefaultPlan(countryCode, providerName string) (defaultPlan Plan, err error)

GetDefaultPlan return default plan for taget provider, usually is the first plan.

func GetPlans

func GetPlans(countryCode, providerName string) (plans []Plan, err error)

GetPlans return all plans(apn names for gsm and provider name for cdma) under target provider.

func UnmarshalPlan

func UnmarshalPlan(jsonStr string) (plan *Plan, err error)

type Provider

type Provider struct {
	Primary ProviderPrimaryValue `xml:"primary,attr"`
	Name    *Name                `xml:"name"`
	GSM     *GSM                 `xml:"gsm"`
	CDMA    *CDMA                `xml:"cdma"`
}

func GetProvider

func GetProvider(countryCode, providerName string) (provider *Provider, err error)

GetProvider return the provider information that matched the provided country code and provider name.

func GetProviders

func GetProviders(countryCode string) (providers []*Provider, err error)

GetProviders return all providers in target country.

type ProviderPrimaryValue

type ProviderPrimaryValue string
const (
	ProviderPrimaryValueTrue  ProviderPrimaryValue = "true"
	ProviderPrimaryValueFalse ProviderPrimaryValue = "false"
)

type SID

type SID struct {
	Value string `xml:"value,attr"`
}

type SMS

type SMS struct {
	Text string `xml:"text,attr"`
	Body string `xml:",chardata"`
}

type USSD

type USSD struct {
	Replacement string `xml:"replacement,attr"`
	Body        string `xml:",chardata"`
}

type Usage

type Usage struct {
	Type string `xml:"type,attr"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL