// toBigQueryMessage returns a message to upload to BigQuery.
554642
func (i *MintedTokenInfo) toBigQueryMessage() *bqpb.DelegationToken {
	subtok := i.Response.DelegationSubtoken
	return &bqpb.DelegationToken{
		// Information about the produced token.
		Fingerprint:       utils.TokenFingerprint(i.Response.Token),
		TokenKind:         subtok.Kind,
		TokenId:           fmt.Sprintf("%d", subtok.SubtokenId),
		DelegatedIdentity: subtok.DelegatedIdentity,
		RequestorIdentity: subtok.RequestorIdentity,
		IssuedAt:          &timestamp.Timestamp{Seconds: subtok.CreationTime},
		Expiration:        &timestamp.Timestamp{Seconds: subtok.CreationTime + int64(subtok.ValidityDuration)},
		TargetAudience:    subtok.Audience,
		TargetServices:    subtok.Services,

		// Information about the request.
		RequestedValidity: i.Request.ValidityDuration,
		RequestedIntent:   i.Request.Intent,
		Tags:              subtok.Tags,

		// Information about the delegation rule used.
		ConfigRev:  i.ConfigRev,
		ConfigRule: i.Rule.Name,

		// Information about the request handler environment.
		PeerIp:         i.PeerIP.String(),
		ServiceVersion: i.Response.ServiceVersion,
		GaeRequestId:   i.RequestID,
		AuthDbRev:      i.AuthDBRev,
	}
}
1166226
func NewMessageFromBytes(nlb []byte) (*Message, error) {
	nlm := C.nlmsg_alloc_size(C.size_t(len(nlb)))
	if nlm == nil {
		return nil, errors.New("failed to create netlink message")
	}
	nlh := C.nlmsg_hdr(nlm)
	copy((*[1 << 20]byte)(unsafe.Pointer(nlh))[:len(nlb)], nlb)
	return &Message{nlm: nlm}, nil
}
414230
func RequestMessage(level string, r *http.Request, msg string) {
	std.RequestMessage(level, r, msg)
}
500078
func (a *SetPausedInDebuggerMessageArgs) SetMessage(message string) *SetPausedInDebuggerMessageArgs {
	a.Message = &message
	return a
}
212431
func NewMessage(typ Message_MessageType, key []byte, level int) *Message {
	m := &Message{
		Type: typ,
		Key:  key,
	}
	m.SetClusterLevel(level)
	return m
}
444260
func (c *Conversation) revealSigMessage() ([]byte, error) {
	c.calcAKEKeys(c.calcDHSharedSecret())
	c.ake.keys.ourKeyID++

	encryptedSig, err := c.generateEncryptedSignature(&c.ake.revealKey)
	if err != nil {
		return nil, err
	}

	macSig := sumHMAC(c.ake.revealKey.m2, encryptedSig, c.version)
	revealSigMsg := revealSig{
		r:            c.ake.r,
		encryptedSig: encryptedSig,
		macSig:       macSig,
	}

	return revealSigMsg.serialize(c.version), nil
}
1154581
func (pl *Payload) BuildMessage() ([]byte, error) {
	plBuf, err := pl.Encode()
	if err != nil {
		return nil, fmt.Errorf("unable to encode payload: %s", err)
	}

	meta := &Meta{Size: uint32(len(plBuf))}
	metaBuf, err := meta.MarshalBinary()
	if err != nil {
		return nil, fmt.Errorf("unable to encode metadata: %s", err)
	}

	return append(metaBuf, plBuf...), nil
}
1068139
func (v *TApplicationException) GetMessage() (o string) {
	if v != nil && v.Message != nil {
		return *v.Message
	}

	return
}
1312944
func (l *Limiter) GetMessageContentType() string {
	l.RLock()
	defer l.RUnlock()
	return l.messageContentType
}
402163
func ReadMessage(r io.Reader, pver uint32) (Message, error) {
	// First, we'll read out the first two bytes of the message so we can
	// create the proper empty message.
	var mType [2]byte
	if _, err := io.ReadFull(r, mType[:]); err != nil {
		return nil, err
	}

	msgType := MessageType(binary.BigEndian.Uint16(mType[:]))

	// Now that we know the target message type, we can create the proper
	// empty message type and decode the message into it.
	msg, err := makeEmptyMessage(msgType)
	if err != nil {
		return nil, err
	}
	if err := msg.Decode(r, pver); err != nil {
		return nil, err
	}

	return msg, nil
}
1359853
func logMessage(peer wtserver.Peer, msg wtwire.Message, read bool) {
	var action = "Received"
	var preposition = "from"
	if !read {
		action = "Sending"
		preposition = "to"
	}

	summary := wtwire.MessageSummary(msg)
	if len(summary) > 0 {
		summary = "(" + summary + ")"
	}

	log.Debugf("%s %s%v %s %x@%s", action, msg.MsgType(), summary,
		preposition, peer.RemotePub().SerializeCompressed(),
		peer.RemoteAddr())
}
1370817
func (c *Client) UpdateBigQuery(i *UpdateBigQueryInput) (*BigQuery, error) {
	if i.Service == "" {
		return nil, ErrMissingService
	}

	if i.Version == 0 {
		return nil, ErrMissingVersion
	}

	if i.Name == "" {
		return nil, ErrMissingName
	}

	if i.NewName == "" {
		return nil, ErrMissingNewName
	}

	params := make(map[string]string)
	params["name"] = i.NewName
	if i.ProjectID != "" {
		params["project_id"] = i.ProjectID
	}
	if i.Dataset != "" {
		params["dataset"] = i.Dataset
	}
	if i.Table != "" {
		params["table"] = i.Table
	}
	if i.Template != "" {
		params["template_suffix"] = i.Template
	}
	if i.User != "" {
		params["user"] = i.User
	}
	if i.SecretKey != "" {
		params["secret_key"] = i.SecretKey
	}
	if i.Format != "" {
		params["format"] = i.Format
	}
	if i.ResponseCondition != "" {
		params["response_condition"] = i.ResponseCondition
	}

	if i.Placement != "" {
		params["placement"] = i.Placement
	}

	path := fmt.Sprintf("/service/%s/version/%d/logging/bigquery/%s", i.Service, i.Version, i.Name)
	resp, err := c.PutForm(path, i, &RequestOptions{
		Params: params,
	})
	if err != nil {
		return nil, err
	}

	var b *BigQuery
	if err := decodeJSON(&b, resp.Body); err != nil {
		return nil, err
	}
	return b, nil
}
1140339
func (v *Bonk) GetMessage() (o string) {
	if v != nil && v.Message != nil {
		return *v.Message
	}

	return
}
398366
func (buf *LogBuffer) PushMessage(msg string) {
	buf.msgLock.Lock()
	buf.messages.Value = msg
	buf.messages = buf.messages.Next()
	buf.msgLock.Unlock()
	if hook := buf.PushMessageHook; hook != nil {
		hook(msg)
	}
}
47750
func (c *Conn) WriteMessage(messageType int, data []byte) error {

	if c.isServer && (c.newCompressionWriter == nil || !c.enableWriteCompression) {
		// Fast path with no allocations and single frame.

		var mw messageWriter
		if err := c.beginMessage(&mw, messageType); err != nil {
			return err
		}
		n := copy(c.writeBuf[mw.pos:], data)
		mw.pos += n
		data = data[n:]
		return mw.flushFrame(true, data)
	}

	w, err := c.NextWriter(messageType)
	if err != nil {
		return err
	}
	if _, err = w.Write(data); err != nil {
		return err
	}
	return w.Close()
}
680013
func (b *Builder) ToOutsideQuery(t tap.Message_Type) (*tap.Message, error) {
	return &tap.Message{
		Type:            &t,
		SocketFamily:    &b.SocketFam,
		SocketProtocol:  &b.SocketProto,
		QueryTimeSec:    &b.TimeSec,
		QueryTimeNsec:   &b.TimeNsec,
		QueryMessage:    b.Packed,
		ResponseAddress: b.Address,
		ResponsePort:    &b.Port,
	}, b.err
}
624153
func (c Conversation) QueryMessage() ValidMessage {
	queryMessage := []byte("?OTRv")

	if c.Policies.has(allowV2) {
		queryMessage = append(queryMessage, '2')
	}

	if c.Policies.has(allowV3) {
		queryMessage = append(queryMessage, '3')
	}

	suffix := "?"
	if c.friendlyQueryMessage != "" {
		suffix = "? " + c.friendlyQueryMessage
	}

	return append(queryMessage, suffix...)
}