// LogUplinkFrameForGateways logs the given frame to all the gateway pub-sub keys.
191631
func LogUplinkFrameForGateways(p *redis.Pool, uplinkFrameSet gw.UplinkFrameSet) error {
	c := p.Get()
	defer c.Close()

	c.Send("MULTI")
	for _, rx := range uplinkFrameSet.RxInfo {
		var id lorawan.EUI64
		copy(id[:], rx.GatewayId)

		frameLog := gw.UplinkFrameSet{
			PhyPayload: uplinkFrameSet.PhyPayload,
			TxInfo:     uplinkFrameSet.TxInfo,
			RxInfo:     []*gw.UplinkRXInfo{rx},
		}

		b, err := proto.Marshal(&frameLog)
		if err != nil {
			return errors.Wrap(err, "marshal uplink frame-set error")
		}

		key := fmt.Sprintf(gatewayFrameLogUplinkPubSubKeyTempl, id)
		c.Send("PUBLISH", key, b)
	}
	_, err := c.Do("EXEC")
	if err != nil {
		return errors.Wrap(err, "publish frame to gateway channel error")
	}

	return nil
}
238452
func hdfsGatewayMain(ctx *cli.Context) {
	// Validate gateway arguments.
	if !ctx.Args().Present() || ctx.Args().First() == "help" {
		cli.ShowCommandHelpAndExit(ctx, hdfsBackend, 1)
	}

	minio.StartGateway(ctx, &HDFS{args: ctx.Args()})
}
1004513
func (wfe *WebFrontEndImpl) KeyRollover(ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) {
	body, _, reg, prob := wfe.verifyPOST(ctx, logEvent, request, true, core.ResourceKeyChange)
	addRequesterHeader(response, logEvent.Requester)
	if prob != nil {
		wfe.sendError(response, logEvent, prob, nil)
		return
	}

	// Parse as JWS
	newKey, parsedJWS, err := wfe.extractJWSKey(string(body))
	if err != nil {
		wfe.sendError(response, logEvent, probs.Malformed(err.Error()), err)
		return
	}
	payload, err := parsedJWS.Verify(newKey)
	if err != nil {
		wfe.sendError(response, logEvent, probs.Malformed("JWS verification error"), err)
		return
	}
	var rolloverRequest struct {
		NewKey  jose.JSONWebKey
		Account string
	}
	err = json.Unmarshal(payload, &rolloverRequest)
	if err != nil {
		wfe.sendError(response, logEvent, probs.Malformed("Request payload did not parse as JSON"), nil)
		return
	}

	if web.RelativeEndpoint(request, fmt.Sprintf("%s%d", regPath, reg.ID)) != rolloverRequest.Account {
		wfe.sendError(response, logEvent, probs.Malformed("Incorrect account URL provided in payload"), nil)
		return
	}

	keysEqual, err := core.PublicKeysEqual(rolloverRequest.NewKey.Key, newKey.Key)
	if err != nil {
		wfe.sendError(response, logEvent, probs.Malformed("Unable to marshal new JWK"), nil)
		return
	}
	if !keysEqual {
		wfe.sendError(response, logEvent, probs.Malformed("New JWK in inner payload doesn't match key used to sign inner JWS"), nil)
		return
	}

	// Update registration key
	updatedReg, err := wfe.RA.UpdateRegistration(ctx, reg, core.Registration{Key: newKey})
	if err != nil {
		wfe.sendError(response, logEvent, web.ProblemDetailsForError(err, "Unable to update registration"), err)
		return
	}

	jsonReply, err := marshalIndent(updatedReg)
	if err != nil {
		wfe.sendError(response, logEvent, probs.ServerInternal("Failed to marshal registration"), err)
		return
	}
	response.Header().Set("Content-Type", "application/json")
	response.WriteHeader(http.StatusOK)
	response.Write(jsonReply)
}
1080714
func (o *IKEGateway) IKEGatewayConfigs(info *bambou.FetchingInfo) (IKEGatewayConfigsList, *bambou.Error) {

	var list IKEGatewayConfigsList
	err := bambou.CurrentSession().FetchChildren(o, IKEGatewayConfigIdentity, &list, info)
	return list, err
}
1107630
func (c *Client) LinkWalk(bucket, key string) (*RpbGetResp, error) {
	return c.FetchObject(bucket, key)
}
1046503
func (o *Enterprise) CreateGateway(child *Gateway) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
358482
func (a *Account) EditGateway(gatewayID string, edits GatewayEdits) error {
	return a.patch(a.auth.WithScope(scope.Gateway(gatewayID)), fmt.Sprintf("/api/v2/gateways/%s", gatewayID), edits, nil)
}
202030
func (o *Me) InfrastructureGatewayProfiles(info *bambou.FetchingInfo) (InfrastructureGatewayProfilesList, *bambou.Error) {

	var list InfrastructureGatewayProfilesList
	err := bambou.CurrentSession().FetchChildren(o, InfrastructureGatewayProfileIdentity, &list, info)
	return list, err
}
390908
func buildRollbarFrames(callers []uintptr) (frames rollbarFrames) {
	frames = rollbarFrames{}

	// 2016-08-24 - runtime.CallersFrames was added in Go 1.7, which should
	// replace the following code when roll is able to require Go 1.7+.
	for _, caller := range callers {
		frame := rollbarFrame{
			Filename: "???",
			Method:   "???",
		}
		if fn := runtime.FuncForPC(caller); fn != nil {
			name, line := fn.FileLine(caller)
			frame.Filename = scrubFile(name)
			frame.Line = line
			frame.Method = scrubFunction(fn.Name())
		}
		frames = append(frames, frame)
	}

	return frames
}
775922
func (o *Enterprise) CreateIKEGateway(child *IKEGateway) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
857837
func (l *LoaderContextG) getLinksFromServer(ctx context.Context,
	teamID keybase1.TeamID, requestSeqnos []keybase1.Seqno, readSubteamID *keybase1.TeamID) (*rawTeam, error) {
	return l.getLinksFromServerCommon(ctx, teamID, nil, requestSeqnos, readSubteamID)
}
1302087
func (s DeviceSession) GetDownlinkGatewayMAC() (lorawan.EUI64, error) {
	for mac := range s.UplinkGatewayHistory {
		return mac, nil
	}

	return lorawan.EUI64{}, errors.New("uplink gateway-history is empty")
}
666617
func (o *NSRedundantGatewayGroup) ShuntLinks(info *bambou.FetchingInfo) (ShuntLinksList, *bambou.Error) {

	var list ShuntLinksList
	err := bambou.CurrentSession().FetchChildren(o, ShuntLinkIdentity, &list, info)
	return list, err
}
160154
func linkFlags(rawFlags uint32) net.Flags {
	var f net.Flags
	if rawFlags&unix.IFF_UP != 0 {
		f |= net.FlagUp
	}
	if rawFlags&unix.IFF_BROADCAST != 0 {
		f |= net.FlagBroadcast
	}
	if rawFlags&unix.IFF_LOOPBACK != 0 {
		f |= net.FlagLoopback
	}
	if rawFlags&unix.IFF_POINTOPOINT != 0 {
		f |= net.FlagPointToPoint
	}
	if rawFlags&unix.IFF_MULTICAST != 0 {
		f |= net.FlagMulticast
	}
	return f
}
403086
func GetGatewaysForIDs(db sqlx.Queryer, ids []lorawan.EUI64) (map[lorawan.EUI64]Gateway, error) {
	out := make(map[lorawan.EUI64]Gateway)
	var idsB [][]byte
	for i := range ids {
		idsB = append(idsB, ids[i][:])
	}

	var gws []Gateway
	err := sqlx.Select(db, &gws, "select * from gateway where gateway_id = any($1)", pq.ByteaArray(idsB))
	if err != nil {
		return nil, handlePSQLError(err, "select error")
	}

	if len(gws) != len(ids) {
		return nil, fmt.Errorf("expected %d gateways, got %d", len(ids), len(out))
	}

	for i := range gws {
		out[gws[i].GatewayID] = gws[i]
	}

	return out, nil
}
1316556
func (c *client) gatewayAllSubsReceiveStart(info *Info) {
	account := getAccountFromGatewayCommand(c, info, "start")
	if account == "" {
		return
	}
	// Since the remote would send us this start command
	// only after sending us too many RS- for this account,
	// we should always have an entry here.
	// TODO(ik): Should we close connection with protocol violation
	// error if that happens?
	ei, _ := c.gw.outsim.Load(account)
	if ei != nil {
		e := ei.(*outsie)
		e.Lock()
		e.mode = modeTransitioning
		e.Unlock()
	} else {
		e := &outsie{sl: NewSublist()}
		e.mode = modeTransitioning
		c.mu.Lock()
		c.gw.outsim.Store(account, e)
		c.mu.Unlock()
	}
}
1279675
func isAWSErrStorageGatewayGatewayNotFound(err error) bool {
	if isAWSErr(err, storagegateway.ErrCodeInvalidGatewayRequestException, "The specified gateway was not found.") {
		return true
	}
	if isAWSErr(err, storagegateway.ErrorCodeGatewayNotFound, "") {
		return true
	}
	return false
}