common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0, BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Overview

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	Deployed = iota + 1
	PendingDownload
	InDeployment
	Failure
)
View Source
const (
	LoggingTimeFormat = "2006-01-02 15:04:05.000"
	PokeBodyTemplate  = `{"parameters":[{"dataType":0,"name":"Device.X_RDK_WebConfig.ForceSync","value":"%s"}]}`
)
View Source
const (
	HeaderContentType                = "Content-Type"
	HeaderApplicationJson            = "application/json"
	HeaderApplicationMsgpack         = "application/msgpack"
	HeaderEtag                       = "Etag"
	HeaderIfNoneMatch                = "If-None-Match"
	HeaderFirmwareVersion            = "X-System-Firmware-Version"
	HeaderSupportedDocs              = "X-System-Supported-Docs"
	HeaderSupplementaryService       = "X-System-SupplementaryService-Sync"
	HeaderModelName                  = "X-System-Model-Name"
	HeaderProfileVersion             = "X-System-Telemetry-Profile-Version"
	HeaderPartnerID                  = "X-System-PartnerID"
	HeaderAccountID                  = "X-System-AccountID"
	HeaderProductClass               = "X-System-Product-Class"
	HeaderAccountType                = "X-System-Type"
	HeaderUserAgent                  = "User-Agent"
	HeaderSchemaVersion              = "X-System-Schema-Version"
	HeaderMetricsAgent               = "X-Metrics-Agent"
	HeaderStoreUpstreamResponse      = "X-Store-Upstream-Response"
	HeaderSubdocumentVersion         = "X-Subdocument-Version"
	HeaderSubdocumentState           = "X-Subdocument-State"
	HeaderSubdocumentUpdatedTime     = "X-Subdocument-Updated-Time"
	HeaderSubdocumentErrorCode       = "X-Subdocument-Error-Code"
	HeaderSubdocumentErrorDetails    = "X-Subdocument-Error-Details"
	HeaderSubdocumentExpiry          = "X-Subdocument-Expiry"
	HeaderSubdocumentOldState        = "X-Subdocument-Old-State"
	HeaderSubdocumentMetricsAgent    = "X-Subdocument-Metrics-Agent"
	HeaderDeviceId                   = "Device-Id"
	HeaderDocName                    = "Doc-Name"
	HeaderUpstreamNewBitmap          = "X-Upstream-New-Bitmap"
	HeaderUpstreamNewFirmwareVersion = "X-Upstream-New-Firmware-Version"
	HeaderUpstreamNewModelName       = "X-Upstream-New-Model-Name"
	HeaderUpstreamNewPartnerId       = "X-Upstream-New-Partner-Id"
	HeaderUpstreamNewSchemaVersion   = "X-Upstream-New-Schema-Version"
	HeaderUpstreamOldBitmap          = "X-Upstream-Old-Bitmap"
	HeaderUpstreamOldFirmwareVersion = "X-Upstream-Old-Firmware-Version"
	HeaderUpstreamOldModelName       = "X-Upstream-Old-Model-Name"
	HeaderUpstreamOldPartnerId       = "X-Upstream-Old-Partner-Id"
	HeaderUpstreamOldSchemaVersion   = "X-Upstream-Old-Schema-Version"
	HeaderAuthorization              = "Authorization"
	HeaderAuditid                    = "X-Auditid"
	HeaderTransactionId              = "Transaction-Id"
	HeaderReqUrl                     = "X-Req-Url"
	HeaderWanMac                     = "X-System-Wan-Mac"
	HeaderSourceAppName              = "X-Source-App-Name"
	HeaderTraceparent                = "Traceparent"
	HeaderTracestate                 = "Tracestate"
	HeaderContentLength              = "Content-Length"
	HeaderRefSubdocumentVersion      = "X-Refsubdocument-Version"
	HeaderUpstreamResponse           = "X-Upstream-Response"
	HeaderMoneytrace                 = "X-Moneytrace"
	HeaderWebconfigTransactionId     = "X-Webconfig-Transaction-Id"
	HeaderMoracide                   = "X-Cl-Experiment"
	HeaderCanary                     = "X-Cl-Canary"
)
View Source
const (
	RouteMqtt = "mqtt"
	RouteHttp = "http"
)
View Source
const (
	RootDocumentEquals = iota
	RootDocumentVersionOnlyChanged
	RootDocumentMetaChanged
	RootDocumentMissing
)
View Source
const (
	VersionChanged = iota + 1
	BitmapChanged
	VersionAndBitmapChanged
)
View Source
const (
	TR181Str           = 0
	TR181Int           = 1
	TR181Uint          = 2
	TR181Bool          = 3
	TR181Blob          = 12
	TR181NameTelemetry = "Device.X_RDKCENTRAL-COM_T2.ReportProfilesMsgPack"
)
View Source
const (
	TR181NamePrivatessid = "Device.WiFi.Private"
	TR181NameHomessid    = "Device.WiFi.Home"
)
View Source
const (
	Boundary = "2xKIxjfJuErFW+hmNCwEoMoY8I+ECM9efrV6EI4efSSW9QjI"
)
View Source
const (
	SkipDbUpdate = "skip-db-update"
)
View Source
const (
	TimeFormat = "Mon, 02 Jan 2006 15:04:05 GMT"
)

Variables

View Source
var (
	BinaryVersion   = ""
	BinaryBranch    = ""
	BinaryBuildTime = ""
	OpenLibVersion  = ""

	DefaultIgnoredHeaders = []string{
		"Accept",
		"User-Agent",
		"Authorization",
		"Content-Type",
		"Content-Length",
		"Accept-Encoding",
		"X-B3-Sampled",
		"X-B3-Spanid",
		"X-B3-Traceid",
		"X-Envoy-Decorator-Operation",
		"X-Envoy-External-Address",
		"X-Envoy-Peer-Metadata",
		"X-Envoy-Peer-Metadata-Id",
		"X-Forwarded-Proto",
	}
)
View Source
var (
	SupportedPokeDocs   = []string{"primary", "telemetry", "root"}
	SupportedPokeRoutes = []string{"mqtt"}
)
View Source
var (
	CRLFCRLF = []byte("\r\n\r\n")
	CRLF     = []byte("\r\n")
)
View Source
var (
	ErrNotOK              = fmt.Errorf("!ok")
	ErrRootDocumentLocked = fmt.Errorf("root document is locked")
	ErrInvalidQueryParams = fmt.Errorf("invalid query parameters")
	ErrLowTrust           = fmt.Errorf("token trust is lower than threshold")
	ErrPending            = fmt.Errorf("application_status pending")
	ErrNoCapabilities     = NoCapabilitiesError{}
)
View Source
var (
	Http400ErrorType    = &Http400Error{}
	Http404ErrorType    = &Http404Error{}
	Http500ErrorType    = &Http500Error{}
	RemoteHttpErrorType = &RemoteHttpError{}
)
View Source
var (
	MultipartContentType = fmt.Sprintf("multipart/mixed; boundary=%s", Boundary)
)
View Source
var (
	States = [5]string{
		"",
		"deployed",
		"pending download",
		"in deployment",
		"failure",
	}
)
View Source
var (
	SubdocBitIndexMap = map[string]int{
		"portforwarding":          1,
		"lan":                     2,
		"wan":                     3,
		"macbinding":              4,
		"hotspot":                 5,
		"bridge":                  6,
		"privatessid":             7,
		"homessid":                8,
		"radio":                   9,
		"moca":                    10,
		"xdns":                    11,
		"advsecurity":             12,
		"mesh":                    13,
		"aker":                    14,
		"telemetry":               15,
		"statusreport":            16,
		"trafficreport":           17,
		"interfacereport":         18,
		"radioreport":             19,
		"telcovoip":               20,
		"wanmanager":              21,
		"voiceservice":            22,
		"wanfailover":             23,
		"cellularconfig":          24,
		"telcovoice":              25,
		"gwfailover":              26,
		"gwrestore":               27,
		"prioritizedmacs":         28,
		"connectedbuilding":       29,
		"lldqoscontrol":           30,
		"clienttosteeringprofile": 31,
		"defaultrfc":              32,
		"rfc":                     33,
		"wifimotionsettings":      34,
		"xmspeedboost":            35,
		"meshsteeringprofiles":    36,
		"wifistatsconfig":         37,
		"mwoconfigs":              38,
		"interference":            39,
		"webui":                   40,
		"channelplan":             41,
		"hotspotwantolan":         42,
		"ignitewifi":              43,
		"networkintelligence":     44,
	}
)
View Source
var (
	SupportedDocsBitMaskMap = map[int][]BitMaskTuple{
		1: {
			{1, 1},
			{2, 2},
			{3, 3},
			{4, 4},
			{5, 5},
			{6, 6},
			{7, 29},
			{8, 35},
			{9, 40},
		},
		2: {
			{1, 7},
			{2, 8},
			{3, 9},
			{4, 43},
		},
		3: {
			{1, 10},
		},
		4: {
			{1, 11},
		},
		5: {
			{1, 12},
			{2, 44},
		},
		6: {
			{1, 13},
			{2, 31},
			{3, 36},
			{4, 37},
			{5, 38},
			{6, 39},
			{7, 34},
			{8, 41},
		},
		7: {
			{1, 14},
		},
		8: {
			{1, 15},
			{2, 32},
			{3, 33},
		},
		9: {
			{1, 16},
			{2, 17},
		},
		10: {
			{1, 18},
			{2, 19},
		},
		11: {
			{1, 20},
			{2, 25},
		},
		12: {
			{1, 21},
			{2, 23},
			{3, 42},
		},
		13: {
			{1, 22},
		},
		14: {
			{1, 24},
		},
		15: {
			{1, 26},
			{2, 27},
		},
		16: {
			{1, 28},
		},
		17: {
			{1, 30},
		},
	}
)

The group based bitmaps will be merged into 1 cpe bitmap 1: []BitMaskTuple{ // meta_group_id: defined by RDK

BitMaskTuple{1, 1},  // {"index_of_bit_from_lsb" for a group bitmap, "index_of_bit_from_lsb" for the cpe bitmap

Functions

func BitarrayToBitmap added in v1.0.0

func BitarrayToBitmap(src string) (int, error)

func BuildPayloadAsHttp added in v1.0.0

func BuildPayloadAsHttp(status int, header http.Header, rbytes []byte) []byte

func BuildSupportedSubdocMapWithDefaults added in v1.0.0

func BuildSupportedSubdocMapWithDefaults(supportedSubdocIds []string) map[string]bool

func CopyCoreLogFields added in v1.0.0

func CopyCoreLogFields(src log.Fields) log.Fields

func FilterLogFields added in v1.0.0

func FilterLogFields(src log.Fields, excludes ...string) log.Fields

func GetBitmapFromSupportedMap added in v1.0.0

func GetBitmapFromSupportedMap(srcMap map[string]bool) int

func GetCaller added in v1.0.0

func GetCaller(args ...int) string

func GetCpeBitmap added in v1.0.0

func GetCpeBitmap(rdkSupportedDocsHeaderStr string) (int, error)

func GetDefaultSupportedSubdocMap added in v1.0.0

func GetDefaultSupportedSubdocMap() map[string]bool

func GetInt added in v1.0.0

func GetInt(fields log.Fields, key string) int

func GetStateMetricsLine added in v1.0.0

func GetStateMetricsLine(oldState, newState int, fields log.Fields) string

func GetSupportedMap added in v1.0.0

func GetSupportedMap(cpeBitmap int) map[string]bool

func GetTestConfigFile added in v1.0.0

func GetTestConfigFile() (string, error)

func GetUrlPattern added in v1.0.0

func GetUrlPattern(url string) string

func IsPrintable added in v1.0.0

func IsPrintable(bbytes []byte) bool

func IsSubdocSupported added in v1.0.0

func IsSubdocSupported(cpeBitmap int, subdocId string) bool

func LoadKafkaTLSConfig added in v1.0.0

func LoadKafkaTLSConfig(conf *configuration.Config, prefix string) (*tls.Config, error)

LoadKafkaTLSConfig loads enabled Kafka TLS configuration from HOCON. Prefix should be like "webconfig.kafka", "webconfig.kafka.clusters.mesh", or "webconfig.kafka_producer".

func LoadTLSConfig added in v1.0.0

func LoadTLSConfig(conf *configuration.Config, prefix, component string) (*tls.Config, error)

LoadTLSConfig loads the shared flat tls_* configuration used by Kafka and Cassandra. Prefix should be empty for a driver sub-config, or a full HOCON path such as "webconfig.kafka" or "webconfig.kafka_producer".

func NewError

func NewError(err error) error

func ParseFirmwareGroupBitarray added in v1.0.0

func ParseFirmwareGroupBitarray(s string) (int, int, error)

func ParseGauge added in v1.0.0

func ParseGauge(metrics []*promemodel.Metric) map[string]int

func ParseSummary added in v1.0.0

func ParseSummary(metrics []*promemodel.Metric) map[string]int

func ParseTR181EntryAsItf added in v1.0.0

func ParseTR181EntryAsItf(t *TR181Entry, version string) (interface{}, error)

func PrettyBitarray added in v1.0.0

func PrettyBitarray(i int) string

func PrettyGroupBitarray added in v1.0.0

func PrettyGroupBitarray(i int) string

func RandomBool added in v1.0.0

func RandomBool() bool

func RandomBytes added in v1.0.0

func RandomBytes(lowerBound, upperBound int) []byte

func RandomDouble added in v1.0.0

func RandomDouble() float64

func RandomInt added in v1.0.0

func RandomInt(n int) int

func RectifyLabels added in v1.0.0

func RectifyLabels(labels prometheus.Labels)

func SetBitmapByGroup added in v1.0.0

func SetBitmapByGroup(cpeBitmap *int, groupId int, groupBitmap int) error

func UnwrapAll added in v1.0.0

func UnwrapAll(wrappedErr error) error

func UpdateLogFields added in v1.0.0

func UpdateLogFields(fields, newfields log.Fields)

func WriteMultipartBytes added in v1.0.0

func WriteMultipartBytes(mparts []Multipart) ([]byte, error)

Types

type AppMetrics added in v1.0.0

type AppMetrics struct {
	// contains filtered or unexported fields
}

func NewMetrics added in v1.0.0

func NewMetrics(conf *configuration.Config, args ...func(string) string) *AppMetrics

func (*AppMetrics) CountKafkaEvents added in v1.0.0

func (m *AppMetrics) CountKafkaEvents(eventName string, status string, partition int32)

func (*AppMetrics) DeployedDec added in v1.0.0

func (m *AppMetrics) DeployedDec(labels, mlabels prometheus.Labels, isWatchedCpe bool)

func (*AppMetrics) DeployedInc added in v1.0.0

func (m *AppMetrics) DeployedInc(labels, mlabels prometheus.Labels, isWatchedCpe bool)

deployed(1)

func (*AppMetrics) DeployedSet added in v1.0.0

func (m *AppMetrics) DeployedSet(labels, mlabels prometheus.Labels, v float64, isWatchedCpe bool)

func (*AppMetrics) FailureDec added in v1.0.0

func (m *AppMetrics) FailureDec(labels, mlabels prometheus.Labels, isWatchedCpe bool)

func (*AppMetrics) FailureInc added in v1.0.0

func (m *AppMetrics) FailureInc(labels, mlabels prometheus.Labels, isWatchedCpe bool)

failure(4)

func (*AppMetrics) FailureSet added in v1.0.0

func (m *AppMetrics) FailureSet(labels, mlabels prometheus.Labels, v float64, isWatchedCpe bool)

func (*AppMetrics) GetStateCounter added in v1.0.0

func (m *AppMetrics) GetStateCounter(labels prometheus.Labels) (*StateCounter, error)

func (*AppMetrics) GetStateCountsAsFields added in v1.0.0

func (m *AppMetrics) GetStateCountsAsFields(labels, mlabels prometheus.Labels, isWatchedCpe bool) log.Fields

func (*AppMetrics) InDeploymentDec added in v1.0.0

func (m *AppMetrics) InDeploymentDec(labels, mlabels prometheus.Labels, isWatchedCpe bool)

func (*AppMetrics) InDeploymentInc added in v1.0.0

func (m *AppMetrics) InDeploymentInc(labels, mlabels prometheus.Labels, isWatchedCpe bool)

in_deployment(3)

func (*AppMetrics) InDeploymentSet added in v1.0.0

func (m *AppMetrics) InDeploymentSet(labels, mlabels prometheus.Labels, v float64, isWatchedCpe bool)

func (*AppMetrics) ObserveKafkaDuration added in v1.0.0

func (m *AppMetrics) ObserveKafkaDuration(eventName string, clientName string, duration int)

func (*AppMetrics) ObserveKafkaLag added in v1.0.0

func (m *AppMetrics) ObserveKafkaLag(eventName string, clientName string, lag int, partition int32)

func (*AppMetrics) ObserveKafkaProducerErr added in v1.0.0

func (m *AppMetrics) ObserveKafkaProducerErr(topic string, partition int32)

func (*AppMetrics) PendingDownloadDec added in v1.0.0

func (m *AppMetrics) PendingDownloadDec(labels, mlabels prometheus.Labels, isWatchedCpe bool)

func (*AppMetrics) PendingDownloadInc added in v1.0.0

func (m *AppMetrics) PendingDownloadInc(labels, mlabels prometheus.Labels, isWatchedCpe bool)

pending_download(2)

func (*AppMetrics) PendingDownloadSet added in v1.0.0

func (m *AppMetrics) PendingDownloadSet(labels, mlabels prometheus.Labels, v float64, isWatchedCpe bool)

func (*AppMetrics) ResetStateGauges added in v1.0.0

func (m *AppMetrics) ResetStateGauges()

func (*AppMetrics) SetWatchedCpes added in v1.0.0

func (m *AppMetrics) SetWatchedCpes(watchedCpes []string)

func (*AppMetrics) UpdateStateMetrics added in v1.0.0

func (m *AppMetrics) UpdateStateMetrics(oldState, newState int, labels prometheus.Labels, cpeMac string, fields log.Fields)

func (*AppMetrics) UrlPatternFn added in v1.0.0

func (m *AppMetrics) UrlPatternFn() func(string) string

func (*AppMetrics) WatchedCpes added in v1.0.0

func (m *AppMetrics) WatchedCpes() []string

func (*AppMetrics) WebMetrics added in v1.0.0

func (m *AppMetrics) WebMetrics(next http.Handler) http.Handler

type BitMaskTuple

type BitMaskTuple struct {
	GroupBit int
	CpeBit   int
}

header X-System-Supported-Docs

type Document

type Document struct {
	// contains filtered or unexported fields
}

deviceRootDocument is use to stored the data from device headers in the GET call We stored it to build "new" headers during the upstream call *RootDocument is used to stored data read from db and used to build the "old" headers

func NewDocument

func NewDocument(rootDocument *RootDocument) *Document

TODO add support to support NewDocument([]common.Multipart)

func (*Document) Bytes

func (d *Document) Bytes() ([]byte, error)

func (*Document) DeleteSubDocument added in v1.0.0

func (d *Document) DeleteSubDocument(groupId string)

func (*Document) FilterByBitmap added in v1.0.0

func (d *Document) FilterByBitmap(alwaysTrueSubdocIds ...string) *Document

func (*Document) FilterForGet added in v1.0.0

func (d *Document) FilterForGet(versionMap map[string]string) *Document

func (*Document) FilterForMqttSend added in v1.0.0

func (d *Document) FilterForMqttSend() *Document

TODO (1) for now we only filter by state (2) expiry check can be included to support blaster/command subdocs (3) we can implement blockedSubdocIds if we want

func (*Document) GetRootDocument added in v1.0.0

func (d *Document) GetRootDocument() *RootDocument

func (*Document) HttpBytes added in v1.0.0

func (d *Document) HttpBytes(fields log.Fields) ([]byte, error)

func (*Document) Items added in v1.0.0

func (d *Document) Items() map[string]SubDocument

func (*Document) Length added in v1.0.0

func (d *Document) Length() int

func (*Document) RootVersion added in v1.0.0

func (d *Document) RootVersion() string

func (*Document) SetRootDocument added in v1.0.0

func (d *Document) SetRootDocument(rootDocument *RootDocument)

func (*Document) SetSubDocument added in v1.0.0

func (d *Document) SetSubDocument(groupId string, subdoc *SubDocument)

func (*Document) SetSubDocuments added in v1.0.0

func (d *Document) SetSubDocuments(mparts []Multipart)

func (*Document) StateMap added in v1.0.0

func (d *Document) StateMap() map[string]int

func (*Document) SubDocument added in v1.0.0

func (d *Document) SubDocument(subdocId string) *SubDocument

func (*Document) VersionMap added in v1.0.0

func (d *Document) VersionMap() map[string]string

type EmbeddedHomeWifi added in v1.0.0

type EmbeddedHomeWifi struct {
	Ssid2g      *EmbeddedSsid     `json:"home_ssid_2g,omitempty" msgpack:"home_ssid_2g,omitempty"`
	Ssid5g      *EmbeddedSsid     `json:"home_ssid_5g,omitempty" msgpack:"home_ssid_5g,omitempty"`
	Ssid5gl     *EmbeddedSsid     `json:"home_ssid_5gl,omitempty" msgpack:"home_ssid_5gl,omitempty"`
	Ssid5gu     *EmbeddedSsid     `json:"home_ssid_5gu,omitempty" msgpack:"home_ssid_5gu,omitempty"`
	Ssid6g      *EmbeddedSsid     `json:"home_ssid_6g,omitempty" msgpack:"home_ssid_6g,omitempty"`
	Security2g  *EmbeddedSecurity `json:"home_security_2g,omitempty" msgpack:"home_security_2g,omitempty"`
	Security5g  *EmbeddedSecurity `json:"home_security_5g,omitempty" msgpack:"home_security_5g,omitempty"`
	Security5gl *EmbeddedSecurity `json:"home_security_5gl,omitempty" msgpack:"home_security_5gl,omitempty"`
	Security5gu *EmbeddedSecurity `json:"home_security_5gu,omitempty" msgpack:"home_security_5gu,omitempty"`
	Security6g  *EmbeddedSecurity `json:"home_security_6g,omitempty" msgpack:"home_security_6g,omitempty"`
}

func (*EmbeddedHomeWifi) GetSimpleWifi added in v1.0.0

func (w *EmbeddedHomeWifi) GetSimpleWifi(version string) *SimpleWifi

type EmbeddedPrivateWifi added in v1.0.0

type EmbeddedPrivateWifi struct {
	Ssid2g      *EmbeddedSsid     `json:"private_ssid_2g,omitempty" msgpack:"private_ssid_2g,omitempty"`
	Ssid5g      *EmbeddedSsid     `json:"private_ssid_5g,omitempty" msgpack:"private_ssid_5g,omitempty"`
	Ssid5gl     *EmbeddedSsid     `json:"private_ssid_5gl,omitempty" msgpack:"private_ssid_5gl,omitempty"`
	Ssid5gu     *EmbeddedSsid     `json:"private_ssid_5gu,omitempty" msgpack:"private_ssid_5gu,omitempty"`
	Ssid6g      *EmbeddedSsid     `json:"private_ssid_6g,omitempty" msgpack:"private_ssid_6g,omitempty"`
	Security2g  *EmbeddedSecurity `json:"private_security_2g,omitempty" msgpack:"private_security_2g,omitempty"`
	Security5g  *EmbeddedSecurity `json:"private_security_5g,omitempty" msgpack:"private_security_5g,omitempty"`
	Security5gl *EmbeddedSecurity `json:"private_security_5gl,omitempty" msgpack:"private_security_5gl,omitempty"`
	Security5gu *EmbeddedSecurity `json:"private_security_5gu,omitempty" msgpack:"private_security_5gu,omitempty"`
	Security6g  *EmbeddedSecurity `json:"private_security_6g,omitempty" msgpack:"private_security_6g,omitempty"`
}

func (*EmbeddedPrivateWifi) GetSimpleWifi added in v1.0.0

func (w *EmbeddedPrivateWifi) GetSimpleWifi(version string) *SimpleWifi

type EmbeddedSecurity added in v1.0.0

type EmbeddedSecurity struct {
	Passphrase string `json:"Passphrase" msgpack:"Passphrase"`
	Encryption string `json:"EncryptionMethod" msgpack:"EncryptionMethod"`
	Mode       string `json:"ModeEnabled" msgpack:"ModeEnabled"`
}

type EmbeddedSsid added in v1.0.0

type EmbeddedSsid struct {
	Ssid      string `json:"SSID" msgpack:"SSID"`
	Enable    bool   `json:"Enable" msgpack:"Enable"`
	Broadcast bool   `json:"SSIDAdvertisementEnabled" msgpack:"SSIDAdvertisementEnabled"`
}

type EventMessage added in v1.0.0

type EventMessage struct {
	Namespace         *string       `json:"namespace,omitempty"`
	ApplicationStatus *string       `json:"application_status,omitempty"`
	ErrorCode         *int          `json:"error_code,omitempty"`
	ErrorDetails      *string       `json:"error_details,omitempty"`
	DeviceId          string        `json:"device_id"`
	HttpStatusCode    *int          `json:"http_status_code,omitempty"`
	TransactionUuid   *string       `json:"transaction_uuid,omitempty"`
	Version           *string       `json:"version,omitempty"`
	Reports           []StateReport `json:"reports,omitempty"`
	MetricsAgent      *string       `json:"metrics_agent,omitempty"`
}

func (*EventMessage) EventName added in v1.0.0

func (m *EventMessage) EventName() string

func (*EventMessage) Validate added in v1.0.0

func (m *EventMessage) Validate(checkDeviceId bool) (string, error)

type GroupVersionMismatchError added in v1.0.0

type GroupVersionMismatchError struct {
	// contains filtered or unexported fields
}

func NewGroupVersionMismatchError added in v1.0.0

func NewGroupVersionMismatchError(message string) *GroupVersionMismatchError

func (GroupVersionMismatchError) Error added in v1.0.0

type Http400Error

type Http400Error struct {
	Message string
}

func NewHttp400Error added in v1.0.0

func NewHttp400Error(message string) *Http400Error

func (Http400Error) Error

func (e Http400Error) Error() string

type Http404Error

type Http404Error struct {
	Message string
}

func NewHttp404Error added in v1.0.0

func NewHttp404Error(message string) *Http404Error

func (Http404Error) Error

func (e Http404Error) Error() string

type Http500Error

type Http500Error struct {
	Message string
}

func NewHttp500Error added in v1.0.0

func NewHttp500Error(message string) *Http500Error

func (Http500Error) Error

func (e Http500Error) Error() string

type HttpErrorResponse

type HttpErrorResponse struct {
	Status    int         `json:"status"`
	ErrorCode int         `json:"error_code,omitempty"`
	Message   string      `json:"message,omitempty"`
	Errors    interface{} `json:"errors,omitempty"`
}

http error response

type HttpResponse

type HttpResponse struct {
	Status       int         `json:"status"`
	Message      string      `json:"message,omitempty"`
	Data         interface{} `json:"data,omitempty"`
	State        string      `json:"state,omitempty"`
	UpdatedTime  int         `json:"updated_time,omitempty"`
	ErrorCode    int         `json:"error_code,omitempty"`
	ErrorDetails string      `json:"error_details,omitempty"`
}

http ok response

type Multipart

type Multipart struct {
	Bytes   []byte
	Version string
	Name    string
	State   int
}

type NoCapabilitiesError added in v1.0.0

type NoCapabilitiesError struct {
}

func (NoCapabilitiesError) Error added in v1.0.0

func (e NoCapabilitiesError) Error() string

type PostTokenResponse

type PostTokenResponse struct {
	Data    string `json:"data"`
	Message string `json:"message"`
	Status  int    `json:"status"`
}

type RefSubDocument added in v1.0.0

type RefSubDocument struct {
	// contains filtered or unexported fields
}

func NewRefSubDocument added in v1.0.0

func NewRefSubDocument(payload []byte, version *string) *RefSubDocument

func (*RefSubDocument) Equals added in v1.0.0

func (d *RefSubDocument) Equals(tdoc *RefSubDocument) bool

func (*RefSubDocument) HasPayload added in v1.0.0

func (d *RefSubDocument) HasPayload() bool

func (*RefSubDocument) Payload added in v1.0.0

func (d *RefSubDocument) Payload() []byte

func (*RefSubDocument) SetPayload added in v1.0.0

func (d *RefSubDocument) SetPayload(payload []byte)

func (*RefSubDocument) SetVersion added in v1.0.0

func (d *RefSubDocument) SetVersion(version *string)

func (*RefSubDocument) Version added in v1.0.0

func (d *RefSubDocument) Version() *string

type RemoteHttpError

type RemoteHttpError struct {
	StatusCode int
	Message    string
}

func (RemoteHttpError) Error

func (e RemoteHttpError) Error() string

type ReqHeader added in v1.0.0

type ReqHeader struct {
	http.Header
}

func NewReqHeader added in v1.0.0

func NewReqHeader(header http.Header) *ReqHeader

func (*ReqHeader) Get added in v1.0.0

func (h *ReqHeader) Get(k string) (string, error)

type RootDocument

type RootDocument struct {
	Bitmap          int    `json:"bitmap"`
	FirmwareVersion string `json:"firmware_version"`
	ModelName       string `json:"model_name"`
	PartnerId       string `json:"partner_id"`
	SchemaVersion   string `json:"schema_version"`
	Version         string `json:"version"`
	QueryParams     string `json:"query_params"`
	LockedTill      int    `json:"locked_till"`
	ProductClass    string `json:"product_class"`
	AccountType     string `json:"account_type"`
}

func NewRootDocument

func NewRootDocument(bitmap int, firmwareVersion, modelName, partnerId, schemaVersion, version, query_params, productClass, accountType string) *RootDocument

(bitmap, firmware_version, model_name, partner_id, schema_version, version, query_params, product_class, account_type), nil

func (*RootDocument) Clone added in v1.0.0

func (d *RootDocument) Clone() *RootDocument

func (*RootDocument) ColumnMap added in v1.0.0

func (d *RootDocument) ColumnMap() map[string]interface{}

func (*RootDocument) Compare added in v1.0.0

func (d *RootDocument) Compare(r *RootDocument) int

func (*RootDocument) Equals

func (d *RootDocument) Equals(r *RootDocument) bool

func (*RootDocument) Locked added in v1.0.0

func (d *RootDocument) Locked() bool

func (*RootDocument) NonEmptyColumnMap added in v1.0.0

func (d *RootDocument) NonEmptyColumnMap() map[string]interface{}

func (*RootDocument) String added in v1.0.0

func (d *RootDocument) String() string

func (*RootDocument) Update added in v1.0.0

func (d *RootDocument) Update(r *RootDocument)

update in place

func (*RootDocument) UpdateMetadata added in v1.0.0

func (d *RootDocument) UpdateMetadata(r *RootDocument)

type ServerConfig

type ServerConfig struct {
	*configuration.Config
	// contains filtered or unexported fields
}

func GetTestServerConfig added in v1.0.0

func GetTestServerConfig(args ...string) (*ServerConfig, error)

REMINDER this is called from mutiple packages, but we only init the client/session once

func NewServerConfig

func NewServerConfig(configFile string) (*ServerConfig, error)

func (*ServerConfig) AddConfig added in v1.0.0

func (c *ServerConfig) AddConfig(args ...string)

NOTE that "bad" entries (keys without values, ill-formatted) can still be added hence no parsing error

func (*ServerConfig) ConfigBytes

func (c *ServerConfig) ConfigBytes() []byte

func (*ServerConfig) Copy added in v1.0.0

func (c *ServerConfig) Copy(args ...string) *ServerConfig

copy the config and add extra items

func (*ServerConfig) KafkaClusterNames added in v1.0.0

func (c *ServerConfig) KafkaClusterNames() []string

type SimpleMetrics added in v1.0.0

type SimpleMetrics struct {
	Deployed        map[string]int `json:"deployed"`
	PendingDownload map[string]int `json:"pending_download"`
	InDeployment    map[string]int `json:"in_deployment"`
	Failure         map[string]int `json:"failure"`
	KafkaLag        map[string]int `json:"kafka_lag"`
	KafkaDuration   map[string]int `json:"kafka_duration"`
}

func (*SimpleMetrics) String added in v1.0.0

func (m *SimpleMetrics) String() string

type SimpleWifi added in v1.0.0

type SimpleWifi struct {
	Enabled2g *bool   `json:"enabled_2g,omitempty"`
	Ssid2g    *string `json:"ssid_2g,omitempty"`
	Pass2g    *string `json:"pass_2g,omitempty"`
	Mode2g    *string `json:"mode_2g,omitempty"`
	Enabled5g *bool   `json:"enabled_5g,omitempty"`
	Ssid5g    *string `json:"ssid_5g,omitempty"`
	Pass5g    *string `json:"pass_5g,omitempty"`
	Mode5g    *string `json:"mode_5g,omitempty"`
	Enabled6g *bool   `json:"enabled_6g,omitempty"`
	Ssid6g    *string `json:"ssid_6g,omitempty"`
	Pass6g    *string `json:"pass_6g,omitempty"`
	Mode6g    *string `json:"mode_6g,omitempty"`
	Version   *string `json:"version,omitempty"`
}

type StateCounter added in v1.0.0

type StateCounter struct {
	Deployed        int `json:"deployed"`
	PendingDownload int `json:"pending_download"`
	InDeployment    int `json:"in_deployment"`
	Failure         int `json:"failure"`
}

func (*StateCounter) String added in v1.0.0

func (m *StateCounter) String() string

type StateReport added in v1.0.0

type StateReport struct {
	Url              string `json:"url"`
	HttpStatusCode   int    `json:"http_status_code"`
	RequestTimestamp int    `json:"request_timestamp"`
	Version          string `json:"version"`
	TransactionUuid  string `json:"transaction_uuid"`
}

type SubDocument added in v1.0.0

type SubDocument struct {
	// contains filtered or unexported fields
}

func NewSubDocument added in v1.0.0

func NewSubDocument(payload []byte, version *string, state *int, updatedTime *int, errorCode *int, errorDetails *string) *SubDocument

func (*SubDocument) Equals added in v1.0.0

func (d *SubDocument) Equals(tdoc *SubDocument) (bool, error)

func (*SubDocument) ErrorCode added in v1.0.0

func (d *SubDocument) ErrorCode() *int

func (*SubDocument) ErrorDetails added in v1.0.0

func (d *SubDocument) ErrorDetails() *string

func (*SubDocument) Expiry added in v1.0.0

func (d *SubDocument) Expiry() *int

func (*SubDocument) GetState added in v1.0.0

func (d *SubDocument) GetState() int

convenient function

func (*SubDocument) GetVersion added in v1.0.0

func (d *SubDocument) GetVersion() string

convenient function

func (*SubDocument) HasPayload added in v1.0.0

func (d *SubDocument) HasPayload() bool

func (*SubDocument) NeedsUpdateForHttp304 added in v1.0.0

func (d *SubDocument) NeedsUpdateForHttp304() bool

func (*SubDocument) Payload added in v1.0.0

func (d *SubDocument) Payload() []byte

func (*SubDocument) SetErrorCode added in v1.0.0

func (d *SubDocument) SetErrorCode(errorCode *int)

func (*SubDocument) SetErrorDetails added in v1.0.0

func (d *SubDocument) SetErrorDetails(errorDetails *string)

func (*SubDocument) SetExpiry added in v1.0.0

func (d *SubDocument) SetExpiry(expiry *int)

func (*SubDocument) SetPayload added in v1.0.0

func (d *SubDocument) SetPayload(payload []byte)

func (*SubDocument) SetState added in v1.0.0

func (d *SubDocument) SetState(state *int)

func (*SubDocument) SetUpdatedTime added in v1.0.0

func (d *SubDocument) SetUpdatedTime(updatedTime *int)

func (*SubDocument) SetVersion added in v1.0.0

func (d *SubDocument) SetVersion(version *string)

func (*SubDocument) State added in v1.0.0

func (d *SubDocument) State() *int

func (SubDocument) String added in v1.0.0

func (d SubDocument) String() string

func (*SubDocument) UpdatedTime added in v1.0.0

func (d *SubDocument) UpdatedTime() *int

func (*SubDocument) Version added in v1.0.0

func (d *SubDocument) Version() *string

type SupportedGroupsData

type SupportedGroupsData struct {
	Bitmap int             `json:"bitmap"`
	Groups map[string]bool `json:"groups"`
}

type SupportedGroupsGetResponse

type SupportedGroupsGetResponse struct {
	Data    SupportedGroupsData `json:"data"`
	Message string              `json:"message"`
	Status  int                 `json:"status"`
}

type TR181Entry

type TR181Entry struct {
	Name     string `json:"name" msgpack:"name"`
	Value    string `json:"value" msgpack:"value"`
	DataType int    `json:"dataType" msgpack:"dataType,omitempty"`
}

type TR181Output

type TR181Output struct {
	Parameters []TR181Entry `json:"parameters" msgpack:"parameters"`
}

type TR181Response added in v1.0.0

type TR181Response struct {
	Parameters []TR181ResponseObject `json:"parameters" msgpack:"parameters"`
}

type TR181ResponseObject added in v1.0.0

type TR181ResponseObject struct {
	Name    string `json:"name" msgpack:"name"`
	Message string `json:"message" msgpack:"message"`
}

type Version

type Version struct {
	CodeGitCommit   string `json:"code_git_commit"`
	BuildTime       string `json:"build_time"`
	BinaryVersion   string `json:"binary_version"`
	BinaryBranch    string `json:"binary_branch"`
	BinaryBuildTime string `json:"binary_build_time"`
	OpenLibVersion  string `json:"open_lib_version,omitempty"`
}

Jump to

Keyboard shortcuts

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