diff --git a/lte/cloud/go/protos/oai/spgw_state.pb.go b/lte/cloud/go/protos/oai/spgw_state.pb.go index 87c742d8e354..8a94a7a3fbd5 100644 --- a/lte/cloud/go/protos/oai/spgw_state.pb.go +++ b/lte/cloud/go/protos/oai/spgw_state.pb.go @@ -42,19 +42,21 @@ type SgwEpsBearerContextInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Imsi []byte `protobuf:"bytes,1,opt,name=imsi,proto3" json:"imsi,omitempty"` - ImsiUnauthIndicator uint32 `protobuf:"varint,2,opt,name=imsi_unauth_indicator,json=imsiUnauthIndicator,proto3" json:"imsi_unauth_indicator,omitempty"` - Msisdn string `protobuf:"bytes,3,opt,name=msisdn,proto3" json:"msisdn,omitempty"` - LastKnownCellId *Ecgi `protobuf:"bytes,4,opt,name=last_known_cell_id,json=lastKnownCellId,proto3" json:"last_known_cell_id,omitempty"` - Trxn []byte `protobuf:"bytes,5,opt,name=trxn,proto3" json:"trxn,omitempty"` - Imsi64 uint64 `protobuf:"varint,6,opt,name=imsi64,proto3" json:"imsi64,omitempty"` - MmeTeidS11 uint32 `protobuf:"varint,10,opt,name=mme_teid_s11,json=mmeTeidS11,proto3" json:"mme_teid_s11,omitempty"` // teid_t - MmeIpAddressS11 []byte `protobuf:"bytes,11,opt,name=mme_ip_address_s11,json=mmeIpAddressS11,proto3" json:"mme_ip_address_s11,omitempty"` - SgwTeidS11S4 uint32 `protobuf:"varint,15,opt,name=sgw_teid_s11_s4,json=sgwTeidS11S4,proto3" json:"sgw_teid_s11_s4,omitempty"` - SgwIpAddressS11S4 []byte `protobuf:"bytes,16,opt,name=sgw_ip_address_s11_s4,json=sgwIpAddressS11S4,proto3" json:"sgw_ip_address_s11_s4,omitempty"` - PdnConnection *SgwPdnConnection `protobuf:"bytes,20,opt,name=pdn_connection,json=pdnConnection,proto3" json:"pdn_connection,omitempty"` - SavedMessage *CreateSessionMessage `protobuf:"bytes,21,opt,name=saved_message,json=savedMessage,proto3" json:"saved_message,omitempty"` - PendingProcedures []*PgwCbrProcedure `protobuf:"bytes,22,rep,name=pending_procedures,json=pendingProcedures,proto3" json:"pending_procedures,omitempty"` + Imsi []byte `protobuf:"bytes,1,opt,name=imsi,proto3" json:"imsi,omitempty"` + ImsiUnauthIndicator uint32 `protobuf:"varint,2,opt,name=imsi_unauth_indicator,json=imsiUnauthIndicator,proto3" json:"imsi_unauth_indicator,omitempty"` + Msisdn string `protobuf:"bytes,3,opt,name=msisdn,proto3" json:"msisdn,omitempty"` + LastKnownCellId *Ecgi `protobuf:"bytes,4,opt,name=last_known_cell_id,json=lastKnownCellId,proto3" json:"last_known_cell_id,omitempty"` + Trxn []byte `protobuf:"bytes,5,opt,name=trxn,proto3" json:"trxn,omitempty"` + Imsi64 uint64 `protobuf:"varint,6,opt,name=imsi64,proto3" json:"imsi64,omitempty"` + MmeTeidS11 uint32 `protobuf:"varint,10,opt,name=mme_teid_s11,json=mmeTeidS11,proto3" json:"mme_teid_s11,omitempty"` // teid_t + // Deprecated: Do not use. + MmeIpAddressS11 []byte `protobuf:"bytes,11,opt,name=mme_ip_address_s11,json=mmeIpAddressS11,proto3" json:"mme_ip_address_s11,omitempty"` + SgwTeidS11S4 uint32 `protobuf:"varint,15,opt,name=sgw_teid_s11_s4,json=sgwTeidS11S4,proto3" json:"sgw_teid_s11_s4,omitempty"` + SgwIpAddressS11S4 []byte `protobuf:"bytes,16,opt,name=sgw_ip_address_s11_s4,json=sgwIpAddressS11S4,proto3" json:"sgw_ip_address_s11_s4,omitempty"` + PdnConnection *SgwPdnConnection `protobuf:"bytes,20,opt,name=pdn_connection,json=pdnConnection,proto3" json:"pdn_connection,omitempty"` + SavedMessage *CreateSessionMessage `protobuf:"bytes,21,opt,name=saved_message,json=savedMessage,proto3" json:"saved_message,omitempty"` + PendingProcedures []*PgwCbrProcedure `protobuf:"bytes,22,rep,name=pending_procedures,json=pendingProcedures,proto3" json:"pending_procedures,omitempty"` + MmeCpIpAddressS11 *IpTupple `protobuf:"bytes,23,opt,name=mme_cp_ip_address_s11,json=mmeCpIpAddressS11,proto3" json:"mme_cp_ip_address_s11,omitempty"` } func (x *SgwEpsBearerContextInfo) Reset() { @@ -138,6 +140,7 @@ func (x *SgwEpsBearerContextInfo) GetMmeTeidS11() uint32 { return 0 } +// Deprecated: Do not use. func (x *SgwEpsBearerContextInfo) GetMmeIpAddressS11() []byte { if x != nil { return x.MmeIpAddressS11 @@ -180,6 +183,13 @@ func (x *SgwEpsBearerContextInfo) GetPendingProcedures() []*PgwCbrProcedure { return nil } +func (x *SgwEpsBearerContextInfo) GetMmeCpIpAddressS11() *IpTupple { + if x != nil { + return x.MmeCpIpAddressS11 + } + return nil +} + // pgw_ni_cbr_proc_t type PgwCbrProcedure struct { state protoimpl.MessageState @@ -370,16 +380,17 @@ type CreateSessionMessage struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Trxn []byte `protobuf:"bytes,1,opt,name=trxn,proto3" json:"trxn,omitempty"` - Teid uint32 `protobuf:"varint,2,opt,name=teid,proto3" json:"teid,omitempty"` - Imsi []byte `protobuf:"bytes,3,opt,name=imsi,proto3" json:"imsi,omitempty"` - Msisdn []byte `protobuf:"bytes,4,opt,name=msisdn,proto3" json:"msisdn,omitempty"` - Mei []byte `protobuf:"bytes,5,opt,name=mei,proto3" json:"mei,omitempty"` - Uli []byte `protobuf:"bytes,6,opt,name=uli,proto3" json:"uli,omitempty"` - ServingNetwork *ServingNetwork `protobuf:"bytes,7,opt,name=serving_network,json=servingNetwork,proto3" json:"serving_network,omitempty"` - RatType uint32 `protobuf:"varint,10,opt,name=rat_type,json=ratType,proto3" json:"rat_type,omitempty"` - PdnType uint32 `protobuf:"varint,11,opt,name=pdn_type,json=pdnType,proto3" json:"pdn_type,omitempty"` - Apn []byte `protobuf:"bytes,12,opt,name=apn,proto3" json:"apn,omitempty"` + Trxn []byte `protobuf:"bytes,1,opt,name=trxn,proto3" json:"trxn,omitempty"` + Teid uint32 `protobuf:"varint,2,opt,name=teid,proto3" json:"teid,omitempty"` + Imsi []byte `protobuf:"bytes,3,opt,name=imsi,proto3" json:"imsi,omitempty"` + Msisdn []byte `protobuf:"bytes,4,opt,name=msisdn,proto3" json:"msisdn,omitempty"` + Mei []byte `protobuf:"bytes,5,opt,name=mei,proto3" json:"mei,omitempty"` + Uli []byte `protobuf:"bytes,6,opt,name=uli,proto3" json:"uli,omitempty"` + ServingNetwork *ServingNetwork `protobuf:"bytes,7,opt,name=serving_network,json=servingNetwork,proto3" json:"serving_network,omitempty"` + RatType uint32 `protobuf:"varint,10,opt,name=rat_type,json=ratType,proto3" json:"rat_type,omitempty"` + PdnType uint32 `protobuf:"varint,11,opt,name=pdn_type,json=pdnType,proto3" json:"pdn_type,omitempty"` + Apn []byte `protobuf:"bytes,12,opt,name=apn,proto3" json:"apn,omitempty"` + // Deprecated: Do not use. Paa []byte `protobuf:"bytes,13,opt,name=paa,proto3" json:"paa,omitempty"` Ambr *Ambr `protobuf:"bytes,14,opt,name=ambr,proto3" json:"ambr,omitempty"` Pco *Pco `protobuf:"bytes,15,opt,name=pco,proto3" json:"pco,omitempty"` @@ -388,6 +399,7 @@ type CreateSessionMessage struct { PeerIp uint32 `protobuf:"varint,21,opt,name=peer_ip,json=peerIp,proto3" json:"peer_ip,omitempty"` UeTimeZone *TimeZone `protobuf:"bytes,22,opt,name=ue_time_zone,json=ueTimeZone,proto3" json:"ue_time_zone,omitempty"` ChargingCharacteristics string `protobuf:"bytes,23,opt,name=charging_characteristics,json=chargingCharacteristics,proto3" json:"charging_characteristics,omitempty"` // Taken from S6A UpdateLocationAnswer + UeIpPaa *IpTupple `protobuf:"bytes,24,opt,name=ue_ip_paa,json=ueIpPaa,proto3" json:"ue_ip_paa,omitempty"` } func (x *CreateSessionMessage) Reset() { @@ -492,6 +504,7 @@ func (x *CreateSessionMessage) GetApn() []byte { return nil } +// Deprecated: Do not use. func (x *CreateSessionMessage) GetPaa() []byte { if x != nil { return x.Paa @@ -548,6 +561,13 @@ func (x *CreateSessionMessage) GetChargingCharacteristics() string { return "" } +func (x *CreateSessionMessage) GetUeIpPaa() *IpTupple { + if x != nil { + return x.UeIpPaa + } + return nil +} + // bearer_context_to_be_created_t type BearerContextToBeCreated struct { state protoimpl.MessageState @@ -682,12 +702,14 @@ type SgwPdnConnection struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ApnInUse string `protobuf:"bytes,1,opt,name=apn_in_use,json=apnInUse,proto3" json:"apn_in_use,omitempty"` - PgwAddressInUseCp []byte `protobuf:"bytes,2,opt,name=pgw_address_in_use_cp,json=pgwAddressInUseCp,proto3" json:"pgw_address_in_use_cp,omitempty"` - PgwAddressInUseUp []byte `protobuf:"bytes,3,opt,name=pgw_address_in_use_up,json=pgwAddressInUseUp,proto3" json:"pgw_address_in_use_up,omitempty"` - DefaultBearer uint32 `protobuf:"varint,10,opt,name=default_bearer,json=defaultBearer,proto3" json:"default_bearer,omitempty"` - UeSuspendedForPsHandover bool `protobuf:"varint,11,opt,name=ue_suspended_for_ps_handover,json=ueSuspendedForPsHandover,proto3" json:"ue_suspended_for_ps_handover,omitempty"` - EpsBearerList []*SgwEpsBearerContext `protobuf:"bytes,15,rep,name=eps_bearer_list,json=epsBearerList,proto3" json:"eps_bearer_list,omitempty"` + ApnInUse string `protobuf:"bytes,1,opt,name=apn_in_use,json=apnInUse,proto3" json:"apn_in_use,omitempty"` + PgwAddressInUseCp []byte `protobuf:"bytes,2,opt,name=pgw_address_in_use_cp,json=pgwAddressInUseCp,proto3" json:"pgw_address_in_use_cp,omitempty"` + PgwAddressInUseUp []byte `protobuf:"bytes,3,opt,name=pgw_address_in_use_up,json=pgwAddressInUseUp,proto3" json:"pgw_address_in_use_up,omitempty"` + DefaultBearer uint32 `protobuf:"varint,10,opt,name=default_bearer,json=defaultBearer,proto3" json:"default_bearer,omitempty"` + UeSuspendedForPsHandover bool `protobuf:"varint,11,opt,name=ue_suspended_for_ps_handover,json=ueSuspendedForPsHandover,proto3" json:"ue_suspended_for_ps_handover,omitempty"` + // Deprecated: Do not use. + EpsBearerList []*SgwEpsBearerContext `protobuf:"bytes,15,rep,name=eps_bearer_list,json=epsBearerList,proto3" json:"eps_bearer_list,omitempty"` + EpsBearerMap map[uint32]*SgwEpsBearerContext `protobuf:"bytes,16,rep,name=eps_bearer_map,json=epsBearerMap,proto3" json:"eps_bearer_map,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // ebi -> SgwEpsBearerContext } func (x *SgwPdnConnection) Reset() { @@ -757,6 +779,7 @@ func (x *SgwPdnConnection) GetUeSuspendedForPsHandover() bool { return false } +// Deprecated: Do not use. func (x *SgwPdnConnection) GetEpsBearerList() []*SgwEpsBearerContext { if x != nil { return x.EpsBearerList @@ -764,14 +787,23 @@ func (x *SgwPdnConnection) GetEpsBearerList() []*SgwEpsBearerContext { return nil } +func (x *SgwPdnConnection) GetEpsBearerMap() map[uint32]*SgwEpsBearerContext { + if x != nil { + return x.EpsBearerMap + } + return nil +} + // sgw_eps_bearer_ctxt_t type SgwEpsBearerContext struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EpsBearerId uint32 `protobuf:"varint,1,opt,name=eps_bearer_id,json=epsBearerId,proto3" json:"eps_bearer_id,omitempty"` - Paa []byte `protobuf:"bytes,2,opt,name=paa,proto3" json:"paa,omitempty"` + EpsBearerId uint32 `protobuf:"varint,1,opt,name=eps_bearer_id,json=epsBearerId,proto3" json:"eps_bearer_id,omitempty"` + // Deprecated: Do not use. + Paa []byte `protobuf:"bytes,2,opt,name=paa,proto3" json:"paa,omitempty"` + // Deprecated: Do not use. PgwAddressInUseUp []byte `protobuf:"bytes,10,opt,name=pgw_address_in_use_up,json=pgwAddressInUseUp,proto3" json:"pgw_address_in_use_up,omitempty"` PgwTeidS5S8Up uint32 `protobuf:"varint,11,opt,name=pgw_teid_s5_s8_up,json=pgwTeidS5S8Up,proto3" json:"pgw_teid_s5_s8_up,omitempty"` SgwIpAddressS5S8Up []byte `protobuf:"bytes,12,opt,name=sgw_ip_address_s5_s8_up,json=sgwIpAddressS5S8Up,proto3" json:"sgw_ip_address_s5_s8_up,omitempty"` @@ -786,6 +818,12 @@ type SgwEpsBearerContext struct { SdfIds []uint32 `protobuf:"varint,26,rep,packed,name=sdf_ids,json=sdfIds,proto3" json:"sdf_ids,omitempty"` PolicyRuleName string `protobuf:"bytes,27,opt,name=policy_rule_name,json=policyRuleName,proto3" json:"policy_rule_name,omitempty"` SgwIpv6AddressS1US12S4Up []byte `protobuf:"bytes,28,opt,name=sgw_ipv6_address_s1u_s12_s4_up,json=sgwIpv6AddressS1uS12S4Up,proto3" json:"sgw_ipv6_address_s1u_s12_s4_up,omitempty"` + EnbS1UIpAddr *IpTupple `protobuf:"bytes,29,opt,name=enb_s1u_ip_addr,json=enbS1uIpAddr,proto3" json:"enb_s1u_ip_addr,omitempty"` + UeIpPaa *IpTupple `protobuf:"bytes,30,opt,name=ue_ip_paa,json=ueIpPaa,proto3" json:"ue_ip_paa,omitempty"` + PgwAddressUp *IpTupple `protobuf:"bytes,31,opt,name=pgw_address_up,json=pgwAddressUp,proto3" json:"pgw_address_up,omitempty"` + SgwS1US12S4UpIpAddr *IpTupple `protobuf:"bytes,32,opt,name=sgw_s1u_s12_s4_up_ip_addr,json=sgwS1uS12S4UpIpAddr,proto3" json:"sgw_s1u_s12_s4_up_ip_addr,omitempty"` + SgwSequenceNumber uint32 `protobuf:"varint,33,opt,name=sgw_sequence_number,json=sgwSequenceNumber,proto3" json:"sgw_sequence_number,omitempty"` + UpdateTeids bool `protobuf:"varint,34,opt,name=update_teids,json=updateTeids,proto3" json:"update_teids,omitempty"` } func (x *SgwEpsBearerContext) Reset() { @@ -827,6 +865,7 @@ func (x *SgwEpsBearerContext) GetEpsBearerId() uint32 { return 0 } +// Deprecated: Do not use. func (x *SgwEpsBearerContext) GetPaa() []byte { if x != nil { return x.Paa @@ -834,6 +873,7 @@ func (x *SgwEpsBearerContext) GetPaa() []byte { return nil } +// Deprecated: Do not use. func (x *SgwEpsBearerContext) GetPgwAddressInUseUp() []byte { if x != nil { return x.PgwAddressInUseUp @@ -932,6 +972,48 @@ func (x *SgwEpsBearerContext) GetSgwIpv6AddressS1US12S4Up() []byte { return nil } +func (x *SgwEpsBearerContext) GetEnbS1UIpAddr() *IpTupple { + if x != nil { + return x.EnbS1UIpAddr + } + return nil +} + +func (x *SgwEpsBearerContext) GetUeIpPaa() *IpTupple { + if x != nil { + return x.UeIpPaa + } + return nil +} + +func (x *SgwEpsBearerContext) GetPgwAddressUp() *IpTupple { + if x != nil { + return x.PgwAddressUp + } + return nil +} + +func (x *SgwEpsBearerContext) GetSgwS1US12S4UpIpAddr() *IpTupple { + if x != nil { + return x.SgwS1US12S4UpIpAddr + } + return nil +} + +func (x *SgwEpsBearerContext) GetSgwSequenceNumber() uint32 { + if x != nil { + return x.SgwSequenceNumber + } + return 0 +} + +func (x *SgwEpsBearerContext) GetUpdateTeids() bool { + if x != nil { + return x.UpdateTeids + } + return false +} + // traffic_flow_template type TrafficFlowTemplate struct { state protoimpl.MessageState @@ -1520,6 +1602,85 @@ func (x *SpgwState) GetGtpv1UData() *GTPV1UData { return nil } +type IpTupple struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PdnType uint32 `protobuf:"varint,1,opt,name=pdn_type,json=pdnType,proto3" json:"pdn_type,omitempty"` + Ipv4Addr []byte `protobuf:"bytes,2,opt,name=ipv4_addr,json=ipv4Addr,proto3" json:"ipv4_addr,omitempty"` + Ipv6Addr []byte `protobuf:"bytes,3,opt,name=ipv6_addr,json=ipv6Addr,proto3" json:"ipv6_addr,omitempty"` + Vlan int32 `protobuf:"varint,4,opt,name=vlan,proto3" json:"vlan,omitempty"` + Ipv6PrefixLength uint32 `protobuf:"varint,5,opt,name=ipv6_prefix_length,json=ipv6PrefixLength,proto3" json:"ipv6_prefix_length,omitempty"` +} + +func (x *IpTupple) Reset() { + *x = IpTupple{} + if protoimpl.UnsafeEnabled { + mi := &file_lte_protos_oai_spgw_state_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IpTupple) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IpTupple) ProtoMessage() {} + +func (x *IpTupple) ProtoReflect() protoreflect.Message { + mi := &file_lte_protos_oai_spgw_state_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use IpTupple.ProtoReflect.Descriptor instead. +func (*IpTupple) Descriptor() ([]byte, []int) { + return file_lte_protos_oai_spgw_state_proto_rawDescGZIP(), []int{17} +} + +func (x *IpTupple) GetPdnType() uint32 { + if x != nil { + return x.PdnType + } + return 0 +} + +func (x *IpTupple) GetIpv4Addr() []byte { + if x != nil { + return x.Ipv4Addr + } + return nil +} + +func (x *IpTupple) GetIpv6Addr() []byte { + if x != nil { + return x.Ipv6Addr + } + return nil +} + +func (x *IpTupple) GetVlan() int32 { + if x != nil { + return x.Vlan + } + return 0 +} + +func (x *IpTupple) GetIpv6PrefixLength() uint32 { + if x != nil { + return x.Ipv6PrefixLength + } + return 0 +} + var File_lte_protos_oai_spgw_state_proto protoreflect.FileDescriptor var file_lte_protos_oai_spgw_state_proto_rawDesc = []byte{ @@ -1530,7 +1691,7 @@ var file_lte_protos_oai_spgw_state_proto_rawDesc = []byte{ 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x23, 0x6c, 0x74, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x6f, 0x61, 0x69, 0x2f, 0x73, 0x74, 0x64, 0x5f, 0x33, 0x67, 0x70, 0x70, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf0, 0x04, 0x0a, 0x17, 0x53, 0x67, 0x77, + 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbf, 0x05, 0x0a, 0x17, 0x53, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x6d, 0x73, 0x69, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x69, 0x6d, 0x73, 0x69, 0x12, 0x32, 0x0a, 0x15, 0x69, 0x6d, 0x73, 0x69, @@ -1547,287 +1708,340 @@ var file_lte_protos_oai_spgw_state_proto_rawDesc = []byte{ 0x73, 0x69, 0x36, 0x34, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x69, 0x6d, 0x73, 0x69, 0x36, 0x34, 0x12, 0x20, 0x0a, 0x0c, 0x6d, 0x6d, 0x65, 0x5f, 0x74, 0x65, 0x69, 0x64, 0x5f, 0x73, 0x31, 0x31, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6d, 0x6d, 0x65, 0x54, 0x65, 0x69, - 0x64, 0x53, 0x31, 0x31, 0x12, 0x2b, 0x0a, 0x12, 0x6d, 0x6d, 0x65, 0x5f, 0x69, 0x70, 0x5f, 0x61, + 0x64, 0x53, 0x31, 0x31, 0x12, 0x2f, 0x0a, 0x12, 0x6d, 0x6d, 0x65, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x31, 0x31, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x0f, 0x6d, 0x6d, 0x65, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x31, - 0x31, 0x12, 0x25, 0x0a, 0x0f, 0x73, 0x67, 0x77, 0x5f, 0x74, 0x65, 0x69, 0x64, 0x5f, 0x73, 0x31, - 0x31, 0x5f, 0x73, 0x34, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x73, 0x67, 0x77, 0x54, - 0x65, 0x69, 0x64, 0x53, 0x31, 0x31, 0x53, 0x34, 0x12, 0x30, 0x0a, 0x15, 0x73, 0x67, 0x77, 0x5f, - 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x31, 0x31, 0x5f, 0x73, - 0x34, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x11, 0x73, 0x67, 0x77, 0x49, 0x70, 0x41, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x31, 0x31, 0x53, 0x34, 0x12, 0x46, 0x0a, 0x0e, 0x70, 0x64, - 0x6e, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x14, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, - 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x50, 0x64, 0x6e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x70, 0x64, 0x6e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x48, 0x0a, 0x0d, 0x73, 0x61, 0x76, 0x65, 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6d, 0x61, 0x67, 0x6d, - 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0c, - 0x73, 0x61, 0x76, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x4d, 0x0a, 0x12, - 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x64, 0x75, 0x72, - 0x65, 0x73, 0x18, 0x16, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, - 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x67, 0x77, 0x43, 0x62, 0x72, 0x50, - 0x72, 0x6f, 0x63, 0x65, 0x64, 0x75, 0x72, 0x65, 0x52, 0x11, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, - 0x67, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x64, 0x75, 0x72, 0x65, 0x73, 0x22, 0xa4, 0x01, 0x0a, 0x0f, - 0x50, 0x67, 0x77, 0x43, 0x62, 0x72, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x64, 0x75, 0x72, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x74, 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x74, - 0x65, 0x69, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x73, 0x64, 0x66, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x05, 0x73, 0x64, 0x66, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x52, - 0x0a, 0x13, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, - 0x61, 0x72, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6d, 0x61, - 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x45, - 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, - 0x11, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, - 0x72, 0x73, 0x22, 0x34, 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x4e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x03, 0x6d, 0x63, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x6e, 0x63, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6d, 0x6e, 0x63, 0x22, 0x59, 0x0a, 0x08, 0x54, 0x69, 0x6d, 0x65, - 0x5a, 0x6f, 0x6e, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x7a, 0x6f, 0x6e, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x5a, 0x6f, 0x6e, - 0x65, 0x12, 0x30, 0x0a, 0x14, 0x64, 0x61, 0x79, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x73, 0x61, - 0x76, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x12, 0x64, 0x61, 0x79, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x53, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x54, - 0x69, 0x6d, 0x65, 0x22, 0xbe, 0x05, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x74, 0x72, 0x78, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x74, 0x72, 0x78, 0x6e, - 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, - 0x74, 0x65, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x6d, 0x73, 0x69, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x04, 0x69, 0x6d, 0x73, 0x69, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x73, 0x69, 0x73, - 0x64, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6d, 0x73, 0x69, 0x73, 0x64, 0x6e, - 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x65, 0x69, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6d, - 0x65, 0x69, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x6c, 0x69, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x03, 0x75, 0x6c, 0x69, 0x12, 0x46, 0x0a, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x5f, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, - 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x6e, 0x67, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x0e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x6e, 0x67, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x19, 0x0a, 0x08, - 0x72, 0x61, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, - 0x72, 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x64, 0x6e, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x70, 0x64, 0x6e, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x70, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x03, 0x61, 0x70, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x61, 0x61, 0x18, 0x0d, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x03, 0x70, 0x61, 0x61, 0x12, 0x27, 0x0a, 0x04, 0x61, 0x6d, 0x62, 0x72, 0x18, 0x0e, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, - 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x41, 0x6d, 0x62, 0x72, 0x52, 0x04, 0x61, 0x6d, 0x62, 0x72, 0x12, - 0x24, 0x0a, 0x03, 0x70, 0x63, 0x6f, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6d, - 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x63, 0x6f, - 0x52, 0x03, 0x70, 0x63, 0x6f, 0x12, 0x43, 0x0a, 0x13, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, - 0x66, 0x74, 0x65, 0x69, 0x64, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x63, 0x70, 0x18, 0x10, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, - 0x61, 0x69, 0x2e, 0x46, 0x74, 0x65, 0x69, 0x64, 0x52, 0x10, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, - 0x46, 0x74, 0x65, 0x69, 0x64, 0x46, 0x6f, 0x72, 0x43, 0x70, 0x12, 0x69, 0x0a, 0x1d, 0x62, 0x65, - 0x61, 0x72, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x73, 0x5f, 0x74, 0x6f, - 0x5f, 0x62, 0x65, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x14, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x27, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, - 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x54, - 0x6f, 0x42, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x19, 0x62, 0x65, 0x61, 0x72, - 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x73, 0x54, 0x6f, 0x42, 0x65, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x69, 0x70, - 0x18, 0x15, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, 0x70, 0x12, 0x39, - 0x0a, 0x0c, 0x75, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x7a, 0x6f, 0x6e, 0x65, 0x18, 0x16, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, - 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x5a, 0x6f, 0x6e, 0x65, 0x52, 0x0a, 0x75, - 0x65, 0x54, 0x69, 0x6d, 0x65, 0x5a, 0x6f, 0x6e, 0x65, 0x12, 0x39, 0x0a, 0x18, 0x63, 0x68, 0x61, - 0x72, 0x67, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74, 0x65, 0x72, 0x69, - 0x73, 0x74, 0x69, 0x63, 0x73, 0x18, 0x17, 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, 0x63, 0x68, 0x61, - 0x72, 0x67, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74, 0x65, 0x72, 0x69, 0x73, - 0x74, 0x69, 0x63, 0x73, 0x22, 0xbb, 0x01, 0x0a, 0x18, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, - 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x54, 0x6f, 0x42, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x12, 0x22, 0x0a, 0x0d, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x65, 0x70, 0x73, 0x42, 0x65, 0x61, - 0x72, 0x65, 0x72, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x03, 0x74, 0x66, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x42, 0x02, 0x18, 0x01, 0x52, 0x0f, 0x6d, 0x6d, 0x65, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x53, 0x31, 0x31, 0x12, 0x25, 0x0a, 0x0f, 0x73, 0x67, 0x77, 0x5f, 0x74, 0x65, 0x69, + 0x64, 0x5f, 0x73, 0x31, 0x31, 0x5f, 0x73, 0x34, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, + 0x73, 0x67, 0x77, 0x54, 0x65, 0x69, 0x64, 0x53, 0x31, 0x31, 0x53, 0x34, 0x12, 0x30, 0x0a, 0x15, + 0x73, 0x67, 0x77, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, + 0x31, 0x31, 0x5f, 0x73, 0x34, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x11, 0x73, 0x67, 0x77, + 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x31, 0x31, 0x53, 0x34, 0x12, 0x46, + 0x0a, 0x0e, 0x70, 0x64, 0x6e, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, + 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x50, 0x64, 0x6e, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x70, 0x64, 0x6e, 0x43, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x48, 0x0a, 0x0d, 0x73, 0x61, 0x76, 0x65, 0x64, 0x5f, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, + 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x52, 0x0c, 0x73, 0x61, 0x76, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x4d, 0x0a, 0x12, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x63, + 0x65, 0x64, 0x75, 0x72, 0x65, 0x73, 0x18, 0x16, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6d, + 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x67, 0x77, + 0x43, 0x62, 0x72, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x64, 0x75, 0x72, 0x65, 0x52, 0x11, 0x70, 0x65, + 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x64, 0x75, 0x72, 0x65, 0x73, 0x12, + 0x49, 0x0a, 0x15, 0x6d, 0x6d, 0x65, 0x5f, 0x63, 0x70, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x31, 0x31, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, + 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x49, + 0x70, 0x54, 0x75, 0x70, 0x70, 0x6c, 0x65, 0x52, 0x11, 0x6d, 0x6d, 0x65, 0x43, 0x70, 0x49, 0x70, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x31, 0x31, 0x22, 0xa4, 0x01, 0x0a, 0x0f, 0x50, + 0x67, 0x77, 0x43, 0x62, 0x72, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x64, 0x75, 0x72, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x74, 0x65, + 0x69, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x73, 0x64, 0x66, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x05, 0x73, 0x64, 0x66, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x52, 0x0a, + 0x13, 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x5f, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, + 0x72, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6d, 0x61, 0x67, + 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x45, 0x70, + 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x11, + 0x70, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, + 0x73, 0x22, 0x34, 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x03, 0x6d, 0x63, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x6e, 0x63, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x03, 0x6d, 0x6e, 0x63, 0x22, 0x59, 0x0a, 0x08, 0x54, 0x69, 0x6d, 0x65, 0x5a, + 0x6f, 0x6e, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x7a, 0x6f, 0x6e, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x74, 0x69, 0x6d, 0x65, 0x5a, 0x6f, 0x6e, 0x65, + 0x12, 0x30, 0x0a, 0x14, 0x64, 0x61, 0x79, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x5f, 0x73, 0x61, 0x76, + 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x12, + 0x64, 0x61, 0x79, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x53, 0x61, 0x76, 0x69, 0x6e, 0x67, 0x54, 0x69, + 0x6d, 0x65, 0x22, 0xf7, 0x05, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, + 0x72, 0x78, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x74, 0x72, 0x78, 0x6e, 0x12, + 0x12, 0x0a, 0x04, 0x74, 0x65, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x74, + 0x65, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x6d, 0x73, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x04, 0x69, 0x6d, 0x73, 0x69, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x73, 0x69, 0x73, 0x64, + 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x6d, 0x73, 0x69, 0x73, 0x64, 0x6e, 0x12, + 0x10, 0x0a, 0x03, 0x6d, 0x65, 0x69, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6d, 0x65, + 0x69, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x6c, 0x69, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, + 0x75, 0x6c, 0x69, 0x12, 0x46, 0x0a, 0x0f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x6e, 0x67, 0x5f, 0x6e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6d, + 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x6e, 0x67, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x0e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x6e, 0x67, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x19, 0x0a, 0x08, 0x72, + 0x61, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x72, + 0x61, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x64, 0x6e, 0x5f, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x70, 0x64, 0x6e, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x70, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, + 0x61, 0x70, 0x6e, 0x12, 0x14, 0x0a, 0x03, 0x70, 0x61, 0x61, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0c, + 0x42, 0x02, 0x18, 0x01, 0x52, 0x03, 0x70, 0x61, 0x61, 0x12, 0x27, 0x0a, 0x04, 0x61, 0x6d, 0x62, + 0x72, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, + 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x41, 0x6d, 0x62, 0x72, 0x52, 0x04, 0x61, 0x6d, + 0x62, 0x72, 0x12, 0x24, 0x0a, 0x03, 0x70, 0x63, 0x6f, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x12, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, + 0x50, 0x63, 0x6f, 0x52, 0x03, 0x70, 0x63, 0x6f, 0x12, 0x43, 0x0a, 0x13, 0x73, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x5f, 0x66, 0x74, 0x65, 0x69, 0x64, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x63, 0x70, 0x18, + 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, + 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x46, 0x74, 0x65, 0x69, 0x64, 0x52, 0x10, 0x73, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x46, 0x74, 0x65, 0x69, 0x64, 0x46, 0x6f, 0x72, 0x43, 0x70, 0x12, 0x69, 0x0a, + 0x1d, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x73, + 0x5f, 0x74, 0x6f, 0x5f, 0x62, 0x65, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x14, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, + 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, + 0x78, 0x74, 0x54, 0x6f, 0x42, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x52, 0x19, 0x62, + 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x73, 0x54, 0x6f, 0x42, + 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x65, 0x65, 0x72, + 0x5f, 0x69, 0x70, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x70, 0x65, 0x65, 0x72, 0x49, + 0x70, 0x12, 0x39, 0x0a, 0x0c, 0x75, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x7a, 0x6f, 0x6e, + 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, + 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x5a, 0x6f, 0x6e, 0x65, + 0x52, 0x0a, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x5a, 0x6f, 0x6e, 0x65, 0x12, 0x39, 0x0a, 0x18, + 0x63, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74, + 0x65, 0x72, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x18, 0x17, 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, + 0x63, 0x68, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74, 0x65, + 0x72, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x12, 0x33, 0x0a, 0x09, 0x75, 0x65, 0x5f, 0x69, 0x70, + 0x5f, 0x70, 0x61, 0x61, 0x18, 0x18, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x61, 0x67, + 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x49, 0x70, 0x54, 0x75, 0x70, + 0x70, 0x6c, 0x65, 0x52, 0x07, 0x75, 0x65, 0x49, 0x70, 0x50, 0x61, 0x61, 0x22, 0xbb, 0x01, 0x0a, + 0x18, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x54, 0x6f, + 0x42, 0x65, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x12, 0x22, 0x0a, 0x0d, 0x65, 0x70, 0x73, + 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x0b, 0x65, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x49, 0x64, 0x12, 0x34, 0x0a, + 0x03, 0x74, 0x66, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6d, 0x61, 0x67, + 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x54, 0x72, 0x61, 0x66, 0x66, + 0x69, 0x63, 0x46, 0x6c, 0x6f, 0x77, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x03, + 0x74, 0x66, 0x74, 0x12, 0x45, 0x0a, 0x10, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x6c, 0x65, + 0x76, 0x65, 0x6c, 0x5f, 0x71, 0x6f, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, + 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, + 0x77, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x51, 0x6f, 0x73, 0x52, 0x0e, 0x62, 0x65, 0x61, 0x72, + 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x51, 0x6f, 0x73, 0x22, 0x79, 0x0a, 0x17, 0x50, 0x67, + 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x6d, 0x73, 0x69, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x69, 0x6d, 0x73, 0x69, 0x12, 0x32, 0x0a, 0x15, 0x69, 0x6d, 0x73, + 0x69, 0x5f, 0x75, 0x6e, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x61, 0x74, + 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x13, 0x69, 0x6d, 0x73, 0x69, 0x55, 0x6e, + 0x61, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x64, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x16, 0x0a, + 0x06, 0x6d, 0x73, 0x69, 0x73, 0x64, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, + 0x73, 0x69, 0x73, 0x64, 0x6e, 0x22, 0x89, 0x04, 0x0a, 0x10, 0x53, 0x67, 0x77, 0x50, 0x64, 0x6e, + 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x0a, 0x61, 0x70, + 0x6e, 0x5f, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x61, 0x70, 0x6e, 0x49, 0x6e, 0x55, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x15, 0x70, 0x67, 0x77, 0x5f, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x5f, 0x63, + 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x11, 0x70, 0x67, 0x77, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x49, 0x6e, 0x55, 0x73, 0x65, 0x43, 0x70, 0x12, 0x30, 0x0a, 0x15, 0x70, 0x67, + 0x77, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, + 0x5f, 0x75, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x11, 0x70, 0x67, 0x77, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, 0x6e, 0x55, 0x73, 0x65, 0x55, 0x70, 0x12, 0x25, 0x0a, 0x0e, + 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42, 0x65, 0x61, + 0x72, 0x65, 0x72, 0x12, 0x3e, 0x0a, 0x1c, 0x75, 0x65, 0x5f, 0x73, 0x75, 0x73, 0x70, 0x65, 0x6e, + 0x64, 0x65, 0x64, 0x5f, 0x66, 0x6f, 0x72, 0x5f, 0x70, 0x73, 0x5f, 0x68, 0x61, 0x6e, 0x64, 0x6f, + 0x76, 0x65, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, 0x75, 0x65, 0x53, 0x75, 0x73, + 0x70, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x46, 0x6f, 0x72, 0x50, 0x73, 0x48, 0x61, 0x6e, 0x64, 0x6f, + 0x76, 0x65, 0x72, 0x12, 0x4e, 0x0a, 0x0f, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, + 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6d, + 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, + 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, + 0x42, 0x02, 0x18, 0x01, 0x52, 0x0d, 0x65, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x4c, + 0x69, 0x73, 0x74, 0x12, 0x57, 0x0a, 0x0e, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, + 0x72, 0x5f, 0x6d, 0x61, 0x70, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x6d, 0x61, + 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x50, + 0x64, 0x6e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x45, 0x70, 0x73, + 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, + 0x65, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x4d, 0x61, 0x70, 0x1a, 0x63, 0x0a, 0x11, + 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x38, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, + 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x22, 0xbd, 0x08, 0x0a, 0x13, 0x53, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, + 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x22, 0x0a, 0x0d, 0x65, 0x70, 0x73, + 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x0b, 0x65, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, + 0x03, 0x70, 0x61, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x02, 0x18, 0x01, 0x52, 0x03, + 0x70, 0x61, 0x61, 0x12, 0x34, 0x0a, 0x15, 0x70, 0x67, 0x77, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x5f, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x5f, 0x75, 0x70, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x0c, 0x42, 0x02, 0x18, 0x01, 0x52, 0x11, 0x70, 0x67, 0x77, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x49, 0x6e, 0x55, 0x73, 0x65, 0x55, 0x70, 0x12, 0x28, 0x0a, 0x11, 0x70, 0x67, 0x77, + 0x5f, 0x74, 0x65, 0x69, 0x64, 0x5f, 0x73, 0x35, 0x5f, 0x73, 0x38, 0x5f, 0x75, 0x70, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x67, 0x77, 0x54, 0x65, 0x69, 0x64, 0x53, 0x35, 0x53, + 0x38, 0x55, 0x70, 0x12, 0x33, 0x0a, 0x17, 0x73, 0x67, 0x77, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x35, 0x5f, 0x73, 0x38, 0x5f, 0x75, 0x70, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x12, 0x73, 0x67, 0x77, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x53, 0x35, 0x53, 0x38, 0x55, 0x70, 0x12, 0x28, 0x0a, 0x11, 0x73, 0x67, 0x77, 0x5f, + 0x74, 0x65, 0x69, 0x64, 0x5f, 0x73, 0x35, 0x5f, 0x73, 0x38, 0x5f, 0x75, 0x70, 0x18, 0x0d, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x73, 0x67, 0x77, 0x54, 0x65, 0x69, 0x64, 0x53, 0x35, 0x53, 0x38, + 0x55, 0x70, 0x12, 0x3c, 0x0a, 0x1c, 0x73, 0x67, 0x77, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x31, 0x75, 0x5f, 0x73, 0x31, 0x32, 0x5f, 0x73, 0x34, 0x5f, + 0x75, 0x70, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x16, 0x73, 0x67, 0x77, 0x49, 0x70, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x31, 0x75, 0x53, 0x31, 0x32, 0x53, 0x34, 0x55, 0x70, + 0x12, 0x31, 0x0a, 0x16, 0x73, 0x67, 0x77, 0x5f, 0x74, 0x65, 0x69, 0x64, 0x5f, 0x73, 0x31, 0x75, + 0x5f, 0x73, 0x31, 0x32, 0x5f, 0x73, 0x34, 0x5f, 0x75, 0x70, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x11, 0x73, 0x67, 0x77, 0x54, 0x65, 0x69, 0x64, 0x53, 0x31, 0x75, 0x53, 0x31, 0x32, 0x53, + 0x34, 0x55, 0x70, 0x12, 0x2b, 0x0a, 0x12, 0x65, 0x6e, 0x62, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x31, 0x75, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0f, 0x65, 0x6e, 0x62, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x31, 0x75, + 0x12, 0x20, 0x0a, 0x0c, 0x65, 0x6e, 0x62, 0x5f, 0x74, 0x65, 0x69, 0x64, 0x5f, 0x73, 0x31, 0x75, + 0x18, 0x11, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x65, 0x6e, 0x62, 0x54, 0x65, 0x69, 0x64, 0x53, + 0x31, 0x75, 0x12, 0x41, 0x0a, 0x0e, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, + 0x5f, 0x71, 0x6f, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, 0x67, + 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x42, 0x65, + 0x61, 0x72, 0x65, 0x72, 0x51, 0x6f, 0x73, 0x52, 0x0c, 0x65, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, + 0x65, 0x72, 0x51, 0x6f, 0x73, 0x12, 0x34, 0x0a, 0x03, 0x74, 0x66, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x46, 0x6c, 0x6f, 0x77, 0x54, 0x65, - 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x03, 0x74, 0x66, 0x74, 0x12, 0x45, 0x0a, 0x10, 0x62, - 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x5f, 0x71, 0x6f, 0x73, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, - 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x51, - 0x6f, 0x73, 0x52, 0x0e, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x51, - 0x6f, 0x73, 0x22, 0x79, 0x0a, 0x17, 0x50, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, - 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, - 0x04, 0x69, 0x6d, 0x73, 0x69, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x69, 0x6d, 0x73, - 0x69, 0x12, 0x32, 0x0a, 0x15, 0x69, 0x6d, 0x73, 0x69, 0x5f, 0x75, 0x6e, 0x61, 0x75, 0x74, 0x68, - 0x5f, 0x69, 0x6e, 0x64, 0x69, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x13, 0x69, 0x6d, 0x73, 0x69, 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68, 0x49, 0x6e, 0x64, 0x69, - 0x63, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x73, 0x69, 0x73, 0x64, 0x6e, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x73, 0x69, 0x73, 0x64, 0x6e, 0x22, 0xc7, 0x02, - 0x0a, 0x10, 0x53, 0x67, 0x77, 0x50, 0x64, 0x6e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x0a, 0x61, 0x70, 0x6e, 0x5f, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x61, 0x70, 0x6e, 0x49, 0x6e, 0x55, 0x73, 0x65, - 0x12, 0x30, 0x0a, 0x15, 0x70, 0x67, 0x77, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, - 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x5f, 0x63, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x11, 0x70, 0x67, 0x77, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, 0x6e, 0x55, 0x73, 0x65, - 0x43, 0x70, 0x12, 0x30, 0x0a, 0x15, 0x70, 0x67, 0x77, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x5f, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x5f, 0x75, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x11, 0x70, 0x67, 0x77, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x49, 0x6e, 0x55, - 0x73, 0x65, 0x55, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, - 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x64, 0x65, - 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x12, 0x3e, 0x0a, 0x1c, 0x75, - 0x65, 0x5f, 0x73, 0x75, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x5f, 0x66, 0x6f, 0x72, 0x5f, - 0x70, 0x73, 0x5f, 0x68, 0x61, 0x6e, 0x64, 0x6f, 0x76, 0x65, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x18, 0x75, 0x65, 0x53, 0x75, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x64, 0x46, 0x6f, - 0x72, 0x50, 0x73, 0x48, 0x61, 0x6e, 0x64, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x4a, 0x0a, 0x0f, 0x65, - 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x0f, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, - 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, - 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x0d, 0x65, 0x70, 0x73, 0x42, 0x65, 0x61, - 0x72, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xdd, 0x05, 0x0a, 0x13, 0x53, 0x67, 0x77, 0x45, - 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, - 0x22, 0x0a, 0x0d, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x65, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x61, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x03, 0x70, 0x61, 0x61, 0x12, 0x30, 0x0a, 0x15, 0x70, 0x67, 0x77, 0x5f, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x5f, 0x75, 0x70, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x11, 0x70, 0x67, 0x77, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x49, 0x6e, 0x55, 0x73, 0x65, 0x55, 0x70, 0x12, 0x28, 0x0a, 0x11, 0x70, 0x67, 0x77, 0x5f, 0x74, - 0x65, 0x69, 0x64, 0x5f, 0x73, 0x35, 0x5f, 0x73, 0x38, 0x5f, 0x75, 0x70, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x67, 0x77, 0x54, 0x65, 0x69, 0x64, 0x53, 0x35, 0x53, 0x38, 0x55, - 0x70, 0x12, 0x33, 0x0a, 0x17, 0x73, 0x67, 0x77, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x5f, 0x73, 0x35, 0x5f, 0x73, 0x38, 0x5f, 0x75, 0x70, 0x18, 0x0c, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x12, 0x73, 0x67, 0x77, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x53, 0x35, 0x53, 0x38, 0x55, 0x70, 0x12, 0x28, 0x0a, 0x11, 0x73, 0x67, 0x77, 0x5f, 0x74, 0x65, - 0x69, 0x64, 0x5f, 0x73, 0x35, 0x5f, 0x73, 0x38, 0x5f, 0x75, 0x70, 0x18, 0x0d, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x0d, 0x73, 0x67, 0x77, 0x54, 0x65, 0x69, 0x64, 0x53, 0x35, 0x53, 0x38, 0x55, 0x70, - 0x12, 0x3c, 0x0a, 0x1c, 0x73, 0x67, 0x77, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x5f, 0x73, 0x31, 0x75, 0x5f, 0x73, 0x31, 0x32, 0x5f, 0x73, 0x34, 0x5f, 0x75, 0x70, - 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x16, 0x73, 0x67, 0x77, 0x49, 0x70, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x53, 0x31, 0x75, 0x53, 0x31, 0x32, 0x53, 0x34, 0x55, 0x70, 0x12, 0x31, - 0x0a, 0x16, 0x73, 0x67, 0x77, 0x5f, 0x74, 0x65, 0x69, 0x64, 0x5f, 0x73, 0x31, 0x75, 0x5f, 0x73, - 0x31, 0x32, 0x5f, 0x73, 0x34, 0x5f, 0x75, 0x70, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, - 0x73, 0x67, 0x77, 0x54, 0x65, 0x69, 0x64, 0x53, 0x31, 0x75, 0x53, 0x31, 0x32, 0x53, 0x34, 0x55, - 0x70, 0x12, 0x2b, 0x0a, 0x12, 0x65, 0x6e, 0x62, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x5f, 0x73, 0x31, 0x75, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x65, - 0x6e, 0x62, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x31, 0x75, 0x12, 0x20, - 0x0a, 0x0c, 0x65, 0x6e, 0x62, 0x5f, 0x74, 0x65, 0x69, 0x64, 0x5f, 0x73, 0x31, 0x75, 0x18, 0x11, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x65, 0x6e, 0x62, 0x54, 0x65, 0x69, 0x64, 0x53, 0x31, 0x75, - 0x12, 0x41, 0x0a, 0x0e, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x71, - 0x6f, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, - 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x42, 0x65, 0x61, 0x72, - 0x65, 0x72, 0x51, 0x6f, 0x73, 0x52, 0x0c, 0x65, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, - 0x51, 0x6f, 0x73, 0x12, 0x34, 0x0a, 0x03, 0x74, 0x66, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x22, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, - 0x2e, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x46, 0x6c, 0x6f, 0x77, 0x54, 0x65, 0x6d, 0x70, - 0x6c, 0x61, 0x74, 0x65, 0x52, 0x03, 0x74, 0x66, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, 0x75, 0x6d, - 0x5f, 0x73, 0x64, 0x66, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x53, - 0x64, 0x66, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x64, 0x66, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x1a, 0x20, - 0x03, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x64, 0x66, 0x49, 0x64, 0x73, 0x12, 0x28, 0x0a, 0x10, 0x70, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x1b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x75, 0x6c, - 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x1e, 0x73, 0x67, 0x77, 0x5f, 0x69, 0x70, 0x76, - 0x36, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x31, 0x75, 0x5f, 0x73, 0x31, - 0x32, 0x5f, 0x73, 0x34, 0x5f, 0x75, 0x70, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x18, 0x73, - 0x67, 0x77, 0x49, 0x70, 0x76, 0x36, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x31, 0x75, - 0x53, 0x31, 0x32, 0x53, 0x34, 0x55, 0x70, 0x22, 0xa7, 0x02, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x66, - 0x66, 0x69, 0x63, 0x46, 0x6c, 0x6f, 0x77, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, - 0x4d, 0x0a, 0x12, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, - 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6d, 0x61, - 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x61, 0x63, 0x6b, - 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x10, 0x70, 0x61, - 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x46, - 0x0a, 0x0f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x5f, 0x6c, 0x69, 0x73, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, - 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, - 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x0e, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, - 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x74, 0x66, 0x74, 0x5f, 0x6f, 0x70, - 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x10, 0x74, 0x66, 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x43, 0x6f, 0x64, 0x65, 0x12, 0x37, 0x0a, 0x18, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, - 0x66, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x15, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, - 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x12, 0x12, 0x0a, - 0x04, 0x65, 0x62, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x65, 0x62, 0x69, - 0x74, 0x22, 0xb6, 0x02, 0x0a, 0x10, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, - 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x41, 0x0a, 0x0e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x5f, 0x6e, 0x65, 0x77, 0x5f, 0x74, 0x66, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, + 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x52, 0x03, 0x74, 0x66, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6e, + 0x75, 0x6d, 0x5f, 0x73, 0x64, 0x66, 0x18, 0x19, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6e, 0x75, + 0x6d, 0x53, 0x64, 0x66, 0x12, 0x17, 0x0a, 0x07, 0x73, 0x64, 0x66, 0x5f, 0x69, 0x64, 0x73, 0x18, + 0x1a, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x06, 0x73, 0x64, 0x66, 0x49, 0x64, 0x73, 0x12, 0x28, 0x0a, + 0x10, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, + 0x75, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x40, 0x0a, 0x1e, 0x73, 0x67, 0x77, 0x5f, 0x69, + 0x70, 0x76, 0x36, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x31, 0x75, 0x5f, + 0x73, 0x31, 0x32, 0x5f, 0x73, 0x34, 0x5f, 0x75, 0x70, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x18, 0x73, 0x67, 0x77, 0x49, 0x70, 0x76, 0x36, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, + 0x31, 0x75, 0x53, 0x31, 0x32, 0x53, 0x34, 0x55, 0x70, 0x12, 0x3e, 0x0a, 0x0f, 0x65, 0x6e, 0x62, + 0x5f, 0x73, 0x31, 0x75, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x1d, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, + 0x61, 0x69, 0x2e, 0x49, 0x70, 0x54, 0x75, 0x70, 0x70, 0x6c, 0x65, 0x52, 0x0c, 0x65, 0x6e, 0x62, + 0x53, 0x31, 0x75, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x12, 0x33, 0x0a, 0x09, 0x75, 0x65, 0x5f, + 0x69, 0x70, 0x5f, 0x70, 0x61, 0x61, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, + 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x49, 0x70, 0x54, + 0x75, 0x70, 0x70, 0x6c, 0x65, 0x52, 0x07, 0x75, 0x65, 0x49, 0x70, 0x50, 0x61, 0x61, 0x12, 0x3d, + 0x0a, 0x0e, 0x70, 0x67, 0x77, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x75, 0x70, + 0x18, 0x1f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, + 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x49, 0x70, 0x54, 0x75, 0x70, 0x70, 0x6c, 0x65, 0x52, + 0x0c, 0x70, 0x67, 0x77, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x55, 0x70, 0x12, 0x4f, 0x0a, + 0x19, 0x73, 0x67, 0x77, 0x5f, 0x73, 0x31, 0x75, 0x5f, 0x73, 0x31, 0x32, 0x5f, 0x73, 0x34, 0x5f, + 0x75, 0x70, 0x5f, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x17, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, + 0x2e, 0x49, 0x70, 0x54, 0x75, 0x70, 0x70, 0x6c, 0x65, 0x52, 0x13, 0x73, 0x67, 0x77, 0x53, 0x31, + 0x75, 0x53, 0x31, 0x32, 0x53, 0x34, 0x55, 0x70, 0x49, 0x70, 0x41, 0x64, 0x64, 0x72, 0x12, 0x2e, + 0x0a, 0x13, 0x73, 0x67, 0x77, 0x5f, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x6e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x21, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x73, 0x67, 0x77, + 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x21, + 0x0a, 0x0c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x65, 0x69, 0x64, 0x73, 0x18, 0x22, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x65, 0x69, 0x64, + 0x73, 0x22, 0xa7, 0x02, 0x0a, 0x13, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x46, 0x6c, 0x6f, + 0x77, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x12, 0x4d, 0x0a, 0x12, 0x70, 0x61, 0x63, + 0x6b, 0x65, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, + 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, + 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x10, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, + 0x6c, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x46, 0x0a, 0x0f, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1d, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, + 0x69, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x0e, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x73, 0x74, + 0x12, 0x2c, 0x0a, 0x12, 0x74, 0x66, 0x74, 0x5f, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x10, 0x74, 0x66, + 0x74, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x37, + 0x0a, 0x18, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x63, 0x6b, + 0x65, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x15, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x4f, 0x66, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, + 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x65, 0x62, 0x69, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x65, 0x62, 0x69, 0x74, 0x22, 0xb6, 0x02, 0x0a, 0x10, + 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, + 0x12, 0x41, 0x0a, 0x0e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x6e, 0x65, 0x77, 0x5f, 0x74, + 0x66, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, + 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0c, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x65, 0x77, + 0x54, 0x66, 0x74, 0x12, 0x47, 0x0a, 0x11, 0x61, 0x64, 0x64, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, - 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0c, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x4e, 0x65, 0x77, 0x54, 0x66, 0x74, 0x12, 0x47, 0x0a, 0x11, 0x61, 0x64, 0x64, - 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, - 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, - 0x72, 0x52, 0x0f, 0x61, 0x64, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, - 0x65, 0x72, 0x12, 0x4f, 0x0a, 0x15, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x5f, 0x70, 0x61, - 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, - 0x69, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x13, - 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, - 0x74, 0x65, 0x72, 0x12, 0x45, 0x0a, 0x1f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x5f, 0x70, 0x61, - 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x1c, 0x64, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, - 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x22, 0xfe, 0x01, 0x0a, 0x0c, 0x50, - 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x73, - 0x70, 0x61, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x73, 0x70, 0x61, 0x72, - 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, - 0x27, 0x0a, 0x0f, 0x65, 0x76, 0x61, 0x6c, 0x5f, 0x70, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, - 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0e, 0x65, 0x76, 0x61, 0x6c, 0x50, 0x72, - 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, - 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, - 0x12, 0x59, 0x0a, 0x16, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, - 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x23, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, - 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x14, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, - 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xa2, 0x01, 0x0a, 0x0c, - 0x53, 0x67, 0x77, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x51, 0x6f, 0x73, 0x12, 0x10, 0x0a, 0x03, - 0x70, 0x63, 0x69, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x70, 0x63, 0x69, 0x12, 0x0e, - 0x0a, 0x02, 0x70, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x70, 0x6c, 0x12, 0x10, - 0x0a, 0x03, 0x70, 0x76, 0x69, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x70, 0x76, 0x69, - 0x12, 0x10, 0x0a, 0x03, 0x71, 0x63, 0x69, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x71, - 0x63, 0x69, 0x12, 0x25, 0x0a, 0x03, 0x67, 0x62, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x13, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, - 0x41, 0x6d, 0x62, 0x72, 0x52, 0x03, 0x67, 0x62, 0x72, 0x12, 0x25, 0x0a, 0x03, 0x6d, 0x62, 0x72, - 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, - 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x41, 0x6d, 0x62, 0x72, 0x52, 0x03, 0x6d, 0x62, 0x72, - 0x22, 0x5e, 0x0a, 0x0d, 0x53, 0x70, 0x67, 0x77, 0x55, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, - 0x74, 0x12, 0x4d, 0x0a, 0x12, 0x73, 0x31, 0x31, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, - 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x31, - 0x31, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x10, - 0x73, 0x31, 0x31, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, - 0x22, 0xcc, 0x01, 0x0a, 0x10, 0x53, 0x31, 0x31, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, - 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x5b, 0x0a, 0x16, 0x73, 0x67, 0x77, 0x5f, 0x65, 0x70, 0x73, - 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, - 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, - 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x13, 0x73, - 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x74, 0x12, 0x5b, 0x0a, 0x16, 0x70, 0x67, 0x77, 0x5f, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, - 0x61, 0x72, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, - 0x61, 0x69, 0x2e, 0x50, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, - 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x13, 0x70, 0x67, 0x77, 0x45, - 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, - 0x9f, 0x01, 0x0a, 0x0a, 0x47, 0x54, 0x50, 0x56, 0x31, 0x75, 0x44, 0x61, 0x74, 0x61, 0x12, 0x21, - 0x0a, 0x0a, 0x69, 0x70, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x69, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x12, 0x1b, 0x0a, 0x07, 0x73, 0x65, 0x71, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x06, 0x73, 0x65, 0x71, 0x4e, 0x75, 0x6d, 0x12, 0x2b, - 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, - 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x72, 0x65, 0x73, - 0x74, 0x61, 0x72, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x66, - 0x64, 0x30, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x66, 0x64, 0x30, 0x12, 0x12, 0x0a, - 0x04, 0x66, 0x64, 0x31, 0x75, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x66, 0x64, 0x31, - 0x75, 0x22, 0xbe, 0x01, 0x0a, 0x09, 0x53, 0x70, 0x67, 0x77, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, - 0x1f, 0x0a, 0x0b, 0x67, 0x74, 0x70, 0x76, 0x31, 0x75, 0x5f, 0x74, 0x65, 0x69, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x67, 0x74, 0x70, 0x76, 0x31, 0x75, 0x54, 0x65, 0x69, 0x64, - 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x70, 0x76, 0x34, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x66, 0x72, - 0x65, 0x65, 0x18, 0x05, 0x20, 0x03, 0x28, 0x04, 0x52, 0x0c, 0x69, 0x70, 0x76, 0x34, 0x4c, 0x69, - 0x73, 0x74, 0x46, 0x72, 0x65, 0x65, 0x12, 0x2e, 0x0a, 0x13, 0x69, 0x70, 0x76, 0x34, 0x5f, 0x6c, - 0x69, 0x73, 0x74, 0x5f, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x06, 0x20, - 0x03, 0x28, 0x04, 0x52, 0x11, 0x69, 0x70, 0x76, 0x34, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, - 0x6f, 0x63, 0x61, 0x74, 0x65, 0x64, 0x12, 0x3a, 0x0a, 0x0b, 0x67, 0x74, 0x70, 0x76, 0x31, 0x75, - 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x61, - 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x47, 0x54, 0x50, 0x56, - 0x31, 0x75, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0a, 0x67, 0x74, 0x70, 0x76, 0x31, 0x75, 0x44, 0x61, - 0x74, 0x61, 0x42, 0x1f, 0x5a, 0x1d, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2f, 0x6c, 0x74, 0x65, 0x2f, - 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, - 0x6f, 0x61, 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x0f, 0x61, 0x64, 0x64, + 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x4f, 0x0a, 0x15, + 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x6d, 0x61, + 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x61, 0x63, 0x6b, + 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x52, 0x13, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, + 0x65, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x45, 0x0a, + 0x1f, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, + 0x18, 0x04, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x1c, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x61, + 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x66, 0x69, 0x65, 0x72, 0x22, 0xfe, 0x01, 0x0a, 0x0c, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, + 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x70, 0x61, 0x72, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x73, 0x70, 0x61, 0x72, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x64, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, + 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x64, 0x65, + 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x69, + 0x64, 0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x65, 0x76, 0x61, + 0x6c, 0x5f, 0x70, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x0e, 0x65, 0x76, 0x61, 0x6c, 0x50, 0x72, 0x65, 0x63, 0x65, 0x64, 0x65, 0x6e, + 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x59, 0x0a, 0x16, 0x70, 0x61, + 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6d, 0x61, 0x67, + 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x61, 0x63, 0x6b, 0x65, + 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x52, + 0x14, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xa2, 0x01, 0x0a, 0x0c, 0x53, 0x67, 0x77, 0x42, 0x65, 0x61, + 0x72, 0x65, 0x72, 0x51, 0x6f, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x63, 0x69, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x03, 0x70, 0x63, 0x69, 0x12, 0x0e, 0x0a, 0x02, 0x70, 0x6c, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x70, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x76, 0x69, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x70, 0x76, 0x69, 0x12, 0x10, 0x0a, 0x03, 0x71, 0x63, + 0x69, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x71, 0x63, 0x69, 0x12, 0x25, 0x0a, 0x03, + 0x67, 0x62, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6d, 0x61, 0x67, 0x6d, + 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x41, 0x6d, 0x62, 0x72, 0x52, 0x03, + 0x67, 0x62, 0x72, 0x12, 0x25, 0x0a, 0x03, 0x6d, 0x62, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x13, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, + 0x2e, 0x41, 0x6d, 0x62, 0x72, 0x52, 0x03, 0x6d, 0x62, 0x72, 0x22, 0x5e, 0x0a, 0x0d, 0x53, 0x70, + 0x67, 0x77, 0x55, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x4d, 0x0a, 0x12, 0x73, + 0x31, 0x31, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, + 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, + 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x53, 0x31, 0x31, 0x42, 0x65, 0x61, 0x72, 0x65, + 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x10, 0x73, 0x31, 0x31, 0x42, 0x65, 0x61, + 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0xcc, 0x01, 0x0a, 0x10, 0x53, + 0x31, 0x31, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, + 0x5b, 0x0a, 0x16, 0x73, 0x67, 0x77, 0x5f, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, + 0x72, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x26, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, + 0x53, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x78, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x13, 0x73, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, + 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x5b, 0x0a, 0x16, + 0x70, 0x67, 0x77, 0x5f, 0x65, 0x70, 0x73, 0x5f, 0x62, 0x65, 0x61, 0x72, 0x65, 0x72, 0x5f, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6d, + 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x50, 0x67, 0x77, + 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, + 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x13, 0x70, 0x67, 0x77, 0x45, 0x70, 0x73, 0x42, 0x65, 0x61, 0x72, + 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x9f, 0x01, 0x0a, 0x0a, 0x47, 0x54, + 0x50, 0x56, 0x31, 0x75, 0x44, 0x61, 0x74, 0x61, 0x12, 0x21, 0x0a, 0x0a, 0x69, 0x70, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x02, 0x18, 0x01, + 0x52, 0x09, 0x69, 0x70, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x07, 0x73, + 0x65, 0x71, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, + 0x52, 0x06, 0x73, 0x65, 0x71, 0x4e, 0x75, 0x6d, 0x12, 0x2b, 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x74, + 0x61, 0x72, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, 0x72, 0x65, 0x73, 0x74, 0x61, 0x72, 0x74, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x64, 0x30, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x03, 0x66, 0x64, 0x30, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x64, 0x31, 0x75, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x66, 0x64, 0x31, 0x75, 0x22, 0xbe, 0x01, 0x0a, 0x09, + 0x53, 0x70, 0x67, 0x77, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x67, 0x74, 0x70, + 0x76, 0x31, 0x75, 0x5f, 0x74, 0x65, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, + 0x67, 0x74, 0x70, 0x76, 0x31, 0x75, 0x54, 0x65, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0e, 0x69, 0x70, + 0x76, 0x34, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x66, 0x72, 0x65, 0x65, 0x18, 0x05, 0x20, 0x03, + 0x28, 0x04, 0x52, 0x0c, 0x69, 0x70, 0x76, 0x34, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x65, 0x65, + 0x12, 0x2e, 0x0a, 0x13, 0x69, 0x70, 0x76, 0x34, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x61, 0x6c, + 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x06, 0x20, 0x03, 0x28, 0x04, 0x52, 0x11, 0x69, + 0x70, 0x76, 0x34, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x65, 0x64, + 0x12, 0x3a, 0x0a, 0x0b, 0x67, 0x74, 0x70, 0x76, 0x31, 0x75, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2e, 0x6c, 0x74, + 0x65, 0x2e, 0x6f, 0x61, 0x69, 0x2e, 0x47, 0x54, 0x50, 0x56, 0x31, 0x75, 0x44, 0x61, 0x74, 0x61, + 0x52, 0x0a, 0x67, 0x74, 0x70, 0x76, 0x31, 0x75, 0x44, 0x61, 0x74, 0x61, 0x22, 0xa1, 0x01, 0x0a, + 0x08, 0x49, 0x70, 0x54, 0x75, 0x70, 0x70, 0x6c, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x64, 0x6e, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x70, 0x64, 0x6e, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x70, 0x76, 0x34, 0x5f, 0x61, 0x64, 0x64, + 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x69, 0x70, 0x76, 0x34, 0x41, 0x64, 0x64, + 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x70, 0x76, 0x36, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x69, 0x70, 0x76, 0x36, 0x41, 0x64, 0x64, 0x72, 0x12, 0x12, + 0x0a, 0x04, 0x76, 0x6c, 0x61, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x76, 0x6c, + 0x61, 0x6e, 0x12, 0x2c, 0x0a, 0x12, 0x69, 0x70, 0x76, 0x36, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, + 0x78, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x10, + 0x69, 0x70, 0x76, 0x36, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x42, 0x1f, 0x5a, 0x1d, 0x6d, 0x61, 0x67, 0x6d, 0x61, 0x2f, 0x6c, 0x74, 0x65, 0x2f, 0x63, 0x6c, + 0x6f, 0x75, 0x64, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x6f, 0x61, + 0x69, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1842,7 +2056,7 @@ func file_lte_protos_oai_spgw_state_proto_rawDescGZIP() []byte { return file_lte_protos_oai_spgw_state_proto_rawDescData } -var file_lte_protos_oai_spgw_state_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_lte_protos_oai_spgw_state_proto_msgTypes = make([]protoimpl.MessageInfo, 19) var file_lte_protos_oai_spgw_state_proto_goTypes = []interface{}{ (*SgwEpsBearerContextInfo)(nil), // 0: magma.lte.oai.SgwEpsBearerContextInfo (*PgwCbrProcedure)(nil), // 1: magma.lte.oai.PgwCbrProcedure @@ -1861,47 +2075,57 @@ var file_lte_protos_oai_spgw_state_proto_goTypes = []interface{}{ (*S11BearerContext)(nil), // 14: magma.lte.oai.S11BearerContext (*GTPV1UData)(nil), // 15: magma.lte.oai.GTPV1uData (*SpgwState)(nil), // 16: magma.lte.oai.SpgwState - (*Ecgi)(nil), // 17: magma.lte.oai.Ecgi - (*Ambr)(nil), // 18: magma.lte.oai.Ambr - (*Pco)(nil), // 19: magma.lte.oai.Pco - (*Fteid)(nil), // 20: magma.lte.oai.Fteid - (*ParametersList)(nil), // 21: magma.lte.oai.ParametersList - (*PacketFilterContents)(nil), // 22: magma.lte.oai.PacketFilterContents + (*IpTupple)(nil), // 17: magma.lte.oai.IpTupple + nil, // 18: magma.lte.oai.SgwPdnConnection.EpsBearerMapEntry + (*Ecgi)(nil), // 19: magma.lte.oai.Ecgi + (*Ambr)(nil), // 20: magma.lte.oai.Ambr + (*Pco)(nil), // 21: magma.lte.oai.Pco + (*Fteid)(nil), // 22: magma.lte.oai.Fteid + (*ParametersList)(nil), // 23: magma.lte.oai.ParametersList + (*PacketFilterContents)(nil), // 24: magma.lte.oai.PacketFilterContents } var file_lte_protos_oai_spgw_state_proto_depIdxs = []int32{ - 17, // 0: magma.lte.oai.SgwEpsBearerContextInfo.last_known_cell_id:type_name -> magma.lte.oai.Ecgi + 19, // 0: magma.lte.oai.SgwEpsBearerContextInfo.last_known_cell_id:type_name -> magma.lte.oai.Ecgi 7, // 1: magma.lte.oai.SgwEpsBearerContextInfo.pdn_connection:type_name -> magma.lte.oai.SgwPdnConnection 4, // 2: magma.lte.oai.SgwEpsBearerContextInfo.saved_message:type_name -> magma.lte.oai.CreateSessionMessage 1, // 3: magma.lte.oai.SgwEpsBearerContextInfo.pending_procedures:type_name -> magma.lte.oai.PgwCbrProcedure - 8, // 4: magma.lte.oai.PgwCbrProcedure.pending_eps_bearers:type_name -> magma.lte.oai.SgwEpsBearerContext - 2, // 5: magma.lte.oai.CreateSessionMessage.serving_network:type_name -> magma.lte.oai.ServingNetwork - 18, // 6: magma.lte.oai.CreateSessionMessage.ambr:type_name -> magma.lte.oai.Ambr - 19, // 7: magma.lte.oai.CreateSessionMessage.pco:type_name -> magma.lte.oai.Pco - 20, // 8: magma.lte.oai.CreateSessionMessage.sender_fteid_for_cp:type_name -> magma.lte.oai.Fteid - 5, // 9: magma.lte.oai.CreateSessionMessage.bearer_contexts_to_be_created:type_name -> magma.lte.oai.BearerContextToBeCreated - 3, // 10: magma.lte.oai.CreateSessionMessage.ue_time_zone:type_name -> magma.lte.oai.TimeZone - 9, // 11: magma.lte.oai.BearerContextToBeCreated.tft:type_name -> magma.lte.oai.TrafficFlowTemplate - 12, // 12: magma.lte.oai.BearerContextToBeCreated.bearer_level_qos:type_name -> magma.lte.oai.SgwBearerQos - 8, // 13: magma.lte.oai.SgwPdnConnection.eps_bearer_list:type_name -> magma.lte.oai.SgwEpsBearerContext - 12, // 14: magma.lte.oai.SgwEpsBearerContext.eps_bearer_qos:type_name -> magma.lte.oai.SgwBearerQos - 9, // 15: magma.lte.oai.SgwEpsBearerContext.tft:type_name -> magma.lte.oai.TrafficFlowTemplate - 10, // 16: magma.lte.oai.TrafficFlowTemplate.packet_filter_list:type_name -> magma.lte.oai.PacketFilterList - 21, // 17: magma.lte.oai.TrafficFlowTemplate.parameters_list:type_name -> magma.lte.oai.ParametersList - 11, // 18: magma.lte.oai.PacketFilterList.create_new_tft:type_name -> magma.lte.oai.PacketFilter - 11, // 19: magma.lte.oai.PacketFilterList.add_packet_filter:type_name -> magma.lte.oai.PacketFilter - 11, // 20: magma.lte.oai.PacketFilterList.replace_packet_filter:type_name -> magma.lte.oai.PacketFilter - 22, // 21: magma.lte.oai.PacketFilter.packet_filter_contents:type_name -> magma.lte.oai.PacketFilterContents - 18, // 22: magma.lte.oai.SgwBearerQos.gbr:type_name -> magma.lte.oai.Ambr - 18, // 23: magma.lte.oai.SgwBearerQos.mbr:type_name -> magma.lte.oai.Ambr - 14, // 24: magma.lte.oai.SpgwUeContext.s11_bearer_context:type_name -> magma.lte.oai.S11BearerContext - 0, // 25: magma.lte.oai.S11BearerContext.sgw_eps_bearer_context:type_name -> magma.lte.oai.SgwEpsBearerContextInfo - 6, // 26: magma.lte.oai.S11BearerContext.pgw_eps_bearer_context:type_name -> magma.lte.oai.PgwEpsBearerContextInfo - 15, // 27: magma.lte.oai.SpgwState.gtpv1u_data:type_name -> magma.lte.oai.GTPV1uData - 28, // [28:28] is the sub-list for method output_type - 28, // [28:28] is the sub-list for method input_type - 28, // [28:28] is the sub-list for extension type_name - 28, // [28:28] is the sub-list for extension extendee - 0, // [0:28] is the sub-list for field type_name + 17, // 4: magma.lte.oai.SgwEpsBearerContextInfo.mme_cp_ip_address_s11:type_name -> magma.lte.oai.IpTupple + 8, // 5: magma.lte.oai.PgwCbrProcedure.pending_eps_bearers:type_name -> magma.lte.oai.SgwEpsBearerContext + 2, // 6: magma.lte.oai.CreateSessionMessage.serving_network:type_name -> magma.lte.oai.ServingNetwork + 20, // 7: magma.lte.oai.CreateSessionMessage.ambr:type_name -> magma.lte.oai.Ambr + 21, // 8: magma.lte.oai.CreateSessionMessage.pco:type_name -> magma.lte.oai.Pco + 22, // 9: magma.lte.oai.CreateSessionMessage.sender_fteid_for_cp:type_name -> magma.lte.oai.Fteid + 5, // 10: magma.lte.oai.CreateSessionMessage.bearer_contexts_to_be_created:type_name -> magma.lte.oai.BearerContextToBeCreated + 3, // 11: magma.lte.oai.CreateSessionMessage.ue_time_zone:type_name -> magma.lte.oai.TimeZone + 17, // 12: magma.lte.oai.CreateSessionMessage.ue_ip_paa:type_name -> magma.lte.oai.IpTupple + 9, // 13: magma.lte.oai.BearerContextToBeCreated.tft:type_name -> magma.lte.oai.TrafficFlowTemplate + 12, // 14: magma.lte.oai.BearerContextToBeCreated.bearer_level_qos:type_name -> magma.lte.oai.SgwBearerQos + 8, // 15: magma.lte.oai.SgwPdnConnection.eps_bearer_list:type_name -> magma.lte.oai.SgwEpsBearerContext + 18, // 16: magma.lte.oai.SgwPdnConnection.eps_bearer_map:type_name -> magma.lte.oai.SgwPdnConnection.EpsBearerMapEntry + 12, // 17: magma.lte.oai.SgwEpsBearerContext.eps_bearer_qos:type_name -> magma.lte.oai.SgwBearerQos + 9, // 18: magma.lte.oai.SgwEpsBearerContext.tft:type_name -> magma.lte.oai.TrafficFlowTemplate + 17, // 19: magma.lte.oai.SgwEpsBearerContext.enb_s1u_ip_addr:type_name -> magma.lte.oai.IpTupple + 17, // 20: magma.lte.oai.SgwEpsBearerContext.ue_ip_paa:type_name -> magma.lte.oai.IpTupple + 17, // 21: magma.lte.oai.SgwEpsBearerContext.pgw_address_up:type_name -> magma.lte.oai.IpTupple + 17, // 22: magma.lte.oai.SgwEpsBearerContext.sgw_s1u_s12_s4_up_ip_addr:type_name -> magma.lte.oai.IpTupple + 10, // 23: magma.lte.oai.TrafficFlowTemplate.packet_filter_list:type_name -> magma.lte.oai.PacketFilterList + 23, // 24: magma.lte.oai.TrafficFlowTemplate.parameters_list:type_name -> magma.lte.oai.ParametersList + 11, // 25: magma.lte.oai.PacketFilterList.create_new_tft:type_name -> magma.lte.oai.PacketFilter + 11, // 26: magma.lte.oai.PacketFilterList.add_packet_filter:type_name -> magma.lte.oai.PacketFilter + 11, // 27: magma.lte.oai.PacketFilterList.replace_packet_filter:type_name -> magma.lte.oai.PacketFilter + 24, // 28: magma.lte.oai.PacketFilter.packet_filter_contents:type_name -> magma.lte.oai.PacketFilterContents + 20, // 29: magma.lte.oai.SgwBearerQos.gbr:type_name -> magma.lte.oai.Ambr + 20, // 30: magma.lte.oai.SgwBearerQos.mbr:type_name -> magma.lte.oai.Ambr + 14, // 31: magma.lte.oai.SpgwUeContext.s11_bearer_context:type_name -> magma.lte.oai.S11BearerContext + 0, // 32: magma.lte.oai.S11BearerContext.sgw_eps_bearer_context:type_name -> magma.lte.oai.SgwEpsBearerContextInfo + 6, // 33: magma.lte.oai.S11BearerContext.pgw_eps_bearer_context:type_name -> magma.lte.oai.PgwEpsBearerContextInfo + 15, // 34: magma.lte.oai.SpgwState.gtpv1u_data:type_name -> magma.lte.oai.GTPV1uData + 8, // 35: magma.lte.oai.SgwPdnConnection.EpsBearerMapEntry.value:type_name -> magma.lte.oai.SgwEpsBearerContext + 36, // [36:36] is the sub-list for method output_type + 36, // [36:36] is the sub-list for method input_type + 36, // [36:36] is the sub-list for extension type_name + 36, // [36:36] is the sub-list for extension extendee + 0, // [0:36] is the sub-list for field type_name } func init() { file_lte_protos_oai_spgw_state_proto_init() } @@ -2116,6 +2340,18 @@ func file_lte_protos_oai_spgw_state_proto_init() { return nil } } + file_lte_protos_oai_spgw_state_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IpTupple); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2123,7 +2359,7 @@ func file_lte_protos_oai_spgw_state_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_lte_protos_oai_spgw_state_proto_rawDesc, NumEnums: 0, - NumMessages: 17, + NumMessages: 19, NumExtensions: 0, NumServices: 0, }, diff --git a/lte/gateway/c/core/common/dynamic_memory_check.cpp b/lte/gateway/c/core/common/dynamic_memory_check.cpp index 0877dd5d338a..3e61d5667e28 100644 --- a/lte/gateway/c/core/common/dynamic_memory_check.cpp +++ b/lte/gateway/c/core/common/dynamic_memory_check.cpp @@ -67,7 +67,7 @@ void bdestroy_wrapper(bstring* b) { // TODO(rsarwad): rename free_wrapper once all tasks are migrated to cpp. // Shall be addressed while addressing issue_id: 13096 void free_cpp_wrapper(void** ptr) { - if (ptr) { + if ((ptr) && (*ptr)) { delete *ptr; *ptr = nullptr; } diff --git a/lte/gateway/c/core/oai/include/sgw_context_manager.hpp b/lte/gateway/c/core/oai/include/sgw_context_manager.hpp index c481bed1ce09..c611f58d9e8b 100644 --- a/lte/gateway/c/core/oai/include/sgw_context_manager.hpp +++ b/lte/gateway/c/core/oai/include/sgw_context_manager.hpp @@ -38,28 +38,46 @@ extern "C" { #define INITIAL_SGW_S8_S1U_TEID 0x7FFFFFFF void sgw_display_sgw_eps_bearer_context( - const sgw_eps_bearer_ctxt_t* eps_bearer_ctxt); + const magma::lte::oai::SgwEpsBearerContext* eps_bearer_ctxt); void sgw_display_s11_bearer_context_information( + log_proto_t module, + magma::lte::oai::S11BearerContext* sgw_context_information); + +// TODO(rsarwad): to be removed while porting sgw_s8 task +void sgw_s8_display_sgw_eps_bearer_context( + const sgw_eps_bearer_ctxt_t* eps_bearer_ctxt); + +void sgw_s8_display_s11_bearer_context_information( log_proto_t module, sgw_eps_bearer_context_information_t* sgw_context_information); +sgw_eps_bearer_ctxt_t* sgw_s8_cm_get_eps_bearer_entry( + sgw_pdn_connection_t* const sgw_pdn_connection, ebi_t ebi); + mme_sgw_tunnel_t* sgw_cm_create_s11_tunnel(teid_t remote_teid, teid_t local_teid); -s_plus_p_gw_eps_bearer_context_information_t* +magma::lte::oai::S11BearerContext* sgw_cm_create_bearer_context_information_in_collection(teid_t teid); magma::proto_map_rc_t sgw_cm_remove_bearer_context_information(teid_t teid, imsi64_t imsi64); sgw_eps_bearer_ctxt_t* sgw_cm_create_eps_bearer_ctxt_in_collection( sgw_pdn_connection_t* const sgw_pdn_connection, const ebi_t eps_bearer_idP); -sgw_eps_bearer_ctxt_t* sgw_cm_insert_eps_bearer_ctxt_in_collection( - sgw_pdn_connection_t* const sgw_pdn_connection, - sgw_eps_bearer_ctxt_t* const sgw_eps_bearer_ctxt); -sgw_eps_bearer_ctxt_t* sgw_cm_get_eps_bearer_entry( - sgw_pdn_connection_t* const sgw_pdn_connection, ebi_t ebi); + +magma::proto_map_rc_t sgw_cm_insert_eps_bearer_ctxt_in_collection( + magma::lte::oai::SgwPdnConnection* const sgw_pdn_connection, + magma::lte::oai::SgwEpsBearerContext* const sgw_eps_bearer_ctxt); + // Returns SPGW state pointer for given UE indexed by IMSI -s_plus_p_gw_eps_bearer_context_information_t* sgw_cm_get_spgw_context( - teid_t teid); +magma::lte::oai::S11BearerContext* sgw_cm_get_spgw_context(teid_t teid); spgw_ue_context_t* spgw_get_ue_context(imsi64_t imsi64); spgw_ue_context_t* spgw_create_or_get_ue_context(imsi64_t imsi64); status_code_e spgw_update_teid_in_ue_context(imsi64_t imsi64, teid_t teid); + +magma::proto_map_rc_t sgw_cm_get_eps_bearer_entry( + magma::lte::oai::SgwPdnConnection* const sgw_pdn_connection, ebi_t ebi, + magma::lte::oai::SgwEpsBearerContext* bearer_context_p); + +magma::proto_map_rc_t sgw_update_eps_bearer_entry( + magma::lte::oai::SgwPdnConnection* sgw_pdn_connection_p, uint32_t ebi, + magma::lte::oai::SgwEpsBearerContext* bearer_context_p); diff --git a/lte/gateway/c/core/oai/include/sgw_ie_defs.h b/lte/gateway/c/core/oai/include/sgw_ie_defs.h index eacc14ed615c..0d745b3aa509 100644 --- a/lte/gateway/c/core/oai/include/sgw_ie_defs.h +++ b/lte/gateway/c/core/oai/include/sgw_ie_defs.h @@ -174,6 +174,28 @@ typedef struct { uint8_t mnc[3]; } ServingNetwork_t; +#define FTEID_T_2_PROTO_IP(fte_p, ip_p) \ + do { \ + if ((fte_p)->ipv4) { \ + (ip_p)->set_pdn_type(IPv4); \ + char ip4_str[INET_ADDRSTRLEN]; \ + inet_ntop(AF_INET, (&(fte_p)->ipv4_address.s_addr), ip4_str, \ + INET_ADDRSTRLEN); \ + (ip_p)->set_ipv4_addr(ip4_str); \ + } \ + if ((fte_p)->ipv6) { \ + if ((fte_p)->ipv4) { \ + (ip_p)->set_pdn_type(IPv4_AND_v6); \ + } else { \ + (ip_p)->set_pdn_type(IPv6); \ + } \ + char ip6_str[INET6_ADDRSTRLEN]; \ + inet_ntop(AF_INET6, &((fte_p)->ipv6_address), ip6_str, \ + INET6_ADDRSTRLEN); \ + (ip_p)->set_ipv6_addr(ip6_str); \ + } \ + } while (0) + #define FTEID_T_2_IP_ADDRESS_T(fte_p, ip_p) \ do { \ if ((fte_p)->ipv4) { \ diff --git a/lte/gateway/c/core/oai/include/spgw_state.hpp b/lte/gateway/c/core/oai/include/spgw_state.hpp index 815226c0a33c..b1c5d37e3321 100644 --- a/lte/gateway/c/core/oai/include/spgw_state.hpp +++ b/lte/gateway/c/core/oai/include/spgw_state.hpp @@ -75,12 +75,18 @@ void spgw_free_s11_bearer_context_information(void**); * Frees pdn connection and its contained objects * @param pdn_connection_p */ -void sgw_free_pdn_connection(sgw_pdn_connection_t* pdn_connection_p); +void sgw_free_pdn_connection( + magma::lte::oai::SgwPdnConnection* pdn_connection_p); /** * Frees sgw_eps_bearer_ctxt entry * @param sgw_eps_bearer_ctxt */ -void sgw_free_eps_bearer_context(sgw_eps_bearer_ctxt_t** sgw_eps_bearer_ctxt); +// TODO(rsarwad): Need to be removed while porting bearer contexts for s8 task +void sgw_s8_free_eps_bearer_context( + sgw_eps_bearer_ctxt_t** sgw_eps_bearer_ctxt); + +void sgw_remove_eps_bearer_context( + magma::lte::oai::SgwPdnConnection* pdn_connection_p, uint32_t ebi); /** * Callback function for freeing the ue context while removing an entry from * state_ue_map diff --git a/lte/gateway/c/core/oai/include/spgw_types.hpp b/lte/gateway/c/core/oai/include/spgw_types.hpp index 292302ce040e..09fbe64777a4 100644 --- a/lte/gateway/c/core/oai/include/spgw_types.hpp +++ b/lte/gateway/c/core/oai/include/spgw_types.hpp @@ -30,6 +30,8 @@ #pragma once +#include "lte/protos/oai/spgw_state.pb.h" + #ifdef __cplusplus extern "C" { #endif @@ -82,9 +84,10 @@ typedef struct sgw_s11_teid_s { } sgw_s11_teid_t; // Map- Key:teid (uint32_t) , -// Data:s_plus_p_gw_eps_bearer_context_information_s* -typedef magma::proto_map_s +// Data: S11BearerContext* +// TODO (rsarwad): rename S11BearerContext to SpgwSessionContext and also +// internal structures +typedef magma::proto_map_s state_teid_map_t; typedef struct spgw_ue_context_s { @@ -95,6 +98,10 @@ typedef struct spgw_ue_context_s { typedef magma::proto_map_s map_uint64_spgw_ue_context_t; +// Map- Key: eps_bearer_id(uint32), Data: SgwEpsBearerContext +typedef magma::proto_map_s + map_uint32_spgw_eps_bearer_context_t; + // Data entry for s11teid2mme typedef struct mme_sgw_tunnel_s { uint32_t local_teid; ///< Local tunnel endpoint Identifier @@ -133,5 +140,5 @@ typedef struct spgw_state_s { void handle_s5_create_session_response( spgw_state_t* state, - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p, + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p, s5_create_session_response_t session_resp); diff --git a/lte/gateway/c/core/oai/lib/directoryd/directoryd.cpp b/lte/gateway/c/core/oai/lib/directoryd/directoryd.cpp index 630e9828f1c0..ab0c5475092e 100644 --- a/lte/gateway/c/core/oai/lib/directoryd/directoryd.cpp +++ b/lte/gateway/c/core/oai/lib/directoryd/directoryd.cpp @@ -54,10 +54,10 @@ bool directoryd_update_location(char* imsi, char* location) { return true; } -bool directoryd_update_record_field(char* imsi, const char* key, char* value) { +bool directoryd_update_record_field(char* imsi, std::string key, char* value) { // Actual GW_ID will be filled in the cloud magma::GatewayDirectoryServiceClient::UpdateRecordField( - "IMSI" + std::string(imsi), std::string(key), std::string(value), + "IMSI" + std::string(imsi), key, std::string(value), [&](grpc::Status status, magma::Void response) { directoryd_rpc_call_done(status); }); diff --git a/lte/gateway/c/core/oai/lib/directoryd/directoryd.hpp b/lte/gateway/c/core/oai/lib/directoryd/directoryd.hpp index 881f5376a78d..c924921d3391 100644 --- a/lte/gateway/c/core/oai/lib/directoryd/directoryd.hpp +++ b/lte/gateway/c/core/oai/lib/directoryd/directoryd.hpp @@ -17,10 +17,7 @@ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - +#include /* * This enum should have the same definition as TableID in directoryd.proto . * @@ -36,8 +33,4 @@ bool directoryd_remove_location(char* imsi); bool directoryd_update_location(char* imsi, char* location); -bool directoryd_update_record_field(char* imsi, const char* key, char* value); - -#ifdef __cplusplus -} -#endif +bool directoryd_update_record_field(char* imsi, std::string key, char* value); diff --git a/lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.cpp b/lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.cpp index 42be1dfb6fb5..b0675b24d8f7 100644 --- a/lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.cpp +++ b/lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.cpp @@ -27,7 +27,6 @@ #include "lte/gateway/c/core/oai/common/common_types.h" #include "lte/gateway/c/core/oai/common/conversions.h" #include "lte/gateway/c/core/oai/common/log.h" -#include "lte/gateway/c/core/oai/include/spgw_types.hpp" #include "lte/gateway/c/core/oai/lib/itti/intertask_interface.h" #include "lte/gateway/c/core/oai/lib/mobility_client/MobilityServiceClient.hpp" #include "orc8r/gateway/c/common/service303/MetricsHelpers.hpp" @@ -65,15 +64,13 @@ int get_assigned_ipv4_block(int index, struct in_addr* netaddr, return status; } -int pgw_handle_allocate_ipv4_address(const char* subscriber_id, const char* apn, - const char* pdn_type, teid_t context_teid, - ebi_t eps_bearer_id) { +int pgw_handle_allocate_ipv4_address(const std::string subscriber_id_str, + const std::string apn_str, + const std::string pdn_type_str, + teid_t context_teid, ebi_t eps_bearer_id) { #if MME_UNIT_TEST return RETURNok; // skip this call for unit testing #endif - auto subscriber_id_str = std::string(subscriber_id); - auto apn_str = std::string(apn); - auto pdn_type_str = std::string(pdn_type); MobilityServiceClient::getInstance().AllocateIPv4AddressAsync( subscriber_id_str, apn_str, [subscriber_id_str, apn_str, pdn_type_str, context_teid, eps_bearer_id]( @@ -150,8 +147,8 @@ static void handle_allocate_ipv4_address_status( send_msg_to_task(&grpc_service_task_zmq_ctx, TASK_SPGW_APP, message_p); } -void release_ipv4_address(const char* subscriber_id, const char* apn, - const struct in_addr* addr) { +void release_ipv4_address(const std::string subscriber_id, + const std::string apn, const struct in_addr* addr) { #if !MME_UNIT_TEST MobilityServiceClient::getInstance().ReleaseIPv4Address(subscriber_id, apn, *addr); @@ -176,15 +173,13 @@ int get_subscriber_id_from_ipv4(const struct in_addr* addr, return status; } -int pgw_handle_allocate_ipv6_address(const char* subscriber_id, const char* apn, - const char* pdn_type, teid_t context_teid, - ebi_t eps_bearer_id) { +int pgw_handle_allocate_ipv6_address(const std::string subscriber_id_str, + const std::string apn_str, + const std::string pdn_type_str, + teid_t context_teid, ebi_t eps_bearer_id) { #if MME_UNIT_TEST return RETURNok; #endif - auto subscriber_id_str = std::string(subscriber_id); - auto apn_str = std::string(apn); - auto pdn_type_str = std::string(pdn_type); // Make an RPC call to Mobilityd MobilityServiceClient::getInstance().AllocateIPv6AddressAsync( subscriber_id_str, apn_str, @@ -269,16 +264,14 @@ static void handle_allocate_ipv6_address_status( send_msg_to_task(&grpc_service_task_zmq_ctx, TASK_SPGW_APP, message_p); } -int pgw_handle_allocate_ipv4v6_address(const char* subscriber_id, - const char* apn, const char* pdn_type, +int pgw_handle_allocate_ipv4v6_address(const std::string subscriber_id_str, + const std::string apn_str, + const std::string pdn_type_str, teid_t context_teid, ebi_t eps_bearer_id) { #if MME_UNIT_TEST return RETURNok; #endif - auto subscriber_id_str = std::string(subscriber_id); - auto apn_str = std::string(apn); - auto pdn_type_str = std::string(pdn_type); // Get IPv4v6 address MobilityServiceClient::getInstance().AllocateIPv4v6AddressAsync( subscriber_id_str, apn_str, @@ -373,13 +366,14 @@ static void handle_allocate_ipv4v6_address_status( send_msg_to_task(&grpc_service_task_zmq_ctx, TASK_SPGW_APP, message_p); } -void release_ipv6_address(const char* subscriber_id, const char* apn, - const struct in6_addr* addr) { +void release_ipv6_address(const std::string subscriber_id, + const std::string apn, const struct in6_addr* addr) { MobilityServiceClient::getInstance().ReleaseIPv6Address(subscriber_id, apn, *addr); } -void release_ipv4v6_address(const char* subscriber_id, const char* apn, +void release_ipv4v6_address(const std::string subscriber_id, + const std::string apn, const struct in_addr* ipv4_addr, const struct in6_addr* ipv6_addr) { MobilityServiceClient::getInstance().ReleaseIPv4v6Address( diff --git a/lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.hpp b/lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.hpp index 4b34048711c9..79818e158f04 100644 --- a/lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.hpp +++ b/lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.hpp @@ -15,10 +15,11 @@ * contact@openairinterface.org */ -#ifndef RPC_CLIENT_H -#define RPC_CLIENT_H +#pragma once -#include "stdint.h" +#include + +#include #ifdef __cplusplus extern "C" { @@ -31,7 +32,6 @@ extern "C" { #endif #include "lte/gateway/c/core/common/dynamic_memory_check.h" -#include "lte/gateway/c/core/oai/include/spgw_state.hpp" // Status codes from gRPC #define RPC_STATUS_OK 0 @@ -75,9 +75,10 @@ int get_assigned_ipv4_block(int index, struct in_addr* netaddr, * @param pdn_type str for PDN type (ipv4, ipv6...) * @return status of gRPC call */ -int pgw_handle_allocate_ipv4_address(const char* subscriber_id, const char* apn, - const char* pdn_type, teid_t context_teid, - ebi_t eps_bearer_id); +int pgw_handle_allocate_ipv4_address(const std::string subscriber_id, + const std::string apn, + const std::string pdn_type, + teid_t context_teid, ebi_t eps_bearer_id); /** * Allocate IP address from MobilityServiceClient over gRPC (non-blocking), @@ -89,9 +90,10 @@ int pgw_handle_allocate_ipv4_address(const char* subscriber_id, const char* apn, * @return status of gRPC call */ -int pgw_handle_allocate_ipv6_address(const char* subscriber_id, const char* apn, - const char* pdn_type, teid_t context_teid, - ebi_t eps_bearer_id); +int pgw_handle_allocate_ipv6_address(const std::string subscriber_id, + const std::string apn, + const std::string pdn_type, + teid_t context_teid, ebi_t eps_bearer_id); /* * Release an allocated IP address. @@ -102,8 +104,8 @@ int pgw_handle_allocate_ipv6_address(const char* subscriber_id, const char* apn, * @param subscriber_id: subscriber id string, i.e. IMSI * @param addr: IP address to release */ -void release_ipv4_address(const char* subscriber_id, const char* apn, - const struct in_addr* addr); +void release_ipv4_address(const std::string subscriber_id, + const std::string apn, const struct in_addr* addr); /* * Release an allocated IP address. @@ -115,8 +117,8 @@ void release_ipv4_address(const char* subscriber_id, const char* apn, * @param apn: access point name string, e.g., "ims", "internet", etc. * @param addr: IPv6 address to release in "host byte order */ -void release_ipv6_address(const char* subscriber_id, const char* apn, - const struct in6_addr* addr); +void release_ipv6_address(const std::string subscriber_id, + const std::string apn, const struct in6_addr* addr); /* * Release an allocated IP address. @@ -129,7 +131,8 @@ void release_ipv6_address(const char* subscriber_id, const char* apn, * @param ipv4_addr: IPv4 address to release in "host byte order * @param ipv6_addr: IPv6 address to release in "host byte order */ -void release_ipv4v6_address(const char* subscriber_id, const char* apn, +void release_ipv4v6_address(const std::string subscriber_id, + const std::string apn, const struct in_addr* ipv4_addr, const struct in6_addr* ipv6_addr); @@ -168,9 +171,8 @@ int get_subscriber_id_from_ipv4(const struct in_addr* addr, * @return status of gRPC call */ -int pgw_handle_allocate_ipv4v6_address(const char* subscriber_id, - const char* apn, const char* pdn_type, +int pgw_handle_allocate_ipv4v6_address(const std::string subscriber_id_str, + const std::string apn_str, + const std::string pdn_type_str, teid_t context_teid, ebi_t eps_bearer_id); - -#endif // RPC_CLIENT_H diff --git a/lte/gateway/c/core/oai/lib/pcef/CMakeLists.txt b/lte/gateway/c/core/oai/lib/pcef/CMakeLists.txt index db3b9304811f..5b84586a01c9 100644 --- a/lte/gateway/c/core/oai/lib/pcef/CMakeLists.txt +++ b/lte/gateway/c/core/oai/lib/pcef/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_CXX_FLAGS "-Wno-write-strings -Wno-literal-suffix") # compile the needed protos set(PCEF_ORC8R_CPP_PROTOS mconfig/mconfigs) -set(PCEF_LTE_CPP_PROTOS policydb session_manager) +set(PCEF_LTE_CPP_PROTOS policydb session_manager oai/spgw_state oai/sgw_state oai/common_types oai/std_3gpp_types) set(PCEF_ORC8R_GRPC_PROTOS "") set(PCEF_LTE_GRPC_PROTOS session_manager) diff --git a/lte/gateway/c/core/oai/lib/pcef/pcef_handlers.cpp b/lte/gateway/c/core/oai/lib/pcef/pcef_handlers.cpp index 4a41f2826abd..7b9c2219782a 100644 --- a/lte/gateway/c/core/oai/lib/pcef/pcef_handlers.cpp +++ b/lte/gateway/c/core/oai/lib/pcef/pcef_handlers.cpp @@ -36,7 +36,6 @@ extern "C" { #include "lte/gateway/c/core/oai/lib/pcef/PCEFClient.hpp" #include "lte/gateway/c/core/oai/lib/mobility_client/MobilityClientAPI.hpp" -#include "lte/gateway/c/core/oai/include/spgw_types.hpp" extern task_zmq_ctx_t grpc_service_task_zmq_ctx; @@ -132,10 +131,9 @@ status_code_e send_itti_pcef_create_session_response( return send_msg_to_task(&grpc_service_task_zmq_ctx, TASK_SPGW_APP, message_p); } -void pcef_create_session(const char* imsi, const char* ip4, const char* ip6, +void pcef_create_session(std::string imsi_str, const char* ip4, const char* ip6, const pcef_create_session_data* session_data, s5_create_session_request_t session_request) { - auto imsi_str = std::string(imsi); std::string ip4_str, ip6_str; if (ip4) { @@ -161,12 +159,10 @@ void pcef_create_session(const char* imsi, const char* ip4, const char* ip6, }); } -bool pcef_end_session(char* imsi, char* apn) { +bool pcef_end_session(const std::string imsi, const std::string apn) { magma::LocalEndSessionRequest request; - request.mutable_sid()->set_id("IMSI" + std::string(imsi)); - if (apn) { - request.set_apn(apn); - } + request.mutable_sid()->set_id("IMSI" + imsi); + request.set_apn(apn); magma::PCEFClient::end_session( request, [&](grpc::Status status, magma::LocalEndSessionResponse response) { @@ -258,36 +254,35 @@ char convert_digit_to_char(char digit) { } } -static void get_plmn_from_session_req( - const itti_s11_create_session_request_t* saved_req, - struct pcef_create_session_data* data) { - data->mcc_mnc[0] = convert_digit_to_char(saved_req->serving_network.mcc[0]); - data->mcc_mnc[1] = convert_digit_to_char(saved_req->serving_network.mcc[1]); - data->mcc_mnc[2] = convert_digit_to_char(saved_req->serving_network.mcc[2]); - data->mcc_mnc[3] = convert_digit_to_char(saved_req->serving_network.mnc[0]); - data->mcc_mnc[4] = convert_digit_to_char(saved_req->serving_network.mnc[1]); - data->mcc_mnc_len = 5; +void get_plmn_from_session_req( + const itti_s11_create_session_request_t* saved_req, char* mcc_mnc) { + mcc_mnc[0] = convert_digit_to_char(saved_req->serving_network.mcc[0]); + mcc_mnc[1] = convert_digit_to_char(saved_req->serving_network.mcc[1]); + mcc_mnc[2] = convert_digit_to_char(saved_req->serving_network.mcc[2]); + mcc_mnc[3] = convert_digit_to_char(saved_req->serving_network.mnc[0]); + mcc_mnc[4] = convert_digit_to_char(saved_req->serving_network.mnc[1]); + int mcc_mnc_len = 5; if ((saved_req->serving_network.mnc[2] & 0xf) != 0xf) { - data->mcc_mnc[5] = convert_digit_to_char(saved_req->serving_network.mnc[2]); - data->mcc_mnc[6] = '\0'; - data->mcc_mnc_len += 1; + mcc_mnc[5] = convert_digit_to_char(saved_req->serving_network.mnc[2]); + mcc_mnc[6] = '\0'; + mcc_mnc_len += 1; } else { - data->mcc_mnc[5] = '\0'; + mcc_mnc[5] = '\0'; } } -static void get_imsi_plmn_from_session_req( - const itti_s11_create_session_request_t* saved_req, - struct pcef_create_session_data* data) { - data->imsi_mcc_mnc[0] = convert_digit_to_char(saved_req->imsi.digit[0]); - data->imsi_mcc_mnc[1] = convert_digit_to_char(saved_req->imsi.digit[1]); - data->imsi_mcc_mnc[2] = convert_digit_to_char(saved_req->imsi.digit[2]); - data->imsi_mcc_mnc[3] = convert_digit_to_char(saved_req->imsi.digit[3]); - data->imsi_mcc_mnc[4] = convert_digit_to_char(saved_req->imsi.digit[4]); +void get_imsi_plmn_from_session_req(const std::string imsi, + struct pcef_create_session_data* data) { + const char* imsi_digit = imsi.c_str(); + data->imsi_mcc_mnc[0] = convert_digit_to_char(imsi_digit[0]); + data->imsi_mcc_mnc[1] = convert_digit_to_char(imsi_digit[1]); + data->imsi_mcc_mnc[2] = convert_digit_to_char(imsi_digit[2]); + data->imsi_mcc_mnc[3] = convert_digit_to_char(imsi_digit[3]); + data->imsi_mcc_mnc[4] = convert_digit_to_char(imsi_digit[4]); data->imsi_mcc_mnc_len = 5; - // Check if 2 or 3 digit by verifying mnc[2] has a valid value - if ((saved_req->serving_network.mnc[2] & 0xf) != 0xf) { - data->imsi_mcc_mnc[5] = convert_digit_to_char(saved_req->imsi.digit[5]); + // Check the mcc_mnc_len which is deocoded from serving network mnc value + if (data->mcc_mnc_len == 6) { + data->imsi_mcc_mnc[5] = convert_digit_to_char(imsi_digit[5]); data->imsi_mcc_mnc[6] = '\0'; data->imsi_mcc_mnc_len += 1; } else { @@ -295,7 +290,7 @@ static void get_imsi_plmn_from_session_req( } } -static int get_uli_from_session_req( +bool get_uli_from_session_req( const itti_s11_create_session_request_t* saved_req, char* uli) { if (!saved_req->uli.present) { return 0; @@ -391,40 +386,6 @@ int get_imeisv_from_session_req( return 0; } -void get_session_req_data(spgw_state_t* spgw_state, - const itti_s11_create_session_request_t* saved_req, - struct pcef_create_session_data* data) { - const bearer_qos_t* qos; - - data->msisdn_len = get_msisdn_from_session_req(saved_req, data->msisdn); - - data->imeisv_exists = get_imeisv_from_session_req(saved_req, data->imeisv); - if (data->imeisv_exists) { - convert_imeisv_to_string(data->imeisv); - } - data->uli_exists = get_uli_from_session_req(saved_req, data->uli); - get_plmn_from_session_req(saved_req, data); - get_imsi_plmn_from_session_req(saved_req, data); - memcpy(&data->charging_characteristics, &saved_req->charging_characteristics, - sizeof(charging_characteristics_t)); - - memcpy(data->apn, saved_req->apn, APN_MAX_LENGTH + 1); - data->pdn_type = saved_req->pdn_type; - - inet_ntop(AF_INET, &spgw_state->sgw_ip_address_S1u_S12_S4_up, data->sgw_ip, - INET_ADDRSTRLEN); - - // QoS Info - data->ambr_dl = saved_req->ambr.br_dl; - data->ambr_ul = saved_req->ambr.br_ul; - qos = &saved_req->bearer_contexts_to_be_created.bearer_contexts[0] - .bearer_level_qos; - data->pl = qos->pl; - data->pci = qos->pci; - data->pvi = qos->pvi; - data->qci = qos->qci; -} - bool pcef_delete_dedicated_bearer(const char* imsi, const ebi_list_t ebi_list) { auto imsi_str = std::string(imsi); diff --git a/lte/gateway/c/core/oai/lib/pcef/pcef_handlers.hpp b/lte/gateway/c/core/oai/lib/pcef/pcef_handlers.hpp index eddef1e525a6..b071d80bc479 100644 --- a/lte/gateway/c/core/oai/lib/pcef/pcef_handlers.hpp +++ b/lte/gateway/c/core/oai/lib/pcef/pcef_handlers.hpp @@ -60,7 +60,7 @@ struct pcef_create_session_data { * the PCEF and sends an S5 ITTI message to SGW when done. * This is a long process, so it needs to by asynchronous */ -void pcef_create_session(const char* imsi, const char* ip4, const char* ip6, +void pcef_create_session(std::string imsi, const char* ip4, const char* ip6, const struct pcef_create_session_data* session_data, s5_create_session_request_t bearer_request); @@ -69,7 +69,7 @@ void pcef_create_session(const char* imsi, const char* ip4, const char* ip6, * PCEF and returns true if successful. * This may turn asynchronous in the future if it's too long */ -bool pcef_end_session(char* imsi, char* apn); +bool pcef_end_session(const std::string imsi, const std::string apn); /** * pcef_send_policy2bearer_binding is an asynchronous call that binds policy @@ -83,10 +83,6 @@ void pcef_send_policy2bearer_binding(const char* imsi, const uint32_t eps_bearer_agw_teid, const uint32_t eps_bearer_enb_teid); -void get_session_req_data(spgw_state_t* spgw_state, - const itti_s11_create_session_request_t* saved_req, - struct pcef_create_session_data* data); - /** * pcef_update_teids is an asynchronous call that updates * enb teid and sgw/agw teid for a particular session that is @@ -107,3 +103,12 @@ int get_imeisv_from_session_req( void convert_imeisv_to_string(char* imeisv); bool pcef_delete_dedicated_bearer(const char* imsi, const ebi_list_t ebi_list); + +bool get_uli_from_session_req( + const itti_s11_create_session_request_t* saved_req, char* uli); + +void get_plmn_from_session_req( + const itti_s11_create_session_request_t* saved_req, char* mcc_mnc); + +void get_imsi_plmn_from_session_req(const std::string imsi, + struct pcef_create_session_data* data); diff --git a/lte/gateway/c/core/oai/tasks/amf/amf_app_ue_context.cpp b/lte/gateway/c/core/oai/tasks/amf/amf_app_ue_context.cpp index a14fa50b6d13..7558a9659f2b 100644 --- a/lte/gateway/c/core/oai/tasks/amf/amf_app_ue_context.cpp +++ b/lte/gateway/c/core/oai/tasks/amf/amf_app_ue_context.cpp @@ -11,17 +11,19 @@ * limitations under the License. */ +#include + #ifdef __cplusplus extern "C" { #endif #include "lte/gateway/c/core/oai/common/log.h" #include "lte/gateway/c/core/oai/lib/itti/intertask_interface.h" -#include "lte/gateway/c/core/oai/lib/directoryd/directoryd.hpp" #include "lte/gateway/c/core/oai/common/conversions.h" #ifdef __cplusplus } #endif -#include + +#include "lte/gateway/c/core/oai/lib/directoryd/directoryd.hpp" #include "lte/gateway/c/core/common/common_defs.h" #include "lte/gateway/c/core/common/dynamic_memory_check.h" #include "lte/gateway/c/core/oai/include/map.h" diff --git a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_openflow.cpp b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_openflow.cpp index 85e94ef8f7be..129bd9a08e9c 100644 --- a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_openflow.cpp +++ b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_openflow.cpp @@ -307,7 +307,7 @@ int openflow_add_tunnel(struct in_addr ue, struct in6_addr* ue_ipv6, int vlan, struct in_addr enb, struct in6_addr* enb_ipv6, uint32_t i_tei, uint32_t o_tei, Imsi_t imsi, struct ip_flow_dl* flow_dl, uint32_t flow_precedence_dl, - char* apn) { + const char* apn) { uint32_t gtp_portno = find_gtp_port_no(enb, enb_ipv6, false); if (spgw_config.sgw_config.ebpf_enabled) { diff --git a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_upf.cpp b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_upf.cpp index e6b3c69a8abf..52b69ee2367d 100644 --- a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_upf.cpp +++ b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_upf.cpp @@ -60,7 +60,7 @@ int upf_add_tunnel(struct in_addr ue, struct in6_addr* ue_ipv6, int vlan, struct in_addr enb, struct in6_addr* unused_in6_addr, uint32_t i_tei, uint32_t o_tei, Imsi_t imsi, struct ip_flow_dl* flow_dl, uint32_t flow_precedence_dl, - char* apn) { + const char* apn) { return upf_classifier_add_tunnel(ue, ue_ipv6, vlan, enb, i_tei, o_tei, (const char*)imsi.digit, flow_dl, flow_precedence_dl, apn); diff --git a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_upf.hpp b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_upf.hpp index 210fc9e40e39..c3772629c483 100644 --- a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_upf.hpp +++ b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtp_tunnel_upf.hpp @@ -25,7 +25,7 @@ int upf_add_tunnel(struct in_addr ue, struct in6_addr* ue_ipv6, int vlan, struct in_addr enb, struct in6_addr* unused_in6_addr, uint32_t i_tei, uint32_t o_tei, Imsi_t imsi, struct ip_flow_dl* flow_dl, uint32_t flow_precedence_dl, - char* apn); + const char* apn); int upf_del_tunnel(struct in_addr enb, struct in6_addr* unused_in6_addr, struct in_addr ue, struct in6_addr* ue_ipv6, uint32_t i_tei, diff --git a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtpv1u.hpp b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtpv1u.hpp index 94394e9aec4d..49a524964cd4 100644 --- a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtpv1u.hpp +++ b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtpv1u.hpp @@ -146,7 +146,7 @@ struct gtp_tunnel_ops { struct in_addr enb, struct in6_addr* enb_ipv6, uint32_t i_tei, uint32_t o_tei, Imsi_t imsi, struct ip_flow_dl* flow_dl, uint32_t flow_precedence_dl, - char* apn); + const char* apn); int (*del_tunnel)(struct in_addr enb, struct in6_addr* enb_ipv6, struct in_addr ue, struct in6_addr* ue_ipv6, uint32_t i_tei, uint32_t o_tei, struct ip_flow_dl* flow_dl); @@ -177,7 +177,7 @@ int gtpv1u_add_tunnel(struct in_addr ue, struct in6_addr* ue_ipv6, int vlan, struct in_addr enb, struct in6_addr* enb_ipv6, uint32_t i_tei, uint32_t o_tei, Imsi_t imsi, struct ip_flow_dl* flow_dl, uint32_t flow_precedence_dl, - char* apn); + const char* apn); int gtpv1u_add_s8_tunnel(struct in_addr ue, struct in6_addr* ue_ipv6, int vlan, struct in_addr enb, struct in6_addr* enb_ipv6, diff --git a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtpv1u_task.cpp b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtpv1u_task.cpp index 548e9b5311ba..91b37a55f666 100644 --- a/lte/gateway/c/core/oai/tasks/gtpv1-u/gtpv1u_task.cpp +++ b/lte/gateway/c/core/oai/tasks/gtpv1-u/gtpv1u_task.cpp @@ -48,7 +48,7 @@ extern "C" { const struct gtp_tunnel_ops* gtp_tunnel_ops; static struct in_addr current_ue_net; -static int current_ue_net_mask; +static uint32_t current_ue_net_mask; //------------------------------------------------------------------------------ void add_route_for_ue_block(struct in_addr ue_net, uint32_t mask) { @@ -175,7 +175,7 @@ int gtpv1u_add_tunnel(struct in_addr ue, struct in6_addr* ue_ipv6, int vlan, struct in_addr enb, struct in6_addr* enb_ipv6, uint32_t i_tei, uint32_t o_tei, Imsi_t imsi, struct ip_flow_dl* flow_dl, uint32_t flow_precedence_dl, - char* apn) { + const char* apn) { OAILOG_DEBUG(LOG_GTPV1U, "Add tunnel ue %s", inet_ntoa(ue)); if (spgw_config.pgw_config.enable_nat) { diff --git a/lte/gateway/c/core/oai/tasks/s1ap/s1ap_state_manager.cpp b/lte/gateway/c/core/oai/tasks/s1ap/s1ap_state_manager.cpp index 456f70916acd..bb05894c84de 100644 --- a/lte/gateway/c/core/oai/tasks/s1ap/s1ap_state_manager.cpp +++ b/lte/gateway/c/core/oai/tasks/s1ap/s1ap_state_manager.cpp @@ -61,10 +61,6 @@ oai::S1apState* create_s1ap_state(void) { proto_map_uint32_enb_description_t enb_map; oai::S1apState* state_cache_p = new oai::S1apState(); - if (!state_cache_p) { - OAILOG_CRITICAL(LOG_S1AP, "Failed allocate memory for S1apState"); - return state_cache_p; - } enb_map.map = state_cache_p->mutable_enbs(); enb_map.set_name(S1AP_ENB_COLL); enb_map.bind_callback(free_enb_description); diff --git a/lte/gateway/c/core/oai/tasks/sgw/mobilityd_ue_ip_address_alloc.cpp b/lte/gateway/c/core/oai/tasks/sgw/mobilityd_ue_ip_address_alloc.cpp index abb2dff7b7b0..f21dc51bbd81 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/mobilityd_ue_ip_address_alloc.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw/mobilityd_ue_ip_address_alloc.cpp @@ -31,7 +31,7 @@ extern "C" { struct in_addr; -void release_ue_ipv4_address(const char* imsi, const char* apn, +void release_ue_ipv4_address(const std::string imsi, const std::string apn, struct in_addr* addr) { increment_counter("ue_pdn_connection", 1, 2, "pdn_type", "ipv4", "result", "ip_address_released"); @@ -39,7 +39,7 @@ void release_ue_ipv4_address(const char* imsi, const char* apn, release_ipv4_address(imsi, apn, addr); } -void release_ue_ipv6_address(const char* imsi, const char* apn, +void release_ue_ipv6_address(const std::string imsi, const std::string apn, struct in6_addr* addr) { increment_counter("ue_pdn_connection", 1, 2, "pdn_type", "ipv6", "result", "ip_address_released"); diff --git a/lte/gateway/c/core/oai/tasks/sgw/pgw_handlers.cpp b/lte/gateway/c/core/oai/tasks/sgw/pgw_handlers.cpp index be4a45d6b45a..c2beda102ced 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/pgw_handlers.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw/pgw_handlers.cpp @@ -73,11 +73,11 @@ extern spgw_config_t spgw_config; static void delete_temporary_dedicated_bearer_context( teid_t s1_u_sgw_fteid, ebi_t lbi, - s_plus_p_gw_eps_bearer_context_information_t* spgw_context_p); + magma::lte::oai::S11BearerContext* spgw_context_p); static void spgw_handle_s5_response_with_error( spgw_state_t* spgw_state, - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p, + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p, teid_t context_teid, ebi_t eps_bearer_id, s5_create_session_response_t* s5_response); @@ -85,13 +85,13 @@ static void spgw_handle_s5_response_with_error( void handle_s5_create_session_request( spgw_state_t* spgw_state, - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p, + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p, teid_t context_teid, ebi_t eps_bearer_id) { OAILOG_FUNC_IN(LOG_SPGW_APP); s5_create_session_response_t s5_response = {0}; - char* imsi = NULL; - char* apn = NULL; + std::string imsi; + std::string apn; if (!new_bearer_ctxt_info_p) { OAILOG_ERROR(LOG_SPGW_APP, @@ -103,23 +103,19 @@ void handle_s5_create_session_request( context_teid, eps_bearer_id, &s5_response); } - + magma::lte::oai::SgwEpsBearerContextInfo sgw_context = + new_bearer_ctxt_info_p->sgw_eps_bearer_context(); OAILOG_DEBUG_UE( - LOG_SPGW_APP, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64, + LOG_SPGW_APP, sgw_context.imsi64(), "Handle s5_create_session_request, for context sgw s11 teid, " TEID_FMT "EPS bearer id %u\n", context_teid, eps_bearer_id); - imsi = - (char*) - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi.digit; + imsi = sgw_context.imsi(); - apn = (char*)new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.apn_in_use; + apn = sgw_context.pdn_connection().apn_in_use(); - switch (new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .saved_message.pdn_type) { + switch (sgw_context.saved_message().pdn_type()) { case IPv4: pgw_handle_allocate_ipv4_address(imsi, apn, "ipv4", context_teid, eps_bearer_id); @@ -136,16 +132,15 @@ void handle_s5_create_session_request( break; default: - Fatal("BAD paa.pdn_type %d", - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .saved_message.pdn_type); + OAILOG_ERROR(LOG_SPGW_APP, "BAD paa.pdn_type %d", + sgw_context.saved_message().pdn_type()); break; } } void spgw_handle_s5_response_with_error( spgw_state_t* spgw_state, - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p, + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p, teid_t context_teid, ebi_t eps_bearer_id, s5_create_session_response_t* s5_response) { s5_response->context_teid = context_teid; @@ -153,8 +148,7 @@ void spgw_handle_s5_response_with_error( s5_response->failure_cause = S5_OK; OAILOG_DEBUG_UE( - LOG_SPGW_APP, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64, + LOG_SPGW_APP, new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64(), "Sending S5 Create Session Response to SGW: with context teid, " TEID_FMT "EPS Bearer Id = %u\n", s5_response->context_teid, s5_response->eps_bearer_id); @@ -176,27 +170,47 @@ void spgw_handle_pcef_create_session_response( s5_response.status = pcef_csr_resp_p->sgi_status; s5_response.failure_cause = S5_OK; - s_plus_p_gw_eps_bearer_context_information_t* bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* bearer_ctxt_info_p = sgw_cm_get_spgw_context(pcef_csr_resp_p->teid); - sgw_eps_bearer_ctxt_t* eps_bearer_ctx_p = sgw_cm_get_eps_bearer_entry( - &bearer_ctxt_info_p->sgw_eps_bearer_context_information.pdn_connection, - s5_response.eps_bearer_id); - - char* apn = (char*)bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.apn_in_use; - eps_bearer_ctx_p->update_teids = true; - char imsi_str[IMSI_BCD_DIGITS_MAX + 1]; - IMSI64_TO_STRING(imsi64, imsi_str, IMSI_BCD_DIGITS_MAX); - + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + if (sgw_cm_get_eps_bearer_entry( + bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + s5_response.eps_bearer_id, &eps_bearer_ctxt) != magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, + "Failed to find eps bearer entry for bearer id %u", + s5_response.eps_bearer_id); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + std::string apn = bearer_ctxt_info_p->sgw_eps_bearer_context() + .pdn_connection() + .apn_in_use(); + eps_bearer_ctxt.set_update_teids(true); + // Updating eps_bearer_ctxt + if (sgw_update_eps_bearer_entry( + bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + s5_response.eps_bearer_id, &eps_bearer_ctxt) != magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE(LOG_SPGW_APP, + bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64(), + "Failed to update bearer context for bearer id :%u\n", + s5_response.eps_bearer_id); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + std::string imsi_str = bearer_ctxt_info_p->sgw_eps_bearer_context().imsi(); if (pcef_csr_resp_p->rpc_status != PCEF_STATUS_OK) { - if ((eps_bearer_ctx_p->paa.pdn_type == IPv4) || - (eps_bearer_ctx_p->paa.pdn_type == IPv4_AND_v6)) { - release_ipv4_address(imsi_str, apn, &eps_bearer_ctx_p->paa.ipv4_address); + struct in_addr ue_ipv4 = {.s_addr = 0}; + struct in6_addr ue_ipv6; + convert_proto_ip_to_standard_ip_fmt(eps_bearer_ctxt.mutable_ue_ip_paa(), + &ue_ipv4, &ue_ipv6, true); + if ((eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4) || + (eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4_AND_v6)) { + release_ipv4_address(imsi_str, apn, &ue_ipv4); } - if ((eps_bearer_ctx_p->paa.pdn_type == IPv6) || - (eps_bearer_ctx_p->paa.pdn_type == IPv4_AND_v6)) { - release_ipv6_address(imsi_str, apn, &eps_bearer_ctx_p->paa.ipv6_address); + if ((eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv6) || + (eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4_AND_v6)) { + release_ipv6_address(imsi_str, apn, &ue_ipv6); } s5_response.failure_cause = PCEF_FAILURE; } @@ -214,14 +228,13 @@ status_code_e spgw_handle_nw_initiated_bearer_actv_req( OAILOG_FUNC_IN(LOG_SPGW_APP); status_code_e rc = RETURNok; state_teid_map_t* state_teid_map = nullptr; - s_plus_p_gw_eps_bearer_context_information_t* spgw_ctxt_p = nullptr; + magma::lte::oai::S11BearerContext* spgw_ctxt_p = nullptr; bool is_imsi_found = false; bool is_lbi_found = false; - OAILOG_INFO_UE( - LOG_SPGW_APP, imsi64, - "Received Create Bearer Req from PCRF with lbi:%d IMSI\n" IMSI_64_FMT, - bearer_req_p->lbi, imsi64); + OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, + "Received Create Bearer Req from PCRF with lbi:%u ", + bearer_req_p->lbi); state_teid_map = get_spgw_teid_state(); if (state_teid_map == nullptr) { @@ -239,13 +252,15 @@ status_code_e spgw_handle_nw_initiated_bearer_actv_req( if (!is_lbi_found) { state_teid_map->get(itr->first, &spgw_ctxt_p); if (spgw_ctxt_p != nullptr) { - if (!strncmp((const char*)spgw_ctxt_p - ->sgw_eps_bearer_context_information.imsi.digit, + if (!strncmp((const char*)spgw_ctxt_p->sgw_eps_bearer_context() + .imsi() + .c_str(), (const char*)bearer_req_p->imsi, strlen((const char*)bearer_req_p->imsi))) { is_imsi_found = true; - if (spgw_ctxt_p->sgw_eps_bearer_context_information.pdn_connection - .default_bearer == bearer_req_p->lbi) { + if (spgw_ctxt_p->sgw_eps_bearer_context() + .pdn_connection() + .default_bearer() == bearer_req_p->lbi) { is_lbi_found = true; break; } @@ -268,11 +283,11 @@ status_code_e spgw_handle_nw_initiated_bearer_actv_req( teid_t s1_u_sgw_fteid = spgw_get_new_s1u_teid(spgw_state); - sgw_eps_bearer_ctxt_t* bearer_ctxt_p = nullptr; - bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_ctxt_p->sgw_eps_bearer_context_information.pdn_connection, - bearer_req_p->lbi); - if (bearer_ctxt_p == nullptr) { + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + if (sgw_cm_get_eps_bearer_entry(spgw_ctxt_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + bearer_req_p->lbi, + &eps_bearer_ctxt) != magma::PROTO_MAP_OK) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "Failed to retrieve bearer ctxt:%u\n", bearer_req_p->lbi); *failed_cause = REQUEST_REJECTED; @@ -281,8 +296,8 @@ status_code_e spgw_handle_nw_initiated_bearer_actv_req( // Create temporary dedicated bearer context rc = create_temporary_dedicated_bearer_context( - &spgw_ctxt_p->sgw_eps_bearer_context_information, bearer_req_p, - bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.pdn_type, + spgw_ctxt_p->mutable_sgw_eps_bearer_context(), bearer_req_p, + eps_bearer_ctxt.sgw_s1u_s12_s4_up_ip_addr().pdn_type(), spgw_state->sgw_ip_address_S1u_S12_S4_up.s_addr, &spgw_state->sgw_ipv6_address_S1u_S12_S4_up, s1_u_sgw_fteid, 0, LOG_SPGW_APP); @@ -296,8 +311,8 @@ status_code_e spgw_handle_nw_initiated_bearer_actv_req( } // Build and send ITTI message, s11_create_bearer_request to MME APP rc = sgw_build_and_send_s11_create_bearer_request( - &spgw_ctxt_p->sgw_eps_bearer_context_information, bearer_req_p, - bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.pdn_type, + spgw_ctxt_p->mutable_sgw_eps_bearer_context(), bearer_req_p, + eps_bearer_ctxt.sgw_s1u_s12_s4_up_ip_addr().pdn_type(), spgw_state->sgw_ip_address_S1u_S12_S4_up.s_addr, &spgw_state->sgw_ipv6_address_S1u_S12_S4_up, s1_u_sgw_fteid, LOG_SPGW_APP); @@ -322,7 +337,7 @@ status_code_e spgw_handle_nw_initiated_bearer_deactv_req( OAILOG_FUNC_IN(LOG_SPGW_APP); status_code_e rc = RETURNok; state_teid_map_t* state_teid_map = nullptr; - s_plus_p_gw_eps_bearer_context_information_t* spgw_ctxt_p = nullptr; + magma::lte::oai::S11BearerContext* spgw_ctxt_p = nullptr; bool is_lbi_found = false; bool is_imsi_found = false; bool is_ebi_found = false; @@ -354,22 +369,26 @@ status_code_e spgw_handle_nw_initiated_bearer_deactv_req( if (!is_lbi_found) { state_teid_map->get(itr->first, &spgw_ctxt_p); if (spgw_ctxt_p != nullptr) { - if (!strcmp((const char*)spgw_ctxt_p->sgw_eps_bearer_context_information - .imsi.digit, - (const char*)bearer_req_p->imsi)) { + if (!strncmp((const char*)spgw_ctxt_p->sgw_eps_bearer_context() + .imsi() + .c_str(), + (const char*)bearer_req_p->imsi, + strlen((const char*)bearer_req_p->imsi))) { is_imsi_found = true; if ((bearer_req_p->lbi != 0) && - (bearer_req_p->lbi == - spgw_ctxt_p->sgw_eps_bearer_context_information.pdn_connection - .default_bearer)) { + (bearer_req_p->lbi == spgw_ctxt_p->sgw_eps_bearer_context() + .pdn_connection() + .default_bearer())) { is_lbi_found = true; // Check if the received EBI is valid for (uint32_t itrn = 0; itrn < bearer_req_p->no_of_bearers; itrn++) { + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; if (sgw_cm_get_eps_bearer_entry( - &spgw_ctxt_p->sgw_eps_bearer_context_information - .pdn_connection, - bearer_req_p->ebi[itrn])) { + spgw_ctxt_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + bearer_req_p->ebi[itrn], + &eps_bearer_ctxt) == magma::PROTO_MAP_OK) { is_ebi_found = true; ebi_to_be_deactivated[no_of_bearers_to_be_deact] = bearer_req_p->ebi[itrn]; @@ -412,8 +431,7 @@ status_code_e spgw_handle_nw_initiated_bearer_deactv_req( rc = spgw_build_and_send_s11_deactivate_bearer_req( imsi64, no_of_bearers_to_be_deact, ebi_to_be_deactivated, delete_default_bearer, - spgw_ctxt_p->sgw_eps_bearer_context_information.mme_teid_S11, - LOG_SPGW_APP); + spgw_ctxt_p->sgw_eps_bearer_context().mme_teid_s11(), LOG_SPGW_APP); } OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); } @@ -518,7 +536,8 @@ status_code_e spgw_handle_nw_init_deactivate_bearer_rsp(gtpv2c_cause_t cause, // Build and send ITTI message, s11_create_bearer_request to MME APP status_code_e sgw_build_and_send_s11_create_bearer_request( - sgw_eps_bearer_context_information_t* sgw_eps_bearer_context_information, + magma::lte::oai::SgwEpsBearerContextInfo* + sgw_eps_bearer_context_information, const itti_gx_nw_init_actv_bearer_request_t* const bearer_req_p, pdn_type_t pdn_type, uint32_t sgw_ip_address_S1u_S12_S4_up, struct in6_addr* sgw_ipv6_address_S1u_S12_S4_up, teid_t s1_u_sgw_fteid, @@ -531,7 +550,7 @@ status_code_e sgw_build_and_send_s11_create_bearer_request( (module == LOG_SPGW_APP ? TASK_SPGW_APP : TASK_SGW_S8), S11_NW_INITIATED_ACTIVATE_BEARER_REQUEST); if (!message_p) { - OAILOG_ERROR_UE(module, sgw_eps_bearer_context_information->imsi64, + OAILOG_ERROR_UE(module, sgw_eps_bearer_context_information->imsi64(), "Failed to allocate message_p for" "S11_NW_INITIATED_BEARER_ACTV_REQUEST\n"); OAILOG_FUNC_RETURN(module, rc); @@ -543,7 +562,7 @@ status_code_e sgw_build_and_send_s11_create_bearer_request( sizeof(itti_s11_nw_init_actv_bearer_request_t)); // Context TEID s11_actv_bearer_request->s11_mme_teid = - sgw_eps_bearer_context_information->mme_teid_S11; + sgw_eps_bearer_context_information->mme_teid_s11(); // LBI s11_actv_bearer_request->lbi = bearer_req_p->lbi; // UL TFT to be sent to UE @@ -567,8 +586,8 @@ status_code_e sgw_build_and_send_s11_create_bearer_request( sgw_ipv6_address_S1u_S12_S4_up, sizeof(s11_actv_bearer_request->s1_u_sgw_fteid.ipv6_address)); } - message_p->ittiMsgHeader.imsi = sgw_eps_bearer_context_information->imsi64; - OAILOG_INFO_UE(module, sgw_eps_bearer_context_information->imsi64, + message_p->ittiMsgHeader.imsi = sgw_eps_bearer_context_information->imsi64(); + OAILOG_INFO_UE(module, sgw_eps_bearer_context_information->imsi64(), "Sending S11 Create Bearer Request to MME_APP for LBI %d \n", bearer_req_p->lbi); if (module == LOG_SPGW_APP) { @@ -576,7 +595,7 @@ status_code_e sgw_build_and_send_s11_create_bearer_request( } else if (module == LOG_SGW_S8) { rc = send_msg_to_task(&sgw_s8_task_zmq_ctx, TASK_MME_APP, message_p); } else { - OAILOG_ERROR_UE(module, sgw_eps_bearer_context_information->imsi64, + OAILOG_ERROR_UE(module, sgw_eps_bearer_context_information->imsi64(), "Invalid module \n"); } OAILOG_FUNC_RETURN(module, rc); @@ -584,114 +603,125 @@ status_code_e sgw_build_and_send_s11_create_bearer_request( // Create temporary dedicated bearer context status_code_e create_temporary_dedicated_bearer_context( - sgw_eps_bearer_context_information_t* sgw_ctxt_p, + magma::lte::oai::SgwEpsBearerContextInfo* sgw_ctxt_p, const itti_gx_nw_init_actv_bearer_request_t* const bearer_req_p, pdn_type_t pdn_type, uint32_t sgw_ip_address_S1u_S12_S4_up, struct in6_addr* sgw_ipv6_address_S1u_S12_S4_up, teid_t s1_u_sgw_fteid, uint32_t sequence_number, log_proto_t module) { OAILOG_FUNC_IN(module); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = new sgw_eps_bearer_ctxt_t(); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; // Copy PAA from default bearer cntxt - sgw_eps_bearer_ctxt_t* default_eps_bearer_entry_p = - sgw_cm_get_eps_bearer_entry(&sgw_ctxt_p->pdn_connection, - sgw_ctxt_p->pdn_connection.default_bearer); - - if (!default_eps_bearer_entry_p) { - OAILOG_ERROR_UE(module, sgw_ctxt_p->imsi64, + magma::lte::oai::SgwEpsBearerContext default_eps_bearer_entry; + if (sgw_cm_get_eps_bearer_entry(sgw_ctxt_p->mutable_pdn_connection(), + sgw_ctxt_p->pdn_connection().default_bearer(), + &default_eps_bearer_entry) != + magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE(module, sgw_ctxt_p->imsi64(), "Failed to get default bearer context\n"); OAILOG_FUNC_RETURN(module, RETURNerror); } - eps_bearer_ctxt_p->eps_bearer_id = 0; - eps_bearer_ctxt_p->paa = default_eps_bearer_entry_p->paa; + eps_bearer_ctxt.set_eps_bearer_id(0); + eps_bearer_ctxt.mutable_ue_ip_paa()->MergeFrom( + default_eps_bearer_entry.ue_ip_paa()); // SGW FTEID - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up = s1_u_sgw_fteid; + eps_bearer_ctxt.set_sgw_teid_s1u_s12_s4_up(s1_u_sgw_fteid); if (pdn_type == IPv4 || pdn_type == IPv4_AND_v6) { - eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.pdn_type = IPv4; - eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.address.ipv4_address - .s_addr = sgw_ip_address_S1u_S12_S4_up; + eps_bearer_ctxt.mutable_sgw_s1u_s12_s4_up_ip_addr()->set_pdn_type(IPv4); + char ip4_str[INET_ADDRSTRLEN]; + inet_ntop(AF_INET, &sgw_ip_address_S1u_S12_S4_up, ip4_str, INET_ADDRSTRLEN); + eps_bearer_ctxt.mutable_sgw_s1u_s12_s4_up_ip_addr()->set_ipv4_addr(ip4_str); } else { - eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.pdn_type = IPv6; - memcpy( - &eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.address.ipv6_address, - &sgw_ipv6_address_S1u_S12_S4_up, - sizeof(eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.address - .ipv6_address)); + char ip6_str[INET6_ADDRSTRLEN]; + eps_bearer_ctxt.mutable_sgw_s1u_s12_s4_up_ip_addr()->set_pdn_type(IPv6); + inet_ntop(AF_INET6, sgw_ipv6_address_S1u_S12_S4_up, ip6_str, + INET6_ADDRSTRLEN); + eps_bearer_ctxt.mutable_sgw_s1u_s12_s4_up_ip_addr()->set_ipv6_addr(ip6_str); } // DL TFT - memcpy(&eps_bearer_ctxt_p->tft, &bearer_req_p->dl_tft, - sizeof(traffic_flow_template_t)); + traffic_flow_template_to_proto(&bearer_req_p->dl_tft, + eps_bearer_ctxt.mutable_tft()); // QoS - memcpy(&eps_bearer_ctxt_p->eps_bearer_qos, &bearer_req_p->eps_bearer_qos, - sizeof(bearer_qos_t)); + eps_bearer_qos_to_proto(&bearer_req_p->eps_bearer_qos, + eps_bearer_ctxt.mutable_eps_bearer_qos()); // Save Policy Rule Name - snprintf(eps_bearer_ctxt_p->policy_rule_name, POLICY_RULE_NAME_MAXLEN + 1, - "%s", bearer_req_p->policy_rule_name); - eps_bearer_ctxt_p->sgw_sequence_number = sequence_number; - OAILOG_INFO_UE(module, sgw_ctxt_p->imsi64, + eps_bearer_ctxt.set_policy_rule_name( + bearer_req_p->policy_rule_name, + strlen(bearer_req_p->policy_rule_name) + 1); + eps_bearer_ctxt.set_sgw_sequence_number(sequence_number); + OAILOG_INFO_UE(module, sgw_ctxt_p->imsi64(), "Number of DL packet filter rules: %d\n", - eps_bearer_ctxt_p->tft.numberofpacketfilters); - - // Create temporary spgw bearer context entry - pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = - pgw_get_procedure_create_bearer(sgw_ctxt_p); - if (!pgw_ni_cbr_proc) { - OAILOG_DEBUG_UE(module, sgw_ctxt_p->imsi64, - "Creating a new temporary eps bearer context entry\n"); - pgw_ni_cbr_proc = pgw_create_procedure_create_bearer(sgw_ctxt_p); - if (!pgw_ni_cbr_proc) { - OAILOG_ERROR_UE(module, sgw_ctxt_p->imsi64, - "Failed to create temporary eps bearer context entry\n"); - OAILOG_FUNC_RETURN(module, RETURNerror); - } - } - struct sgw_eps_bearer_entry_wrapper_s* sgw_eps_bearer_entry_p = - new sgw_eps_bearer_entry_wrapper_s(); - sgw_eps_bearer_entry_p->sgw_eps_bearer_entry = eps_bearer_ctxt_p; - LIST_INSERT_HEAD((pgw_ni_cbr_proc->pending_eps_bearers), - sgw_eps_bearer_entry_p, entries); + eps_bearer_ctxt.tft().number_of_packet_filters()); + + // Create temporary bearer context for NW initiated dedicated bearer request + magma::lte::oai::PgwCbrProcedure* pgw_ni_cbr_proc = + sgw_ctxt_p->add_pending_procedures(); + pgw_ni_cbr_proc->set_type( + PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST); + magma::lte::oai::SgwEpsBearerContext* eps_bearer_proto = + pgw_ni_cbr_proc->add_pending_eps_bearers(); + eps_bearer_proto->MergeFrom(eps_bearer_ctxt); + OAILOG_FUNC_RETURN(module, RETURNok); } // Deletes temporary dedicated bearer context static void delete_temporary_dedicated_bearer_context( teid_t s1_u_sgw_fteid, ebi_t lbi, - s_plus_p_gw_eps_bearer_context_information_t* spgw_context_p) { + magma::lte::oai::S11BearerContext* spgw_context_p) { OAILOG_FUNC_IN(LOG_SPGW_APP); - pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = NULL; - struct sgw_eps_bearer_entry_wrapper_s* spgw_eps_bearer_entry_p = nullptr; - pgw_ni_cbr_proc = pgw_get_procedure_create_bearer( - &spgw_context_p->sgw_eps_bearer_context_information); - if (!pgw_ni_cbr_proc) { - OAILOG_ERROR_UE( - LOG_SPGW_APP, spgw_context_p->sgw_eps_bearer_context_information.imsi64, - "Failed to get Create bearer procedure from temporary stored contexts " - "for lbi :%u \n", - lbi); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + magma::lte::oai::PgwCbrProcedure* pgw_ni_cbr_proc = nullptr; + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + spgw_context_p->mutable_sgw_eps_bearer_context(); + + if (!(sgw_context_p->pending_procedures_size())) { + OAILOG_ERROR_UE(LOG_SPGW_APP, + spgw_context_p->sgw_eps_bearer_context().imsi64(), + "No temporary bearer contexts stored for lbi :%u \n", lbi); OAILOG_FUNC_OUT(LOG_SPGW_APP); } + OAILOG_INFO_UE(LOG_SPGW_APP, - spgw_context_p->sgw_eps_bearer_context_information.imsi64, + spgw_context_p->sgw_eps_bearer_context().imsi64(), "Delete temporary bearer context for lbi :%u \n", lbi); - spgw_eps_bearer_entry_p = LIST_FIRST(pgw_ni_cbr_proc->pending_eps_bearers); - while (spgw_eps_bearer_entry_p) { - if (s1_u_sgw_fteid == spgw_eps_bearer_entry_p->sgw_eps_bearer_entry - ->s_gw_teid_S1u_S12_S4_up) { - // Remove the temporary spgw entry - LIST_REMOVE(spgw_eps_bearer_entry_p, entries); - if (spgw_eps_bearer_entry_p->sgw_eps_bearer_entry) { - free_cpp_wrapper(reinterpret_cast( - &spgw_eps_bearer_entry_p->sgw_eps_bearer_entry)); + + uint8_t num_of_bearers_deleted = 0; + uint8_t num_of_pending_procedures = sgw_context_p->pending_procedures_size(); + for (uint8_t proc_index = 0; + proc_index < sgw_context_p->pending_procedures_size(); proc_index++) { + pgw_ni_cbr_proc = sgw_context_p->mutable_pending_procedures(proc_index); + if (!pgw_ni_cbr_proc) { + OAILOG_ERROR_UE( + LOG_SPGW_APP, spgw_context_p->sgw_eps_bearer_context().imsi64(), + "Pending procedure within sgw_context is null for " + "proc_index:%u and s1u_teid " TEID_FMT, + proc_index, + pgw_ni_cbr_proc->pending_eps_bearers(0).sgw_teid_s1u_s12_s4_up()); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + if (pgw_ni_cbr_proc->type() == + PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST) { + num_of_bearers_deleted = pgw_ni_cbr_proc->pending_eps_bearers_size(); + for (uint8_t bearer_index = 0; + bearer_index < pgw_ni_cbr_proc->pending_eps_bearers_size(); + bearer_index++) { + magma::lte::oai::SgwEpsBearerContext bearer_context = + pgw_ni_cbr_proc->pending_eps_bearers(bearer_index); + if (bearer_context.sgw_teid_s1u_s12_s4_up() == s1_u_sgw_fteid) { + --num_of_bearers_deleted; + } + } // end of bearer index loop + if (num_of_bearers_deleted == 0) { + pgw_ni_cbr_proc->clear_pending_eps_bearers(); + --num_of_pending_procedures; } - free_cpp_wrapper(reinterpret_cast(&spgw_eps_bearer_entry_p)); - break; } - spgw_eps_bearer_entry_p = LIST_NEXT(spgw_eps_bearer_entry_p, entries); - } - if (LIST_EMPTY(pgw_ni_cbr_proc->pending_eps_bearers)) { - pgw_free_procedure_create_bearer((pgw_ni_cbr_proc_t**)&pgw_ni_cbr_proc); + } // end of procedure index loop + if (num_of_pending_procedures == 0) { + sgw_context_p->clear_pending_procedures(); } OAILOG_FUNC_OUT(LOG_SPGW_APP); } diff --git a/lte/gateway/c/core/oai/tasks/sgw/pgw_handlers.hpp b/lte/gateway/c/core/oai/tasks/sgw/pgw_handlers.hpp index 9fce147bc6d9..bca972fa33db 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/pgw_handlers.hpp +++ b/lte/gateway/c/core/oai/tasks/sgw/pgw_handlers.hpp @@ -37,7 +37,7 @@ extern "C" { void handle_s5_create_session_request( spgw_state_t* spgw_state, - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p, + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p, teid_t context_teid, ebi_t eps_bearer_id); void spgw_handle_pcef_create_session_response( diff --git a/lte/gateway/c/core/oai/tasks/sgw/pgw_pco.cpp b/lte/gateway/c/core/oai/tasks/sgw/pgw_pco.cpp index 1c4ad0b5a36b..3e4312d5af4b 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/pgw_pco.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw/pgw_pco.cpp @@ -69,13 +69,13 @@ status_code_e pgw_pco_push_protocol_or_container_id( //------------------------------------------------------------------------------ status_code_e pgw_process_pco_request_ipcp( protocol_configuration_options_t* const pco_resp, - const pco_protocol_or_container_id_t* const poc_id) { + const magma::lte::oai::PcoProtocol poc_id) { in_addr_t ipcp_dns_prim_ipv4_addr = INADDR_NONE; in_addr_t ipcp_dns_sec_ipv4_addr = INADDR_NONE; in_addr_t ipcp_out_dns_prim_ipv4_addr = INADDR_NONE; in_addr_t ipcp_out_dns_sec_ipv4_addr = INADDR_NONE; pco_protocol_or_container_id_t poc_id_resp = {0}; - int16_t ipcp_req_remaining_length = poc_id->length; + int16_t ipcp_req_remaining_length = poc_id.length(); size_t pco_in_index = 0; int8_t ipcp_req_code = 0; @@ -92,22 +92,23 @@ status_code_e pgw_process_pco_request_ipcp( int16_t ipcp_out_length = 0; OAILOG_DEBUG(LOG_SPGW_APP, "PCO: Protocol identifier IPCP length %u\n", - poc_id->length); + poc_id.length()); - ipcp_req_code = poc_id->contents->data[pco_in_index++]; - ipcp_req_identifier = poc_id->contents->data[pco_in_index++]; - ipcp_req_length = (((int16_t)poc_id->contents->data[pco_in_index]) << 8) | - ((int16_t)poc_id->contents->data[pco_in_index + 1]); + std::string contents = poc_id.contents(); + ipcp_req_code = contents[pco_in_index++]; + ipcp_req_identifier = contents[pco_in_index++]; + ipcp_req_length = (((int16_t)contents[pco_in_index]) << 8) | + ((int16_t)contents[pco_in_index + 1]); OAILOG_TRACE( LOG_SPGW_APP, "PCO: Protocol identifier IPCP (0x%x) code 0x%x identifier 0x%x length " "%i\n", - poc_id->id, ipcp_req_code, ipcp_req_identifier, ipcp_req_length); + poc_id.id(), ipcp_req_code, ipcp_req_identifier, ipcp_req_length); pco_in_index += 2; ipcp_req_remaining_length = ipcp_req_remaining_length - 1 - 1 - 2; ipcp_out_length = 1 + 1 + 2; - poc_id_resp.id = poc_id->id; + poc_id_resp.id = poc_id.id(); poc_id_resp.length = 0; // fill value after parsing req uint8_t cil[4] = {0}; // code, identifier, length poc_id_resp.contents = blk2bstr(cil, 4); // fill values after parsing req @@ -115,8 +116,8 @@ status_code_e pgw_process_pco_request_ipcp( ipcp_out_code = IPCP_CODE_CONFIGURE_ACK; while (ipcp_req_remaining_length >= 2) { - ipcp_req_option = poc_id->contents->data[pco_in_index]; - ipcp_req_option_length = poc_id->contents->data[pco_in_index + 1]; + ipcp_req_option = contents[pco_in_index]; + ipcp_req_option_length = contents[pco_in_index + 1]; ipcp_req_remaining_length = ipcp_req_remaining_length - ipcp_req_option_length; OAILOG_TRACE( @@ -143,11 +144,11 @@ status_code_e pgw_process_pco_request_ipcp( "length %i\n", ipcp_req_option_length); if (ipcp_req_option_length >= 6) { - ipcp_dns_prim_ipv4_addr = htonl( - (((uint32_t)poc_id->contents->data[pco_in_index + 2]) << 24) | - (((uint32_t)poc_id->contents->data[pco_in_index + 3]) << 16) | - (((uint32_t)poc_id->contents->data[pco_in_index + 4]) << 8) | - (((uint32_t)poc_id->contents->data[pco_in_index + 5]))); + ipcp_dns_prim_ipv4_addr = + htonl((((uint32_t)contents[pco_in_index + 2]) << 24) | + (((uint32_t)contents[pco_in_index + 3]) << 16) | + (((uint32_t)contents[pco_in_index + 4]) << 8) | + (((uint32_t)contents[pco_in_index + 5]))); OAILOG_DEBUG( LOG_SPGW_APP, "PCO: Protocol identifier IPCP option " @@ -207,11 +208,11 @@ status_code_e pgw_process_pco_request_ipcp( ipcp_req_option_length); if (ipcp_req_option_length >= 6) { - ipcp_dns_sec_ipv4_addr = htonl( - (((uint32_t)poc_id->contents->data[pco_in_index + 2]) << 24) | - (((uint32_t)poc_id->contents->data[pco_in_index + 3]) << 16) | - (((uint32_t)poc_id->contents->data[pco_in_index + 4]) << 8) | - (((uint32_t)poc_id->contents->data[pco_in_index + 5]))); + ipcp_dns_sec_ipv4_addr = + htonl((((uint32_t)contents[pco_in_index + 2]) << 24) | + (((uint32_t)contents[pco_in_index + 3]) << 16) | + (((uint32_t)contents[pco_in_index + 4]) << 8) | + (((uint32_t)contents[pco_in_index + 5]))); OAILOG_DEBUG( LOG_SPGW_APP, "PCO: Protocol identifier IPCP option " @@ -269,8 +270,7 @@ status_code_e pgw_process_pco_request_ipcp( //------------------------------------------------------------------------------ status_code_e pgw_process_pco_dns_server_request( - protocol_configuration_options_t* const pco_resp, - const pco_protocol_or_container_id_t* const poc_id) { + protocol_configuration_options_t* const pco_resp) { in_addr_t ipcp_out_dns_prim_ipv4_addr = spgw_config.pgw_config.ipv4.default_dns.s_addr; pco_protocol_or_container_id_t poc_id_resp = {0}; @@ -290,8 +290,7 @@ status_code_e pgw_process_pco_dns_server_request( } //------------------------------------------------------------------------------ status_code_e pgw_process_pco_link_mtu_request( - protocol_configuration_options_t* const pco_resp, - const pco_protocol_or_container_id_t* const poc_id) { + protocol_configuration_options_t* const pco_resp) { pco_protocol_or_container_id_t poc_id_resp = {0}; uint8_t mtu_array[2]; @@ -378,41 +377,39 @@ status_code_e pgw_process_pco_dns_server_ipv6_address_req( } //------------------------------------------------------------------------------ - status_code_e pgw_process_pco_request( - const protocol_configuration_options_t* const pco_req, + const magma::lte::oai::Pco* const pco_req, protocol_configuration_options_t* pco_resp, protocol_configuration_options_ids_t* const pco_ids) { OAILOG_FUNC_IN(LOG_SPGW_APP); status_code_e rc = RETURNok; memset(pco_ids, 0, sizeof *pco_ids); - switch (pco_req->configuration_protocol) { + switch (pco_req->configuration_protocol()) { case PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE: pco_resp->ext = 1; pco_resp->spare = 0; pco_resp->num_protocol_or_container_id = 0; - pco_resp->configuration_protocol = pco_req->configuration_protocol; + pco_resp->configuration_protocol = pco_req->configuration_protocol(); break; default: OAILOG_WARNING(LOG_SPGW_APP, "PCO: configuration protocol 0x%X not supported now\n", - pco_req->configuration_protocol); + pco_req->configuration_protocol()); break; } - for (int id = 0; id < pco_req->num_protocol_or_container_id; id++) { - switch (pco_req->protocol_or_container_ids[id].id) { + for (uint8_t id = 0; id < pco_req->num_protocol_or_container_id(); id++) { + magma::lte::oai::PcoProtocol pco_protocol = pco_req->pco_protocol(id); + switch (pco_protocol.id()) { case PCO_PI_IPCP: - rc = pgw_process_pco_request_ipcp( - pco_resp, &pco_req->protocol_or_container_ids[id]); + rc = pgw_process_pco_request_ipcp(pco_resp, pco_protocol); pco_ids->pi_ipcp = true; break; case PCO_CI_DNS_SERVER_IPV4_ADDRESS_REQUEST: - rc = pgw_process_pco_dns_server_request( - pco_resp, &pco_req->protocol_or_container_ids[id]); + rc = pgw_process_pco_dns_server_request(pco_resp); pco_ids->ci_dns_server_ipv4_address_request = true; break; @@ -423,8 +420,7 @@ status_code_e pgw_process_pco_request( break; case PCO_CI_IPV4_LINK_MTU_REQUEST: - rc = pgw_process_pco_link_mtu_request( - pco_resp, &pco_req->protocol_or_container_ids[id]); + rc = pgw_process_pco_link_mtu_request(pco_resp); pco_ids->ci_ipv4_link_mtu_request = true; break; @@ -444,17 +440,17 @@ status_code_e pgw_process_pco_request( OAILOG_WARNING( LOG_SPGW_APP, "PCO: Protocol/container identifier 0x%04X not supported now\n", - pco_req->protocol_or_container_ids[id].id); + pco_protocol.id()); } } if (spgw_config.pgw_config.force_push_pco) { pco_ids->ci_ip_address_allocation_via_nas_signaling = true; if (!pco_ids->ci_dns_server_ipv4_address_request) { - pgw_process_pco_dns_server_request(pco_resp, NULL); + pgw_process_pco_dns_server_request(pco_resp); } if (!pco_ids->ci_ipv4_link_mtu_request) { - pgw_process_pco_link_mtu_request(pco_resp, NULL); + pgw_process_pco_link_mtu_request(pco_resp); } } return rc; diff --git a/lte/gateway/c/core/oai/tasks/sgw/pgw_pco.hpp b/lte/gateway/c/core/oai/tasks/sgw/pgw_pco.hpp index 052707b2eb7b..3849a204e4fc 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/pgw_pco.hpp +++ b/lte/gateway/c/core/oai/tasks/sgw/pgw_pco.hpp @@ -26,6 +26,8 @@ #include +#include "lte/protos/oai/std_3gpp_types.pb.h" +#include "lte/protos/oai/spgw_state.pb.h" #include "lte/gateway/c/core/common/common_defs.h" #include "lte/gateway/c/core/oai/lib/3gpp/3gpp_24.008.h" @@ -54,17 +56,15 @@ status_code_e pgw_pco_push_protocol_or_container_id( status_code_e pgw_process_pco_request_ipcp( protocol_configuration_options_t* const pco_resp, - const pco_protocol_or_container_id_t* const poc_id); + const magma::lte::oai::PcoProtocol poc_id); status_code_e pgw_process_pco_dns_server_request( - protocol_configuration_options_t* const pco_resp, - const pco_protocol_or_container_id_t* const poc_id); + protocol_configuration_options_t* const pco_resp); status_code_e pgw_process_pco_link_mtu_request( - protocol_configuration_options_t* const pco_resp, - const pco_protocol_or_container_id_t* const poc_id); + protocol_configuration_options_t* const pco_resp); status_code_e pgw_process_pco_request( - const protocol_configuration_options_t* const pco_req, + const magma::lte::oai::Pco* const pco_req, protocol_configuration_options_t* pco_resp, protocol_configuration_options_ids_t* const pco_ids); diff --git a/lte/gateway/c/core/oai/tasks/sgw/pgw_procedures.cpp b/lte/gateway/c/core/oai/tasks/sgw/pgw_procedures.cpp index 13918eae31ca..1bab4b63bf9f 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/pgw_procedures.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw/pgw_procedures.cpp @@ -89,24 +89,6 @@ pgw_ni_cbr_proc_t* pgw_get_procedure_create_bearer( return NULL; } //------------------------------------------------------------------------------ -void pgw_delete_procedure_create_bearer( - s_plus_p_gw_eps_bearer_context_information_t* const ctx_p) { - if (ctx_p->sgw_eps_bearer_context_information.pending_procedures) { - pgw_base_proc_t* base_proc = NULL; - - LIST_FOREACH(base_proc, - ctx_p->sgw_eps_bearer_context_information.pending_procedures, - entries) { - if (PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST == - base_proc->type) { - LIST_REMOVE(base_proc, entries); - pgw_free_procedure_create_bearer((pgw_ni_cbr_proc_t**)&base_proc); - return; - } - } - } -} -//------------------------------------------------------------------------------ void pgw_free_procedure_create_bearer(pgw_ni_cbr_proc_t** ni_cbr_proc) { if (*ni_cbr_proc && (*ni_cbr_proc)->pending_eps_bearers) { sgw_eps_bearer_entry_wrapper_t* eps_bearer_entry_wrapper = NULL; diff --git a/lte/gateway/c/core/oai/tasks/sgw/pgw_procedures.hpp b/lte/gateway/c/core/oai/tasks/sgw/pgw_procedures.hpp index 3b0ad964d9d9..0cd6d4ead541 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/pgw_procedures.hpp +++ b/lte/gateway/c/core/oai/tasks/sgw/pgw_procedures.hpp @@ -67,5 +67,3 @@ pgw_ni_cbr_proc_t* pgw_get_procedure_create_bearer( #endif pgw_ni_cbr_proc_t* pgw_create_procedure_create_bearer( sgw_eps_bearer_context_information_t* const ctx_p); -void pgw_delete_procedure_create_bearer( - s_plus_p_gw_eps_bearer_context_information_t* ctx_p); diff --git a/lte/gateway/c/core/oai/tasks/sgw/pgw_ue_ip_address_alloc.hpp b/lte/gateway/c/core/oai/tasks/sgw/pgw_ue_ip_address_alloc.hpp index 99031be857df..2b671e59356a 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/pgw_ue_ip_address_alloc.hpp +++ b/lte/gateway/c/core/oai/tasks/sgw/pgw_ue_ip_address_alloc.hpp @@ -26,18 +26,13 @@ #include #include +#include #include "lte/gateway/c/core/oai/include/ip_forward_messages_types.h" -void release_ue_ipv4_address(const char* imsi, const char* apn, +void release_ue_ipv4_address(const std::string imsi, const std::string apn, struct in_addr* addr); - -#ifdef __cplusplus -extern "C" { -#endif int get_ip_block(struct in_addr* netaddr, uint32_t* netmask); -#ifdef __cplusplus -} -#endif -void release_ue_ipv6_address(const char* imsi, const char* apn, + +void release_ue_ipv6_address(const std::string imsi, const std::string apn, struct in6_addr* addr); diff --git a/lte/gateway/c/core/oai/tasks/sgw/sgw_context_manager.cpp b/lte/gateway/c/core/oai/tasks/sgw/sgw_context_manager.cpp index d41a4990453e..f56b81c93b71 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/sgw_context_manager.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw/sgw_context_manager.cpp @@ -46,6 +46,19 @@ extern "C" { //----------------------------------------------------------------------------- void sgw_display_sgw_eps_bearer_context( + const magma::lte::oai::SgwEpsBearerContext* const eps_bearer_ctxt) { + if (eps_bearer_ctxt) { + OAILOG_DEBUG(LOG_SPGW_APP, + "|\t\t\t\tebi: %u, enb_teid_for_S1u: " TEID_FMT + ", s_gw_teid_for_S1u_S12_S4_up: " TEID_FMT " (tbc)\n", + eps_bearer_ctxt->eps_bearer_id(), + eps_bearer_ctxt->enb_teid_s1u(), + eps_bearer_ctxt->sgw_teid_s1u_s12_s4_up()); + } +} + +//----------------------------------------------------------------------------- +void sgw_s8_display_sgw_eps_bearer_context( const sgw_eps_bearer_ctxt_t* const eps_bearer_ctxt) //----------------------------------------------------------------------------- { @@ -60,6 +73,47 @@ void sgw_display_sgw_eps_bearer_context( //----------------------------------------------------------------------------- void sgw_display_s11_bearer_context_information( + log_proto_t module, + magma::lte::oai::S11BearerContext* sgw_context_information) { + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + sgw_context_information->mutable_sgw_eps_bearer_context(); + OAILOG_DEBUG(module, "| KEY %" PRId64 ": \n", sgw_context_p->imsi64()); + OAILOG_DEBUG(module, "|\tsgw_eps_bearer_context_information: |\n"); + // Imsi_t imsi; ///< IMSI + // (International Mobile Subscriber Identity) is the subscriber permanent + // identity. + OAILOG_DEBUG(module, "|\t\timsi_unauthenticated_indicator:\t%u\n", + sgw_context_p->imsi_unauth_indicator()); + // char msisdn[MSISDN_LENGTH]; ///< The basic MSISDN + // of the UE. The presence is dictated by its storage in the HSS. + OAILOG_DEBUG(module, "|\t\tmme_teid_ S11: \t" TEID_FMT "\n", + sgw_context_p->mme_teid_s11()); + // ip_address_t mme_ip_address_for_S11; ///< MME IP address + // the S11 interface. + OAILOG_DEBUG(module, "|\t\ts_gw_teid_S11_S4: \t" TEID_FMT "\n", + sgw_context_p->sgw_teid_s11_s4()); + // ip_address_t s_gw_ip_address_for_S11_S4; ///< S-GW IP address + // for the S11 interface and the S4 Interface (control plane). cgi_t + // last_known_cell_Id; ///< This is the last location of the UE + // known by the network + OAILOG_DEBUG(module, "|\t\tpdn_connection:\n"); + OAILOG_DEBUG(module, "|\t\t\tapn_in_use: %s\n", + sgw_context_p->pdn_connection().apn_in_use().c_str()); + OAILOG_DEBUG(module, "|\t\t\tdefault_bearer: %u\n", + sgw_context_p->pdn_connection().default_bearer()); + OAILOG_DEBUG(module, "|\t\t\teps_bearers:\n"); + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = + sgw_context_p->mutable_pdn_connection()->mutable_eps_bearer_map(); + for (auto itr = eps_bearer_map.map->begin(); itr != eps_bearer_map.map->end(); + itr++) { + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt = itr->second; + sgw_display_sgw_eps_bearer_context(&eps_bearer_ctxt); + } +} + +//----------------------------------------------------------------------------- +void sgw_s8_display_s11_bearer_context_information( log_proto_t module, sgw_eps_bearer_context_information_t* sgw_context_information) //----------------------------------------------------------------------------- @@ -90,12 +144,10 @@ void sgw_display_s11_bearer_context_information( OAILOG_DEBUG(module, "|\t\t\tdefault_bearer: %u\n", sgw_context_information->pdn_connection.default_bearer); OAILOG_DEBUG(module, "|\t\t\teps_bearers:\n"); - for (int ebix = 0; ebix < BEARERS_PER_UE; ebix++) { - sgw_display_sgw_eps_bearer_context( + for (uint8_t ebix = 0; ebix < BEARERS_PER_UE; ebix++) { + sgw_s8_display_sgw_eps_bearer_context( sgw_context_information->pdn_connection.sgw_eps_bearers_array[ebix]); } - // void *trxn; - // uint32_t peer_ip; } //----------------------------------------------------------------------------- @@ -111,12 +163,10 @@ mme_sgw_tunnel_t* sgw_cm_create_s11_tunnel(teid_t remote_teid, } //----------------------------------------------------------------------------- -s_plus_p_gw_eps_bearer_context_information_t* +magma::lte::oai::S11BearerContext* sgw_cm_create_bearer_context_information_in_collection(teid_t teid) { - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_context_information = - nullptr; - new_bearer_context_information = - new s_plus_p_gw_eps_bearer_context_information_t(); + magma::lte::oai::S11BearerContext* new_bearer_context_information = + new magma::lte::oai::S11BearerContext(); /* * Trying to insert the new tunnel into the map. @@ -130,8 +180,8 @@ sgw_cm_create_bearer_context_information_in_collection(teid_t teid) { state_teid_map->insert(teid, new_bearer_context_information); OAILOG_DEBUG(LOG_SPGW_APP, - "Added new s_plus_p_gw_eps_bearer_context_information_t in " - "state_teid_map for TEID " TEID_FMT "\n", + "Added new s_plus_p_gw_eps_bearer_context in " + "state_teid_map for key TEID " TEID_FMT "\n", teid); return new_bearer_context_information; } @@ -213,34 +263,47 @@ sgw_eps_bearer_ctxt_t* sgw_cm_create_eps_bearer_ctxt_in_collection( return new_eps_bearer_entry; } //----------------------------------------------------------------------------- -sgw_eps_bearer_ctxt_t* sgw_cm_insert_eps_bearer_ctxt_in_collection( - sgw_pdn_connection_t* const sgw_pdn_connection, - sgw_eps_bearer_ctxt_t* const sgw_eps_bearer_ctxt) { +magma::proto_map_rc_t sgw_cm_insert_eps_bearer_ctxt_in_collection( + magma::lte::oai::SgwPdnConnection* const sgw_pdn_connection, + magma::lte::oai::SgwEpsBearerContext* const sgw_eps_bearer_ctxt) { if (!sgw_eps_bearer_ctxt) { OAILOG_ERROR(LOG_SPGW_APP, "Failed to insert EPS bearer context : nullptr context\n"); - return nullptr; + return magma::PROTO_MAP_BAD_PARAMETER_VALUE; } - if (!sgw_pdn_connection->sgw_eps_bearers_array[EBI_TO_INDEX( - sgw_eps_bearer_ctxt->eps_bearer_id)]) { - sgw_pdn_connection->sgw_eps_bearers_array[EBI_TO_INDEX( - sgw_eps_bearer_ctxt->eps_bearer_id)] = sgw_eps_bearer_ctxt; + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = sgw_pdn_connection->mutable_eps_bearer_map(); + magma::proto_map_rc_t rc = eps_bearer_map.insert( + sgw_eps_bearer_ctxt->eps_bearer_id(), *sgw_eps_bearer_ctxt); + if (rc == magma::PROTO_MAP_OK) { OAILOG_DEBUG(LOG_SPGW_APP, "Inserted new EPS bearer entry for EPS bearer id %u \n", - sgw_eps_bearer_ctxt->eps_bearer_id); + sgw_eps_bearer_ctxt->eps_bearer_id()); } else { - OAILOG_WARNING( - LOG_SPGW_APP, - "Could not create mew EPS bearer ctxt for EPS bearer id %u : already " - "exist\n", - sgw_eps_bearer_ctxt->eps_bearer_id); + OAILOG_WARNING(LOG_SPGW_APP, + "Could not create new EPS bearer ctxt for EPS bearer id %u: " + "for error:%s ", + sgw_eps_bearer_ctxt->eps_bearer_id(), + map_rc_code2string(rc)); } - return sgw_eps_bearer_ctxt; + return rc; } //----------------------------------------------------------------------------- -sgw_eps_bearer_ctxt_t* sgw_cm_get_eps_bearer_entry( +magma::proto_map_rc_t sgw_cm_get_eps_bearer_entry( + magma::lte::oai::SgwPdnConnection* const sgw_pdn_connection, ebi_t ebi, + magma::lte::oai::SgwEpsBearerContext* bearer_context_p) { + if ((ebi < EPS_BEARER_IDENTITY_FIRST) || (ebi > EPS_BEARER_IDENTITY_LAST)) { + return magma::PROTO_MAP_KEY_NOT_EXISTS; + } + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = sgw_pdn_connection->mutable_eps_bearer_map(); + return (eps_bearer_map.get(ebi, bearer_context_p)); +} + +//----------------------------------------------------------------------------- +sgw_eps_bearer_ctxt_t* sgw_s8_cm_get_eps_bearer_entry( sgw_pdn_connection_t* const sgw_pdn_connection, ebi_t ebi) { if ((ebi < EPS_BEARER_IDENTITY_FIRST) || (ebi > EPS_BEARER_IDENTITY_LAST)) { return nullptr; @@ -249,10 +312,8 @@ sgw_eps_bearer_ctxt_t* sgw_cm_get_eps_bearer_entry( return sgw_pdn_connection->sgw_eps_bearers_array[EBI_TO_INDEX(ebi)]; } -s_plus_p_gw_eps_bearer_context_information_t* sgw_cm_get_spgw_context( - teid_t teid) { - s_plus_p_gw_eps_bearer_context_information_t* spgw_bearer_context_info = - nullptr; +magma::lte::oai::S11BearerContext* sgw_cm_get_spgw_context(teid_t teid) { + magma::lte::oai::S11BearerContext* spgw_bearer_context_info = nullptr; state_teid_map_t* state_teid_map = get_spgw_teid_state(); if (!state_teid_map) { OAILOG_ERROR(LOG_SPGW_APP, "Failed to get state_teid_map"); @@ -263,6 +324,14 @@ s_plus_p_gw_eps_bearer_context_information_t* sgw_cm_get_spgw_context( return spgw_bearer_context_info; } +magma::proto_map_rc_t sgw_update_eps_bearer_entry( + magma::lte::oai::SgwPdnConnection* sgw_pdn_connection_p, uint32_t ebi, + magma::lte::oai::SgwEpsBearerContext* bearer_context_p) { + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = sgw_pdn_connection_p->mutable_eps_bearer_map(); + return (eps_bearer_map.update_val(ebi, bearer_context_p)); +} + spgw_ue_context_t* spgw_get_ue_context(imsi64_t imsi64) { OAILOG_FUNC_IN(LOG_SPGW_APP); spgw_ue_context_t* ue_context_p = nullptr; diff --git a/lte/gateway/c/core/oai/tasks/sgw/sgw_handlers.cpp b/lte/gateway/c/core/oai/tasks/sgw/sgw_handlers.cpp index cc6d46cd90e8..1e7d95754fd3 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/sgw_handlers.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw/sgw_handlers.cpp @@ -74,11 +74,16 @@ extern spgw_config_t spgw_config; extern struct gtp_tunnel_ops* gtp_tunnel_ops; extern void print_bearer_ids_helper(const ebi_t*, uint32_t); static void add_tunnel_helper( - s_plus_p_gw_eps_bearer_context_information_t* spgw_context, - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_entry_p, imsi64_t imsi64); - + magma::lte::oai::S11BearerContext* spgw_context, + magma::lte::oai::SgwEpsBearerContext* eps_bearer_ctxt_entry_p, + imsi64_t imsi64); static teid_t sgw_generate_new_s11_cp_teid(void); +static void get_session_req_data( + spgw_state_t* spgw_state, + const magma::lte::oai::CreateSessionMessage* saved_req, + struct pcef_create_session_data* data); +constexpr char SPGW_EPS_BEARER_MAP_NAME[] = "spgw_eps_bearer_map"; #define TASK_MME TASK_MME_APP //------------------------------------------------------------------------------ @@ -93,9 +98,9 @@ status_code_e sgw_handle_s11_create_session_request( const itti_s11_create_session_request_t* const session_req_pP, imsi64_t imsi64) { mme_sgw_tunnel_t* new_endpoint_p = nullptr; - s_plus_p_gw_eps_bearer_context_information_t* - s_plus_p_gw_eps_bearer_ctxt_info_p = nullptr; - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = nullptr; + magma::lte::oai::S11BearerContext* s_plus_p_gw_eps_bearer_ctxt_info_p = + nullptr; + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = nullptr; OAILOG_FUNC_IN(LOG_SPGW_APP); increment_counter("spgw_create_session", 1, NO_LABELS); @@ -174,99 +179,96 @@ status_code_e sgw_handle_s11_create_session_request( // copy informations from create session request to bearer context // information //-------------------------------------------------- - memcpy(s_plus_p_gw_eps_bearer_ctxt_info_p - ->sgw_eps_bearer_context_information.imsi.digit, - session_req_pP->imsi.digit, IMSI_BCD_DIGITS_MAX); - memcpy(s_plus_p_gw_eps_bearer_ctxt_info_p - ->pgw_eps_bearer_context_information.imsi.digit, - session_req_pP->imsi.digit, IMSI_BCD_DIGITS_MAX); - s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .imsi64 = imsi64; - s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .imsi_unauthenticated_indicator = 1; - s_plus_p_gw_eps_bearer_ctxt_info_p->pgw_eps_bearer_context_information - .imsi_unauthenticated_indicator = 1; - s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .mme_teid_S11 = session_req_pP->sender_fteid_for_cp.teid; - s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .s_gw_teid_S11_S4 = new_endpoint_p->local_teid; - s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .trxn = session_req_pP->trxn; - // s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information.mme_int_ip_address_S11 - // = session_req_pP->peer_ip; - FTEID_T_2_IP_ADDRESS_T( - (&session_req_pP->sender_fteid_for_cp), - (&s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .mme_ip_address_S11)); - - memset(&s_plus_p_gw_eps_bearer_ctxt_info_p - ->sgw_eps_bearer_context_information.pdn_connection, - 0, sizeof(sgw_pdn_connection_t)); + sgw_context_p = + s_plus_p_gw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context(); + sgw_context_p->set_imsi(session_req_pP->imsi.digit, IMSI_BCD_DIGITS_MAX); + s_plus_p_gw_eps_bearer_ctxt_info_p->mutable_pgw_eps_bearer_context() + ->set_imsi(session_req_pP->imsi.digit, IMSI_BCD_DIGITS_MAX); + sgw_context_p->set_imsi64(imsi64); + sgw_context_p->set_imsi_unauth_indicator(1); + s_plus_p_gw_eps_bearer_ctxt_info_p->mutable_pgw_eps_bearer_context() + ->set_imsi_unauth_indicator(1); + sgw_context_p->set_mme_teid_s11(session_req_pP->sender_fteid_for_cp.teid); + sgw_context_p->set_sgw_teid_s11_s4(new_endpoint_p->local_teid); + if (session_req_pP->trxn) { + sgw_context_p->set_trxn(reinterpret_cast(session_req_pP->trxn)); + } + + FTEID_T_2_PROTO_IP((&session_req_pP->sender_fteid_for_cp), + sgw_context_p->mutable_mme_cp_ip_address_s11()); + sgw_context_p->clear_pdn_connection(); + magma::lte::oai::SgwPdnConnection* proto_pdn = + sgw_context_p->mutable_pdn_connection(); if (session_req_pP->apn) { - s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.apn_in_use = strdup(session_req_pP->apn); + proto_pdn->set_apn_in_use(session_req_pP->apn, + strlen(session_req_pP->apn)); } else { - s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.apn_in_use = strdup("NO APN"); + proto_pdn->set_apn_in_use("NO APN"); } - - s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.default_bearer = + proto_pdn->set_default_bearer( session_req_pP->bearer_contexts_to_be_created.bearer_contexts[0] - .eps_bearer_id; + .eps_bearer_id); //-------------------------------------- // EPS bearer entry //-------------------------------------- // TODO several bearers - eps_bearer_ctxt_p = sgw_cm_create_eps_bearer_ctxt_in_collection( - &s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - session_req_pP->bearer_contexts_to_be_created.bearer_contexts[0] - .eps_bearer_id); - sgw_display_s11_bearer_context_information( - LOG_SPGW_APP, &s_plus_p_gw_eps_bearer_ctxt_info_p - ->sgw_eps_bearer_context_information); - - if (eps_bearer_ctxt_p == nullptr) { - OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, - "Failed to create new EPS bearer entry\n"); - increment_counter("spgw_create_session", 1, 2, "result", "failure", - "cause", "internal_software_error"); - // TO DO free_wrapper new_bearer_ctxt_info_p and by cascade... + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = proto_pdn->mutable_eps_bearer_map(); + eps_bearer_map.set_name(SPGW_EPS_BEARER_MAP_NAME); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + if (eps_bearer_map.get( + session_req_pP->bearer_contexts_to_be_created.bearer_contexts[0] + .eps_bearer_id, + &eps_bearer_ctxt) == magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE( + LOG_SPGW_APP, imsi64, + "Bearer contexts already exists for eps bearer id:%u ", + session_req_pP->bearer_contexts_to_be_created.bearer_contexts[0] + .eps_bearer_id); OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); } - eps_bearer_ctxt_p->eps_bearer_qos = + eps_bearer_ctxt.set_eps_bearer_id( session_req_pP->bearer_contexts_to_be_created.bearer_contexts[0] - .bearer_level_qos; - + .eps_bearer_id); + eps_bearer_qos_to_proto( + &session_req_pP->bearer_contexts_to_be_created.bearer_contexts[0] + .bearer_level_qos, + eps_bearer_ctxt.mutable_eps_bearer_qos()); /* * Trying to insert the new tunnel into the tree. * If collision_p is not NULL (0), it means tunnel is already present. */ - memcpy(&s_plus_p_gw_eps_bearer_ctxt_info_p - ->sgw_eps_bearer_context_information.saved_message, - session_req_pP, sizeof(itti_s11_create_session_request_t)); - copy_protocol_configuration_options( - &s_plus_p_gw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .saved_message.pco, - &session_req_pP->pco); + sgw_create_session_message_to_proto( + session_req_pP, + s_plus_p_gw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_saved_message()); /* * Send a create bearer request to PGW and handle respond * asynchronously through sgw_handle_s5_create_bearer_response() */ - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up = spgw_get_new_s1u_teid(state); + eps_bearer_ctxt.set_sgw_teid_s1u_s12_s4_up(spgw_get_new_s1u_teid(state)); OAILOG_DEBUG_UE( LOG_SPGW_APP, imsi64, "Updated eps_bearer_entry_p eps_b_id %u with SGW S1U teid" TEID_FMT "\n", - eps_bearer_ctxt_p->eps_bearer_id, new_endpoint_p->local_teid); + eps_bearer_ctxt.eps_bearer_id(), new_endpoint_p->local_teid); + + if (eps_bearer_map.insert(eps_bearer_ctxt.eps_bearer_id(), + eps_bearer_ctxt) != magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, + "Failed to insert eps bearer context for bearer id:%u", + eps_bearer_ctxt.eps_bearer_id()); + OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); + } + sgw_display_s11_bearer_context_information( + LOG_SPGW_APP, s_plus_p_gw_eps_bearer_ctxt_info_p); handle_s5_create_session_request(state, s_plus_p_gw_eps_bearer_ctxt_info_p, new_endpoint_p->local_teid, - eps_bearer_ctxt_p->eps_bearer_id); + eps_bearer_ctxt.eps_bearer_id()); } else { OAILOG_ERROR_UE( LOG_SPGW_APP, imsi64, @@ -305,11 +307,11 @@ status_code_e sgw_handle_sgi_endpoint_created( memset(create_session_response_p, 0, sizeof(itti_s11_create_session_response_t)); - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p = sgw_cm_get_spgw_context(resp_pP->context_teid); if (new_bearer_ctxt_info_p) { create_session_response_p->teid = - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.mme_teid_S11; + new_bearer_ctxt_info_p->sgw_eps_bearer_context().mme_teid_s11(); /* * Preparing to send create session response on S11 abstraction interface. @@ -320,21 +322,41 @@ status_code_e sgw_handle_sgi_endpoint_created( create_session_response_p->ambr.br_dl = 100000000; create_session_response_p->ambr.br_ul = 40000000; - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - resp_pP->eps_bearer_id); - AssertFatal(eps_bearer_ctxt_p, "ERROR UNABLE TO GET EPS BEARER ENTRY\n"); - AssertFatal(sizeof(eps_bearer_ctxt_p->paa) == - sizeof(create_session_response_p->paa), - "Mismatch in lengths"); // skeptic mode - memcpy(&create_session_response_p->paa, &eps_bearer_ctxt_p->paa, - sizeof(paa_t)); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = + new_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection() + ->mutable_eps_bearer_map(); + if (eps_bearer_map.get(resp_pP->eps_bearer_id, &eps_bearer_ctxt) != + magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, + "Failed to find eps bearer entry for bearer id:%u ", + resp_pP->eps_bearer_id); + OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); + } + create_session_response_p->paa.pdn_type = + (pdn_type_value_t)eps_bearer_ctxt.ue_ip_paa().pdn_type(); + if (eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4 || + eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4_AND_v6) { + inet_pton(AF_INET, eps_bearer_ctxt.ue_ip_paa().ipv4_addr().c_str(), + &create_session_response_p->paa.ipv4_address.s_addr); + } + if (eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv6 || + eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4_AND_v6) { + inet_pton(AF_INET6, eps_bearer_ctxt.ue_ip_paa().ipv6_addr().c_str(), + &create_session_response_p->paa.ipv6_address); + create_session_response_p->paa.ipv6_prefix_length = + eps_bearer_ctxt.ue_ip_paa().ipv6_prefix_length(); + create_session_response_p->paa.vlan = + eps_bearer_ctxt.ue_ip_paa().vlan(); + } + copy_protocol_configuration_options(&create_session_response_p->pco, &resp_pP->pco); clear_protocol_configuration_options(&resp_pP->pco); create_session_response_p->bearer_contexts_created.bearer_contexts[0] - .s1u_sgw_fteid.teid = eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up; + .s1u_sgw_fteid.teid = eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(); create_session_response_p->bearer_contexts_created.bearer_contexts[0] .s1u_sgw_fteid.interface_type = S1_U_SGW_GTP_U; @@ -378,11 +400,17 @@ status_code_e sgw_handle_sgi_endpoint_created( .eps_bearer_id = resp_pP->eps_bearer_id; create_session_response_p->bearer_contexts_created.num_bearer_context += 1; - create_session_response_p->trxn = - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.trxn; - create_session_response_p->peer_ip.s_addr = - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .mme_ip_address_S11.address.ipv4_address.s_addr; + memcpy(create_session_response_p->trxn, + reinterpret_cast( + new_bearer_ctxt_info_p->sgw_eps_bearer_context().trxn().c_str()), + new_bearer_ctxt_info_p->sgw_eps_bearer_context().trxn().size()); + + inet_pton(AF_INET, + new_bearer_ctxt_info_p->sgw_eps_bearer_context() + .mme_cp_ip_address_s11() + .ipv4_addr() + .c_str(), + &create_session_response_p->peer_ip.s_addr); } else { create_session_response_p->cause.cause_value = CONTEXT_NOT_FOUND; create_session_response_p->bearer_contexts_created.bearer_contexts[0] @@ -438,33 +466,31 @@ void sgw_populate_mbr_bearer_contexts_not_found( */ void sgw_populate_mbr_bearer_contexts_removed( const itti_sgi_update_end_point_response_t* const resp_pP, imsi64_t imsi64, - sgw_eps_bearer_context_information_t* sgw_context_p, + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p, itti_s11_modify_bearer_response_t* modify_response_p) { OAILOG_FUNC_IN(LOG_SPGW_APP); uint8_t rsp_idx = 0; - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = NULL; + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; for (uint8_t idx = 0; idx < resp_pP->num_bearers_removed; idx++) { - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &(sgw_context_p->pdn_connection), - resp_pP->bearer_contexts_to_be_removed[idx]); - /* If context is found, delete the context and set cause as - * REQUEST_ACCEPTED. If context is not found set the cause as - * CONTEXT_NOT_FOUND. MME App sends bearer deactivation message to UE for - * the bearers with cause CONTEXT_NOT_FOUND - */ - if (NULL != eps_bearer_ctxt_p) { - sgw_free_eps_bearer_context( - &(sgw_context_p->pdn_connection.sgw_eps_bearers_array[EBI_TO_INDEX( - eps_bearer_ctxt_p->eps_bearer_id)])); + if (sgw_cm_get_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + resp_pP->bearer_contexts_to_be_removed[idx], + &eps_bearer_ctxt) == magma::PROTO_MAP_OK) { + /* If context is found, delete the context and set cause as + * REQUEST_ACCEPTED. If context is not found set the cause as + * CONTEXT_NOT_FOUND. MME App sends bearer deactivation message to UE for + * the bearers with cause CONTEXT_NOT_FOUND + */ + sgw_remove_eps_bearer_context(sgw_context_p->mutable_pdn_connection(), + eps_bearer_ctxt.eps_bearer_id()); modify_response_p->bearer_contexts_marked_for_removal .bearer_contexts[rsp_idx] .cause.cause_value = REQUEST_ACCEPTED; } else { - OAILOG_ERROR_UE( - LOG_SPGW_APP, imsi64, - "Rx SGI_UPDATE_ENDPOINT_RESPONSE: eps_bearer_ctxt_p not found for " - "bearer to be removed ebi %u\n", - resp_pP->bearer_contexts_to_be_removed[idx]); + OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, + "Rx SGI_UPDATE_ENDPOINT_RESPONSE: eps_bearer_ctxt_p " + "not found for " + "bearer to be removed ebi %u\n", + resp_pP->bearer_contexts_to_be_removed[idx]); modify_response_p->bearer_contexts_marked_for_removal .bearer_contexts[rsp_idx] .cause.cause_value = CONTEXT_NOT_FOUND; @@ -482,43 +508,48 @@ void sgw_populate_mbr_bearer_contexts_removed( * dedicated bearers */ static void sgw_add_gtp_tunnel( - imsi64_t imsi64, sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p, - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p) { + imsi64_t imsi64, magma::lte::oai::SgwEpsBearerContext* eps_bearer_ctxt_p, + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p) { int rv = RETURNok; struct in_addr enb = {.s_addr = 0}; - struct in6_addr* enb_ipv6 = NULL; - enb.s_addr = - eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv4_address.s_addr; - if (spgw_config.sgw_config.ipv6.s1_ipv6_enabled && - eps_bearer_ctxt_p->enb_ip_address_S1u.pdn_type == IPv6) { - enb_ipv6 = &eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv6_address; - } + struct in6_addr enb_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt_p->mutable_enb_s1u_ip_addr(), &enb, &enb_ipv6, + spgw_config.sgw_config.ipv6.s1_ipv6_enabled); struct in_addr ue_ipv4 = {.s_addr = 0}; - struct in6_addr* ue_ipv6 = NULL; - ue_ipv4.s_addr = eps_bearer_ctxt_p->paa.ipv4_address.s_addr; - if ((eps_bearer_ctxt_p->paa.pdn_type == IPv6) || - (eps_bearer_ctxt_p->paa.pdn_type == IPv4_AND_v6)) { - ue_ipv6 = &eps_bearer_ctxt_p->paa.ipv6_address; + struct in6_addr ue_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt(eps_bearer_ctxt_p->mutable_ue_ip_paa(), + &ue_ipv4, &ue_ipv6, true); + bool is_ue_ipv6_pres = false; + if (((eps_bearer_ctxt_p->ue_ip_paa().pdn_type() == IPv6 || + eps_bearer_ctxt_p->ue_ip_paa().pdn_type() == IPv4_AND_v6)) && + !(eps_bearer_ctxt_p->ue_ip_paa().ipv6_addr().empty())) { + is_ue_ipv6_pres = true; } - int vlan = eps_bearer_ctxt_p->paa.vlan; - Imsi_t imsi = new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi; - char* apn = (char*)new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.apn_in_use; + int vlan = eps_bearer_ctxt_p->ue_ip_paa().vlan(); + Imsi_t imsi; + memcpy(imsi.digit, + new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi().c_str(), + new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi().size()); + const char* apn = reinterpret_cast( + new_bearer_ctxt_info_p->sgw_eps_bearer_context() + .pdn_connection() + .apn_in_use() + .c_str()); char ip6_str[INET6_ADDRSTRLEN]; - if (ue_ipv6) { - inet_ntop(AF_INET6, ue_ipv6, ip6_str, INET6_ADDRSTRLEN); - } + inet_ntop(AF_INET6, &ue_ipv6, ip6_str, INET6_ADDRSTRLEN); /* UE is switching back to EPS services after the CS Fallback * If Modify bearer Request is received in UE suspended mode, Resume PS * data */ - if (new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.pdn_connection - .ue_suspended_for_ps_handover) { + if (new_bearer_ctxt_info_p->sgw_eps_bearer_context() + .pdn_connection() + .ue_suspended_for_ps_handover()) { rv = gtp_tunnel_ops->forward_data_on_tunnel( - ue_ipv4, ue_ipv6, eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, NULL, + ue_ipv4, &ue_ipv6, eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up(), nullptr, DEFAULT_PRECEDENCE); if (rv < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, @@ -527,62 +558,83 @@ static void sgw_add_gtp_tunnel( } else { OAILOG_DEBUG_UE(LOG_SPGW_APP, imsi64, "Adding tunnel for bearer %u ue addr %x\n", - eps_bearer_ctxt_p->eps_bearer_id, ue_ipv4.s_addr); - if (eps_bearer_ctxt_p->eps_bearer_id == - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.default_bearer) { + eps_bearer_ctxt_p->eps_bearer_id(), ue_ipv4.s_addr); + if (eps_bearer_ctxt_p->eps_bearer_id() == + new_bearer_ctxt_info_p->sgw_eps_bearer_context() + .pdn_connection() + .default_bearer()) { // Set default precedence and tft for default bearer - if (ue_ipv6) { - OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, - "Adding tunnel for ipv6 ue addr %s, enb %x, " - "s_gw_teid_S1u_S12_S4_up %x, enb_teid_S1u %x\n", - ip6_str, enb.s_addr, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->enb_teid_S1u); + OAILOG_INFO_UE( + LOG_SPGW_APP, imsi64, + "Adding tunnel for ipv6 ue addr %s, enb %x, " + "sgw_teid_s1u_s12_s4_up" TEID_FMT " enb_teid_S1u " TEID_FMT, + ip6_str, enb.s_addr, eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt_p->enb_teid_s1u()); + + if (is_ue_ipv6_pres) { + rv = gtpv1u_add_tunnel(ue_ipv4, &ue_ipv6, vlan, enb, &enb_ipv6, + eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt_p->enb_teid_s1u(), imsi, nullptr, + DEFAULT_PRECEDENCE, apn); + } else { + rv = gtpv1u_add_tunnel(ue_ipv4, nullptr, vlan, enb, &enb_ipv6, + eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt_p->enb_teid_s1u(), imsi, nullptr, + DEFAULT_PRECEDENCE, apn); } - rv = gtpv1u_add_tunnel(ue_ipv4, ue_ipv6, vlan, enb, enb_ipv6, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->enb_teid_S1u, imsi, NULL, - DEFAULT_PRECEDENCE, apn); - // (@ulaskozat) We only need to update the TEIDs during session creation // which triggers rule installments on sessiond. When pipelined needs to // use eNB TEID for reporting we need to change this logic into something // more meaningful. - bool update_teids = eps_bearer_ctxt_p->update_teids; - eps_bearer_ctxt_p->update_teids = false; + bool update_teids = eps_bearer_ctxt_p->update_teids(); + eps_bearer_ctxt_p->set_update_teids(false); if (rv < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "ERROR in setting up TUNNEL err=%d\n", rv); } else if (update_teids) { - pcef_update_teids((char*)imsi.digit, eps_bearer_ctxt_p->eps_bearer_id, - eps_bearer_ctxt_p->enb_teid_S1u, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up); + pcef_update_teids(reinterpret_cast(imsi.digit), + eps_bearer_ctxt_p->eps_bearer_id(), + eps_bearer_ctxt_p->enb_teid_s1u(), + eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up()); } } else { - for (int itrn = 0; itrn < eps_bearer_ctxt_p->tft.numberofpacketfilters; - ++itrn) { + for (uint8_t itrn = 0; + itrn < eps_bearer_ctxt_p->tft().number_of_packet_filters(); ++itrn) { // Prepare DL flow rule + magma::lte::oai::PacketFilter create_new_tft = + eps_bearer_ctxt_p->tft().packet_filter_list().create_new_tft(itrn); + packet_filter_t packet_filter = {0}; + proto_to_packet_filter(create_new_tft, &packet_filter); struct ip_flow_dl dlflow = {0}; - generate_dl_flow( - &(eps_bearer_ctxt_p->tft.packetfilterlist.createnewtft[itrn] - .packetfiltercontents), - ue_ipv4.s_addr, ue_ipv6, &dlflow); - OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, - "Adding tunnel for ded bearer ipv6 ue addr %s, enb %x, " - "s_gw_teid_S1u_S12_S4_up %x, enb_teid_S1u %x\n", - ip6_str, enb.s_addr, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->enb_teid_S1u); - - rv = gtpv1u_add_tunnel( - ue_ipv4, ue_ipv6, vlan, enb, enb_ipv6, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->enb_teid_S1u, imsi, &dlflow, - eps_bearer_ctxt_p->tft.packetfilterlist.createnewtft[itrn] - .eval_precedence, - apn); + if (is_ue_ipv6_pres) { + generate_dl_flow(&packet_filter.packetfiltercontents, ue_ipv4.s_addr, + &ue_ipv6, &dlflow); + } else { + generate_dl_flow(&packet_filter.packetfiltercontents, ue_ipv4.s_addr, + nullptr, &dlflow); + } + + OAILOG_INFO_UE( + LOG_SPGW_APP, imsi64, + "Adding tunnel for ded bearer ipv6 ue addr %s, enb %x, " + "sgw_teid_S1u_S12_S4_up" TEID_FMT " enb_teid_S1u " TEID_FMT, + ip6_str, enb.s_addr, eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt_p->enb_teid_s1u()); + + if (is_ue_ipv6_pres) { + rv = + gtpv1u_add_tunnel(ue_ipv4, &ue_ipv6, vlan, enb, &enb_ipv6, + eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt_p->enb_teid_s1u(), imsi, + &dlflow, create_new_tft.eval_precedence(), apn); + } else { + rv = + gtpv1u_add_tunnel(ue_ipv4, nullptr, vlan, enb, &enb_ipv6, + eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt_p->enb_teid_s1u(), imsi, + &dlflow, create_new_tft.eval_precedence(), apn); + } if (rv < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, @@ -591,34 +643,34 @@ static void sgw_add_gtp_tunnel( OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, "Successfully setup flow rule for EPS bearer id %u " "tunnel " TEID_FMT " (eNB) <-> (SGW) " TEID_FMT "\n", - eps_bearer_ctxt_p->eps_bearer_id, - eps_bearer_ctxt_p->enb_teid_S1u, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up); + eps_bearer_ctxt_p->eps_bearer_id(), + eps_bearer_ctxt_p->enb_teid_s1u(), + eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up()); } } } } OAILOG_FUNC_OUT(LOG_SPGW_APP); } + //------------------------------------------------------------------------------ /* Populates bearer contexts to be modified structure in * modify bearer rsp message */ static void sgw_populate_mbr_bearer_contexts_modified( const itti_sgi_update_end_point_response_t* const resp_pP, imsi64_t imsi64, - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p, + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p, itti_s11_modify_bearer_response_t* modify_response_p) { OAILOG_FUNC_IN(LOG_SPGW_APP); uint8_t rsp_idx = 0; - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = NULL; + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; for (uint8_t idx = 0; idx < resp_pP->num_bearers_modified; idx++) { - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - resp_pP->bearer_contexts_to_be_modified[idx].eps_bearer_id); - - if (NULL != eps_bearer_ctxt_p) { + if (sgw_cm_get_eps_bearer_entry( + new_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + resp_pP->bearer_contexts_to_be_modified[idx].eps_bearer_id, + &eps_bearer_ctxt) == magma::PROTO_MAP_OK) { OAILOG_DEBUG_UE(LOG_SPGW_APP, imsi64, "Rx SGI_UPDATE_ENDPOINT_RESPONSE: REQUEST_ACCEPTED\n"); modify_response_p->bearer_contexts_modified.bearer_contexts[rsp_idx] @@ -632,21 +684,24 @@ static void sgw_populate_mbr_bearer_contexts_modified( #if !MME_UNIT_TEST // skip tunnel creation for unit tests // setup GTPv1-U tunnel - sgw_add_gtp_tunnel(imsi64, eps_bearer_ctxt_p, new_bearer_ctxt_info_p); + sgw_add_gtp_tunnel(imsi64, &eps_bearer_ctxt, new_bearer_ctxt_info_p); #endif // may be removed if (TRAFFIC_FLOW_TEMPLATE_NB_PACKET_FILTERS_MAX > - eps_bearer_ctxt_p->num_sdf) { - int i = 0; - while ((i < eps_bearer_ctxt_p->num_sdf) && - (SDF_ID_NGBR_DEFAULT != eps_bearer_ctxt_p->sdf_id[i])) + eps_bearer_ctxt.num_sdf()) { + uint8_t i = 0; + while ((i < eps_bearer_ctxt.num_sdf()) && + (SDF_ID_NGBR_DEFAULT != eps_bearer_ctxt.sdf_ids(i))) i++; - if (i >= eps_bearer_ctxt_p->num_sdf) { - eps_bearer_ctxt_p->sdf_id[eps_bearer_ctxt_p->num_sdf] = - SDF_ID_NGBR_DEFAULT; - eps_bearer_ctxt_p->num_sdf += 1; + if (i >= eps_bearer_ctxt.num_sdf()) { + eps_bearer_ctxt.add_sdf_ids(SDF_ID_NGBR_DEFAULT); + eps_bearer_ctxt.set_num_sdf(eps_bearer_ctxt.num_sdf() + 1); } } + sgw_update_eps_bearer_entry( + new_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + eps_bearer_ctxt.eps_bearer_id(), &eps_bearer_ctxt); } } OAILOG_FUNC_OUT(LOG_SPGW_APP); @@ -674,21 +729,24 @@ void sgw_handle_sgi_endpoint_updated( modify_response_p = &message_p->ittiMsg.s11_modify_bearer_response; - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p = sgw_cm_get_spgw_context(resp_pP->context_teid); if (new_bearer_ctxt_info_p) { modify_response_p->teid = - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.mme_teid_S11; + new_bearer_ctxt_info_p->sgw_eps_bearer_context().mme_teid_s11(); modify_response_p->cause.cause_value = REQUEST_ACCEPTED; - modify_response_p->trxn = - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.trxn; + + memcpy(modify_response_p->trxn, + reinterpret_cast( + new_bearer_ctxt_info_p->sgw_eps_bearer_context().trxn().c_str()), + new_bearer_ctxt_info_p->sgw_eps_bearer_context().trxn().size()); message_p->ittiMsgHeader.imsi = imsi64; sgw_populate_mbr_bearer_contexts_modified( resp_pP, imsi64, new_bearer_ctxt_info_p, modify_response_p); sgw_populate_mbr_bearer_contexts_removed( resp_pP, imsi64, - &new_bearer_ctxt_info_p->sgw_eps_bearer_context_information, + new_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context(), modify_response_p); sgw_populate_mbr_bearer_contexts_not_found(LOG_SPGW_APP, resp_pP, modify_response_p); @@ -696,15 +754,14 @@ void sgw_handle_sgi_endpoint_updated( } OAILOG_FUNC_OUT(LOG_SPGW_APP); } + //------------------------------------------------------------------------------ int sgw_handle_sgi_endpoint_deleted( const itti_sgi_delete_end_point_request_t* const resp_pP, imsi64_t imsi64) { - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = NULL; + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; int rv = RETURNok; - char* imsi = NULL; - char* apn = NULL; struct in_addr inaddr; - struct in6_addr in6addr; + struct in6_addr in6addr = {}; OAILOG_FUNC_IN(LOG_SPGW_APP); @@ -714,37 +771,35 @@ int sgw_handle_sgi_endpoint_deleted( "EPS bearer id %u\n", resp_pP->context_teid, resp_pP->sgw_S1u_teid, resp_pP->eps_bearer_id); - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p = sgw_cm_get_spgw_context(resp_pP->context_teid); if (new_bearer_ctxt_info_p) { - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - resp_pP->eps_bearer_id); - - if (NULL == eps_bearer_ctxt_p) { - OAILOG_DEBUG_UE(LOG_SPGW_APP, imsi64, + if (sgw_cm_get_eps_bearer_entry( + new_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + resp_pP->eps_bearer_id, &eps_bearer_ctxt) != magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "Rx SGI_DELETE_ENDPOINT_REQUEST: CONTEXT_NOT_FOUND " - "(pdn_connection.sgw_eps_bearers context)\n"); + "(pdn_connection.sgw_eps_bearers context) for bearer id", + resp_pP->eps_bearer_id); } else { OAILOG_DEBUG_UE(LOG_SPGW_APP, imsi64, "Rx SGI_DELETE_ENDPOINT_REQUEST: REQUEST_ACCEPTED\n"); - struct in_addr ue_ipv4 = eps_bearer_ctxt_p->paa.ipv4_address; - struct in6_addr* ue_ipv6 = NULL; - if ((eps_bearer_ctxt_p->paa.pdn_type == IPv6) || - (eps_bearer_ctxt_p->paa.pdn_type == IPv4_AND_v6)) { - ue_ipv6 = &eps_bearer_ctxt_p->paa.ipv6_address; - } + struct in_addr ue_ipv4 = {.s_addr = 0}; + struct in6_addr ue_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt(eps_bearer_ctxt.mutable_ue_ip_paa(), + &ue_ipv4, &ue_ipv6, true); // If the forwarding was suspended, first resume it. // Note that forward_data_on_tunnel does not install a new forwarding // rule, but simply deletes previously installed drop rule by // discard_data_on_tunnel. - if (new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.ue_suspended_for_ps_handover) { + if (new_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->pdn_connection() + .ue_suspended_for_ps_handover()) { rv = gtp_tunnel_ops->forward_data_on_tunnel( - ue_ipv4, ue_ipv6, eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, NULL, - DEFAULT_PRECEDENCE); + ue_ipv4, &ue_ipv6, eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + nullptr, DEFAULT_PRECEDENCE); if (rv < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "ERROR in resume forwarding data on TUNNEL err=%d\n", @@ -755,24 +810,20 @@ int sgw_handle_sgi_endpoint_deleted( #if !MME_UNIT_TEST // skip tunnel deletion for unit tests // delete GTPv1-U tunnel struct in_addr enb = {.s_addr = 0}; - struct in6_addr* enb_ipv6 = NULL; - enb.s_addr = - eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv4_address.s_addr; - if (spgw_config.sgw_config.ipv6.s1_ipv6_enabled && - eps_bearer_ctxt_p->enb_ip_address_S1u.pdn_type == IPv6) { - enb_ipv6 = &eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv6_address; - } - - rv = - gtp_tunnel_ops->del_tunnel(enb, enb_ipv6, ue_ipv4, ue_ipv6, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->enb_teid_S1u, NULL); + struct in6_addr enb_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_enb_s1u_ip_addr(), &enb, &enb_ipv6, + spgw_config.sgw_config.ipv6.s1_ipv6_enabled); + + rv = gtp_tunnel_ops->del_tunnel(enb, &enb_ipv6, ue_ipv4, &ue_ipv6, + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.enb_teid_s1u(), nullptr); if (rv < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "ERROR in deleting TUNNEL\n"); } // delete paging rule - char* ip_str = inet_ntoa(ue_ipv4); - rv = gtp_tunnel_ops->delete_paging_rule(ue_ipv4, ue_ipv6); + const char* ip_str = eps_bearer_ctxt.ue_ip_paa().ipv4_addr().c_str(); + rv = gtp_tunnel_ops->delete_paging_rule(ue_ipv4, &ue_ipv6); if (rv < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "ERROR in deleting paging rule for IP Addr: %s\n", @@ -782,10 +833,11 @@ int sgw_handle_sgi_endpoint_deleted( } #endif - imsi = (char*)new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .imsi.digit; - apn = (char*)new_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.apn_in_use; + std::string imsi = + new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi(); + std::string apn = new_bearer_ctxt_info_p->sgw_eps_bearer_context() + .pdn_connection() + .apn_in_use(); switch (resp_pP->paa.pdn_type) { case IPv4: inaddr = resp_pP->paa.ipv4_address; @@ -837,26 +889,27 @@ int sgw_handle_sgi_endpoint_deleted( //------------------------------------------------------------------------------ // This function populates itti_sgi_update_end_point_response_t message + void populate_sgi_end_point_update( uint8_t sgi_rsp_idx, uint8_t idx, const itti_s11_modify_bearer_request_t* const modify_bearer_pP, - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p, + magma::lte::oai::SgwEpsBearerContext* eps_bearer_ctxt_p, itti_sgi_update_end_point_response_t* sgi_update_end_point_resp) { OAILOG_FUNC_IN(LOG_SPGW_APP); - FTEID_T_2_IP_ADDRESS_T( + FTEID_T_2_PROTO_IP( (&modify_bearer_pP->bearer_contexts_to_be_modified.bearer_contexts[idx] .s1_eNB_fteid), - (&eps_bearer_ctxt_p->enb_ip_address_S1u)); - eps_bearer_ctxt_p->enb_teid_S1u = + (eps_bearer_ctxt_p->mutable_enb_s1u_ip_addr())); + eps_bearer_ctxt_p->set_enb_teid_s1u( modify_bearer_pP->bearer_contexts_to_be_modified.bearer_contexts[idx] - .s1_eNB_fteid.teid; + .s1_eNB_fteid.teid); sgi_update_end_point_resp->bearer_contexts_to_be_modified[sgi_rsp_idx] - .sgw_S1u_teid = eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up; + .sgw_S1u_teid = eps_bearer_ctxt_p->sgw_teid_s1u_s12_s4_up(); sgi_update_end_point_resp->bearer_contexts_to_be_modified[sgi_rsp_idx] - .enb_S1u_teid = eps_bearer_ctxt_p->enb_teid_S1u; + .enb_S1u_teid = eps_bearer_ctxt_p->enb_teid_s1u(); sgi_update_end_point_resp->bearer_contexts_to_be_modified[sgi_rsp_idx] - .eps_bearer_id = eps_bearer_ctxt_p->eps_bearer_id; + .eps_bearer_id = eps_bearer_ctxt_p->eps_bearer_id(); sgi_update_end_point_resp->num_bearers_modified++; OAILOG_FUNC_OUT(LOG_SPGW_APP); @@ -913,7 +966,6 @@ status_code_e sgw_handle_modify_bearer_request( const itti_s11_modify_bearer_request_t* const modify_bearer_pP, imsi64_t imsi64) { OAILOG_FUNC_IN(LOG_SPGW_APP); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = NULL; status_code_e rv = RETURNok; uint8_t idx = 0; itti_sgi_update_end_point_response_t sgi_update_end_point_resp = {0}; @@ -923,16 +975,18 @@ status_code_e sgw_handle_modify_bearer_request( "Rx MODIFY_BEARER_REQUEST, teid " TEID_FMT "\n", modify_bearer_pP->teid); - s_plus_p_gw_eps_bearer_context_information_t* bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* bearer_ctxt_info_p = sgw_cm_get_spgw_context(modify_bearer_pP->teid); if (bearer_ctxt_info_p) { - bearer_ctxt_info_p->sgw_eps_bearer_context_information.pdn_connection - .default_bearer = + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + bearer_ctxt_info_p->mutable_sgw_eps_bearer_context(); + sgw_context_p->mutable_pdn_connection()->set_default_bearer( modify_bearer_pP->bearer_contexts_to_be_modified.bearer_contexts[0] - .eps_bearer_id; - bearer_ctxt_info_p->sgw_eps_bearer_context_information.trxn = - modify_bearer_pP->trxn; + .eps_bearer_id); + if (modify_bearer_pP->trxn) { + sgw_context_p->set_trxn(reinterpret_cast(modify_bearer_pP->trxn)); + } sgi_update_end_point_resp.context_teid = modify_bearer_pP->teid; uint8_t sgi_rsp_idx = 0; @@ -940,68 +994,75 @@ status_code_e sgw_handle_modify_bearer_request( idx < modify_bearer_pP->bearer_contexts_to_be_modified.num_bearer_context; idx++) { - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + uint32_t eps_bearer_id = modify_bearer_pP->bearer_contexts_to_be_modified.bearer_contexts[idx] - .eps_bearer_id); - - if (NULL == eps_bearer_ctxt_p) { + .eps_bearer_id; + if (sgw_cm_get_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + eps_bearer_id, &eps_bearer_ctxt) != + magma::PROTO_MAP_OK) { sgi_update_end_point_resp.bearer_contexts_not_found[sgi_rsp_idx++] = - modify_bearer_pP->bearer_contexts_to_be_modified - .bearer_contexts[idx] - .eps_bearer_id; + eps_bearer_id; sgi_update_end_point_resp.num_bearers_not_found++; - } else { // eps_bearer_ctxt_p found - enb.s_addr = - eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv4_address.s_addr; - struct in6_addr* enb_ipv6 = NULL; + } else { // eps_bearer_ctxt found + inet_pton(AF_INET, + eps_bearer_ctxt.enb_s1u_ip_addr().ipv4_addr().c_str(), + &enb.s_addr); + + struct in6_addr enb_ipv6 = {}; if (spgw_config.sgw_config.ipv6.s1_ipv6_enabled && - eps_bearer_ctxt_p->enb_ip_address_S1u.pdn_type == IPv6) { - enb_ipv6 = - &eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv6_address; + eps_bearer_ctxt.enb_s1u_ip_addr().pdn_type() == IPv6) { + inet_pton(AF_INET6, + eps_bearer_ctxt.enb_s1u_ip_addr().ipv6_addr().c_str(), + &enb_ipv6); } // Send end marker to eNB and then delete the tunnel if enb_ip is // different if (does_bearer_context_hold_valid_enb_ip( - eps_bearer_ctxt_p->enb_ip_address_S1u) && + eps_bearer_ctxt.enb_s1u_ip_addr()) && is_enb_ip_address_same( &modify_bearer_pP->bearer_contexts_to_be_modified .bearer_contexts[idx] .s1_eNB_fteid, - &eps_bearer_ctxt_p->enb_ip_address_S1u) == false) { - struct in_addr ue_ipv4 = eps_bearer_ctxt_p->paa.ipv4_address; - struct in6_addr* ue_ipv6 = NULL; - if ((eps_bearer_ctxt_p->paa.pdn_type == IPv6) || - (eps_bearer_ctxt_p->paa.pdn_type == IPv4_AND_v6)) { - ue_ipv6 = &eps_bearer_ctxt_p->paa.ipv6_address; + enb, enb_ipv6) == false) { + struct in_addr ue_ipv4 = {.s_addr = 0}; + inet_pton(AF_INET, eps_bearer_ctxt.ue_ip_paa().ipv4_addr().c_str(), + &ue_ipv4.s_addr); + struct in6_addr ue_ipv6 = {}; + if ((eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv6) || + (eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4_AND_v6)) { + inet_pton(AF_INET6, eps_bearer_ctxt.ue_ip_paa().ipv6_addr().c_str(), + &ue_ipv6); } OAILOG_DEBUG_UE(LOG_SPGW_APP, imsi64, - "Delete GTPv1-U tunnel for sgw_teid : %d" + "Delete GTPv1-U tunnel for sgw_teid " TEID_FMT "for bearer %d\n", - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->eps_bearer_id); + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.eps_bearer_id()); if (gtp_tunnel_ops) { // This is best effort, ignore return code. gtp_tunnel_ops->send_end_marker(enb, modify_bearer_pP->teid); // delete GTPv1-U tunnel if (gtp_tunnel_ops->del_tunnel( - enb, enb_ipv6, ue_ipv4, ue_ipv6, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->enb_teid_S1u, NULL) < 0) { + enb, &enb_ipv6, ue_ipv4, &ue_ipv6, + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.enb_teid_s1u(), nullptr) < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "ERROR in deleting TUNNEL " TEID_FMT " (eNB) <-> (SGW) " TEID_FMT "\n", - eps_bearer_ctxt_p->enb_teid_S1u, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up); + eps_bearer_ctxt.enb_teid_s1u(), + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up()); } } } populate_sgi_end_point_update(sgi_rsp_idx, idx, modify_bearer_pP, - eps_bearer_ctxt_p, + &eps_bearer_ctxt, &sgi_update_end_point_resp); sgi_rsp_idx++; + sgw_update_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + eps_bearer_ctxt.eps_bearer_id(), + &eps_bearer_ctxt); } } // for loop sgi_rsp_idx = 0; @@ -1009,14 +1070,15 @@ status_code_e sgw_handle_modify_bearer_request( idx < modify_bearer_pP->bearer_contexts_to_be_removed.num_bearer_context; idx++) { - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + uint32_t eps_bearer_id = modify_bearer_pP->bearer_contexts_to_be_removed.bearer_contexts[idx] - .eps_bearer_id); - if (eps_bearer_ctxt_p) { + .eps_bearer_id; + if (sgw_cm_get_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + eps_bearer_id, &eps_bearer_ctxt) != + magma::PROTO_MAP_OK) { sgi_update_end_point_resp.bearer_contexts_to_be_removed[sgi_rsp_idx++] = - eps_bearer_ctxt_p->eps_bearer_id; + eps_bearer_ctxt.eps_bearer_id(); sgi_update_end_point_resp.num_bearers_removed++; } } @@ -1063,18 +1125,18 @@ status_code_e sgw_handle_delete_session_request( "should be forwarded to P-GW entity\n"); } - s_plus_p_gw_eps_bearer_context_information_t* ctx_p = + magma::lte::oai::S11BearerContext* ctx_p = sgw_cm_get_spgw_context(delete_session_req_pP->teid); if (ctx_p) { + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + ctx_p->mutable_sgw_eps_bearer_context(); if ((delete_session_req_pP->sender_fteid_for_cp.ipv4) && (delete_session_req_pP->sender_fteid_for_cp.ipv6)) { /* * Sender F-TEID IE present */ - if (delete_session_req_pP->teid != - ctx_p->sgw_eps_bearer_context_information.mme_teid_S11) { - delete_session_resp_p->teid = - ctx_p->sgw_eps_bearer_context_information.mme_teid_S11; + if (delete_session_req_pP->teid != sgw_context_p->mme_teid_s11()) { + delete_session_resp_p->teid = sgw_context_p->mme_teid_s11(); delete_session_resp_p->cause.cause_value = INVALID_PEER; OAILOG_DEBUG_UE(LOG_SPGW_APP, imsi64, "Mismatch in MME Teid for CP\n"); } else { @@ -1083,70 +1145,83 @@ status_code_e sgw_handle_delete_session_request( } } else { delete_session_resp_p->cause.cause_value = REQUEST_ACCEPTED; - delete_session_resp_p->teid = - ctx_p->sgw_eps_bearer_context_information.mme_teid_S11; + delete_session_resp_p->teid = sgw_context_p->mme_teid_s11(); // TODO make async - char* imsi = (char*)ctx_p->sgw_eps_bearer_context_information.imsi.digit; - char* apn = (char*)ctx_p->sgw_eps_bearer_context_information - .pdn_connection.apn_in_use; + std::string imsi = sgw_context_p->imsi(); + std::string apn = sgw_context_p->pdn_connection().apn_in_use(); pcef_end_session(imsi, apn); itti_sgi_delete_end_point_request_t sgi_delete_end_point_request; - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = NULL; + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; for (int ebix = 0; ebix < BEARERS_PER_UE; ebix++) { ebi_t ebi = INDEX_TO_EBI(ebix); - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &ctx_p->sgw_eps_bearer_context_information.pdn_connection, ebi); - - if (eps_bearer_ctxt_p) { + if (sgw_cm_get_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + ebi, &eps_bearer_ctxt) == + magma::PROTO_MAP_OK) { if (ebi != delete_session_req_pP->lbi) { struct in_addr enb = {.s_addr = 0}; - enb.s_addr = eps_bearer_ctxt_p->enb_ip_address_S1u.address - .ipv4_address.s_addr; - struct in6_addr* enb_ipv6 = NULL; - if (spgw_config.sgw_config.ipv6.s1_ipv6_enabled && - eps_bearer_ctxt_p->enb_ip_address_S1u.pdn_type == IPv6) { - enb_ipv6 = - &eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv6_address; - } - struct in6_addr* ue_ipv6 = NULL; - if ((eps_bearer_ctxt_p->paa.pdn_type == IPv6) || - (eps_bearer_ctxt_p->paa.pdn_type == IPv4_AND_v6)) { - ue_ipv6 = &eps_bearer_ctxt_p->paa.ipv6_address; - } - + struct in6_addr enb_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_enb_s1u_ip_addr(), &enb, &enb_ipv6, + spgw_config.sgw_config.ipv6.s1_ipv6_enabled); + + struct in_addr ue_ipv4 = {.s_addr = 0}; + struct in6_addr ue_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_ue_ip_paa(), &ue_ipv4, &ue_ipv6, true); #if !MME_UNIT_TEST // skip tunnel deletion for unit tests if (gtp_tunnel_ops->del_tunnel( - enb, enb_ipv6, eps_bearer_ctxt_p->paa.ipv4_address, ue_ipv6, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->enb_teid_S1u, NULL) < 0) { + enb, &enb_ipv6, ue_ipv4, &ue_ipv6, + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.enb_teid_s1u(), nullptr) < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "ERROR in deleting TUNNEL " TEID_FMT " (eNB) <-> (SGW) " TEID_FMT "\n", - eps_bearer_ctxt_p->enb_teid_S1u, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up); + eps_bearer_ctxt.enb_teid_s1u(), + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up()); } #endif - eps_bearer_ctxt_p->num_sdf = 0; + eps_bearer_ctxt.set_num_sdf(0); + } + if (sgw_update_eps_bearer_entry( + sgw_context_p->mutable_pdn_connection(), ebi, + &eps_bearer_ctxt) != magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE( + LOG_SPGW_APP, sgw_context_p->imsi64(), + "Failed to update bearer context for bearer id :%u\n", ebi); + OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); } } } - - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &ctx_p->sgw_eps_bearer_context_information.pdn_connection, - delete_session_req_pP->lbi); - if (eps_bearer_ctxt_p) { - eps_bearer_ctxt_p->num_sdf = 0; + if (sgw_cm_get_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + delete_session_req_pP->lbi, + &eps_bearer_ctxt) == + magma::PROTO_MAP_OK) { + eps_bearer_ctxt.set_num_sdf(0); sgi_delete_end_point_request.context_teid = delete_session_req_pP->teid; sgi_delete_end_point_request.sgw_S1u_teid = - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up; + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(); sgi_delete_end_point_request.eps_bearer_id = delete_session_req_pP->lbi; sgi_delete_end_point_request.pdn_type = - ctx_p->sgw_eps_bearer_context_information.saved_message.pdn_type; - memcpy(&sgi_delete_end_point_request.paa, &eps_bearer_ctxt_p->paa, - sizeof(paa_t)); + (pdn_type_value_t)sgw_context_p->saved_message().pdn_type(); + + sgi_delete_end_point_request.paa.pdn_type = + (pdn_type_value_t)eps_bearer_ctxt.ue_ip_paa().pdn_type(); + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_ue_ip_paa(), + &sgi_delete_end_point_request.paa.ipv4_address, + &sgi_delete_end_point_request.paa.ipv6_address, true); + if (sgw_update_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + delete_session_req_pP->lbi, + &eps_bearer_ctxt) != + magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE(LOG_SPGW_APP, sgw_context_p->imsi64(), + "Failed to update bearer context for bearer id :%u\n", + delete_session_req_pP->lbi); + OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); + } sgw_handle_sgi_endpoint_deleted(&sgi_delete_end_point_request, imsi64); } else { @@ -1204,18 +1279,6 @@ status_code_e sgw_handle_delete_session_request( OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); } -//------------------------------------------------------------------------------ -static void sgw_release_all_enb_related_information( - sgw_eps_bearer_ctxt_t* const eps_bearer_ctxt) { - OAILOG_FUNC_IN(LOG_SPGW_APP); - if (eps_bearer_ctxt) { - memset(&eps_bearer_ctxt->enb_ip_address_S1u, 0, - sizeof(eps_bearer_ctxt->enb_ip_address_S1u)); - eps_bearer_ctxt->enb_teid_S1u = INVALID_TEID; - } - OAILOG_FUNC_OUT(LOG_SPGW_APP); -} - /* From GPP TS 23.401 version 11.11.0 Release 11, section 5.3.5 S1 release procedure: The S-GW releases all eNodeB related information (address and TEIDs) for the UE and responds with a Release Access Bearers Response message @@ -1236,7 +1299,7 @@ void sgw_handle_release_access_bearers_request( spgw_ue_context_t* ue_context_p = nullptr; gtpv2c_cause_value_t cause = CONTEXT_NOT_FOUND; - s_plus_p_gw_eps_bearer_context_information_t* ctx_p = nullptr; + magma::lte::oai::S11BearerContext* ctx_p = nullptr; map_uint64_spgw_ue_context_t* state_ue_map = get_spgw_ue_state(); if (!state_ue_map) { @@ -1252,8 +1315,7 @@ void sgw_handle_release_access_bearers_request( ctx_p = sgw_cm_get_spgw_context(s11_teid_p->sgw_s11_teid); if (ctx_p) { sgw_process_release_access_bearer_request( - LOG_SPGW_APP, imsi64, - &(ctx_p->sgw_eps_bearer_context_information)); + LOG_SPGW_APP, imsi64, ctx_p->mutable_sgw_eps_bearer_context()); cause = REQUEST_ACCEPTED; } } @@ -1261,14 +1323,14 @@ void sgw_handle_release_access_bearers_request( } sgw_send_release_access_bearer_response( LOG_SPGW_APP, TASK_SPGW_APP, imsi64, cause, release_access_bearers_req_pP, - ctx_p ? ctx_p->sgw_eps_bearer_context_information.mme_teid_S11 : 0); + ctx_p ? ctx_p->sgw_eps_bearer_context().mme_teid_s11() : 0); OAILOG_FUNC_OUT(LOG_SPGW_APP); } //------------------------------------------------------------------------- void handle_s5_create_session_response( spgw_state_t* state, - s_plus_p_gw_eps_bearer_context_information_t* new_bearer_ctxt_info_p, + magma::lte::oai::S11BearerContext* new_bearer_ctxt_info_p, s5_create_session_response_t session_resp) { OAILOG_FUNC_IN(LOG_SPGW_APP); itti_s11_create_session_response_t* create_session_response_p = NULL; @@ -1288,27 +1350,26 @@ void handle_s5_create_session_response( } OAILOG_DEBUG_UE( - LOG_SPGW_APP, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64, + LOG_SPGW_APP, new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64(), "Handle s5_create_session_response, for Context SGW S11 teid, " TEID_FMT "EPS bearer id %u\n", session_resp.context_teid, session_resp.eps_bearer_id); // PCO processing - protocol_configuration_options_t* pco_req = - &new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.saved_message - .pco; + magma::lte::oai::Pco* pco_req = + new_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_saved_message() + ->mutable_pco(); protocol_configuration_options_t pco_resp = {0}; protocol_configuration_options_ids_t pco_ids; memset(&pco_ids, 0, sizeof pco_ids); if (pgw_process_pco_request(pco_req, &pco_resp, &pco_ids) != RETURNok) { - OAILOG_ERROR_UE( - LOG_SPGW_APP, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64, - "Error in processing PCO in create session request for " - "context_id: " TEID_FMT "\n", - session_resp.context_teid); + OAILOG_ERROR_UE(LOG_SPGW_APP, + new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64(), + "Error in processing PCO in create session request for " + "context_id: " TEID_FMT "\n", + session_resp.context_teid); session_resp.failure_cause = S5_OK; session_resp.status = SGI_STATUS_ERROR_FAILED_TO_PROCESS_PCO; } @@ -1320,12 +1381,12 @@ void handle_s5_create_session_response( sgi_create_endpoint_resp.context_teid = session_resp.context_teid; sgi_create_endpoint_resp.eps_bearer_id = session_resp.eps_bearer_id; sgi_create_endpoint_resp.paa.pdn_type = - (pdn_type_value_t)new_bearer_ctxt_info_p - ->sgw_eps_bearer_context_information.saved_message.pdn_type; + (pdn_type_value_t)new_bearer_ctxt_info_p->sgw_eps_bearer_context() + .saved_message() + .pdn_type(); OAILOG_DEBUG_UE( - LOG_SPGW_APP, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64, + LOG_SPGW_APP, new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64(), "Status of SGI_CREATE_ENDPOINT_RESPONSE within S5_CREATE_BEARER_RESPONSE " "is: %u\n", sgi_create_endpoint_resp.status); @@ -1336,7 +1397,7 @@ void handle_s5_create_session_response( // Send Create Session Response with ack sgw_handle_sgi_endpoint_created( state, &sgi_create_endpoint_resp, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64); + new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64()); increment_counter("spgw_create_session", 1, 1, "result", "success"); OAILOG_FUNC_OUT(LOG_SPGW_APP); @@ -1379,10 +1440,9 @@ void handle_s5_create_session_response( message_p = itti_alloc_new_message(TASK_SPGW_APP, S11_CREATE_SESSION_RESPONSE); if (!message_p) { - OAILOG_ERROR_UE( - LOG_SPGW_APP, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64, - "Message Create Session Response allocation failed\n"); + OAILOG_ERROR_UE(LOG_SPGW_APP, + new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64(), + "Message Create Session Response allocation failed\n"); OAILOG_FUNC_OUT(LOG_SPGW_APP); } create_session_response_p = &message_p->ittiMsg.s11_create_session_response; @@ -1398,14 +1458,15 @@ void handle_s5_create_session_response( .bearer_contexts[0] .eps_bearer_id = session_resp.eps_bearer_id; create_session_response_p->teid = - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.mme_teid_S11; - create_session_response_p->trxn = - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.trxn; + new_bearer_ctxt_info_p->sgw_eps_bearer_context().mme_teid_s11(); + memcpy(create_session_response_p->trxn, + reinterpret_cast( + new_bearer_ctxt_info_p->sgw_eps_bearer_context().trxn().c_str()), + new_bearer_ctxt_info_p->sgw_eps_bearer_context().trxn().size()); message_p->ittiMsgHeader.imsi = - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64; + new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64(); OAILOG_DEBUG_UE( - LOG_SPGW_APP, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64, + LOG_SPGW_APP, new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64(), "Sending S11 Create Session Response to MME, MME S11 teid = %u\n", create_session_response_p->teid); @@ -1415,14 +1476,13 @@ void handle_s5_create_session_response( * response failure is received */ OAILOG_INFO_UE( - LOG_SPGW_APP, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64, - "Deleted default bearer context with SGW C-plane TEID = %u " + LOG_SPGW_APP, new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64(), + "Deleted default bearer context with SGW C-plane TEID =" TEID_FMT "as create session response failure is received\n", - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.mme_teid_S11); + new_bearer_ctxt_info_p->sgw_eps_bearer_context().mme_teid_s11()); sgw_cm_remove_bearer_context_information( session_resp.context_teid, - new_bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64); + new_bearer_ctxt_info_p->sgw_eps_bearer_context().imsi64()); OAILOG_FUNC_OUT(LOG_SPGW_APP); } @@ -1439,7 +1499,6 @@ status_code_e sgw_handle_suspend_notification( itti_s11_suspend_acknowledge_t* suspend_acknowledge_p = NULL; MessageDef* message_p = NULL; status_code_e rv = RETURNok; - sgw_eps_bearer_ctxt_t* eps_bearer_entry_p = NULL; OAILOG_FUNC_IN(LOG_SPGW_APP); OAILOG_DEBUG_UE(LOG_SPGW_APP, imsi64, "Rx SUSPEND_NOTIFICATION, teid %u\n", @@ -1456,38 +1515,41 @@ status_code_e sgw_handle_suspend_notification( suspend_acknowledge_p = &message_p->ittiMsg.s11_suspend_acknowledge; memset((void*)suspend_acknowledge_p, 0, sizeof(itti_s11_suspend_acknowledge_t)); - s_plus_p_gw_eps_bearer_context_information_t* ctx_p = + + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + magma::lte::oai::S11BearerContext* ctx_p = sgw_cm_get_spgw_context(suspend_notification_pP->teid); if (ctx_p) { - ctx_p->sgw_eps_bearer_context_information.pdn_connection - .ue_suspended_for_ps_handover = true; + ctx_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection() + ->set_ue_suspended_for_ps_handover(true); suspend_acknowledge_p->cause.cause_value = REQUEST_ACCEPTED; suspend_acknowledge_p->teid = - ctx_p->sgw_eps_bearer_context_information.mme_teid_S11; + ctx_p->sgw_eps_bearer_context().mme_teid_s11(); /* * TODO Need to discard the DL data * deleting the GTPV1-U tunnel in suspended mode * This tunnel will be added again when UE moves back to connected mode. */ - eps_bearer_entry_p = - ctx_p->sgw_eps_bearer_context_information.pdn_connection - .sgw_eps_bearers_array[EBI_TO_INDEX(suspend_notification_pP->lbi)]; - if (eps_bearer_entry_p) { + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = ctx_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection() + ->mutable_eps_bearer_map(); + if (eps_bearer_map.get(suspend_notification_pP->lbi, &eps_bearer_ctxt) == + magma::PROTO_MAP_OK) { OAILOG_DEBUG_UE( LOG_SPGW_APP, imsi64, "Handle S11_SUSPEND_NOTIFICATION: Discard the Data received GTP-U " "Tunnel mapping in" "GTP-U Kernel module \n"); // delete GTPv1-U tunnel - struct in_addr ue_ipv4 = eps_bearer_entry_p->paa.ipv4_address; - struct in6_addr* ue_ipv6 = NULL; - if ((eps_bearer_entry_p->paa.pdn_type == IPv6) || - (eps_bearer_entry_p->paa.pdn_type == IPv4_AND_v6)) { - ue_ipv6 = &eps_bearer_entry_p->paa.ipv6_address; - } + struct in_addr ue_ipv4 = {.s_addr = 0}; + struct in6_addr ue_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt(eps_bearer_ctxt.mutable_ue_ip_paa(), + &ue_ipv4, &ue_ipv6, true); #if !MME_UNIT_TEST if (gtp_tunnel_ops->discard_data_on_tunnel( - ue_ipv4, ue_ipv6, eps_bearer_entry_p->s_gw_teid_S1u_S12_S4_up, + ue_ipv4, &ue_ipv6, eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), NULL) < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "ERROR in Disabling DL data on TUNNEL\n"); @@ -1525,11 +1587,7 @@ status_code_e sgw_handle_nw_initiated_actv_bearer_rsp( OAILOG_FUNC_IN(LOG_SPGW_APP); uint32_t msg_bearer_index = 0; status_code_e rc = RETURNerror; - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = nullptr; - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_entry_p = nullptr; - struct sgw_eps_bearer_entry_wrapper_s* sgw_eps_bearer_entry_p = nullptr; gtpv2c_cause_value_t cause = REQUEST_REJECTED; - pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = NULL; bearer_context_within_create_bearer_response_t bearer_context = {0}; char policy_rule_name[POLICY_RULE_NAME_MAXLEN + 1]; ebi_t default_bearer_id; @@ -1540,7 +1598,7 @@ status_code_e sgw_handle_nw_initiated_actv_bearer_rsp( "Received nw_initiated_bearer_actv_rsp from MME with EBI %u\n", bearer_context.eps_bearer_id); - s_plus_p_gw_eps_bearer_context_information_t* spgw_context = + magma::lte::oai::S11BearerContext* spgw_context = sgw_cm_get_spgw_context(s11_actv_bearer_rsp->sgw_s11_teid); if (!spgw_context) { OAILOG_ERROR_UE( @@ -1549,33 +1607,29 @@ status_code_e sgw_handle_nw_initiated_actv_bearer_rsp( "\n", s11_actv_bearer_rsp->sgw_s11_teid); handle_failed_create_bearer_response( - &spgw_context->sgw_eps_bearer_context_information, - s11_actv_bearer_rsp->cause.cause_value, imsi64, &bearer_context, NULL, - LOG_SPGW_APP); + spgw_context->mutable_sgw_eps_bearer_context(), + s11_actv_bearer_rsp->cause.cause_value, imsi64, &bearer_context, + nullptr, LOG_SPGW_APP); OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); } - default_bearer_id = spgw_context->sgw_eps_bearer_context_information - .pdn_connection.default_bearer; + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + spgw_context->mutable_sgw_eps_bearer_context(); + default_bearer_id = sgw_context_p->pdn_connection().default_bearer(); //-------------------------------------- // EPS bearer entry //-------------------------------------- // TODO multiple bearers - pgw_ni_cbr_proc = pgw_get_procedure_create_bearer( - &spgw_context->sgw_eps_bearer_context_information); - - if (!pgw_ni_cbr_proc) { + if (!(sgw_context_p->pending_procedures_size())) { OAILOG_ERROR_UE( LOG_SPGW_APP, imsi64, "Failed to get create bearer procedure from temporary stored context, " - "so " - "did not create new EPS bearer entry for EBI %u\n", + "so did not create new EPS bearer entry for EBI %u\n", bearer_context.eps_bearer_id); handle_failed_create_bearer_response( - &spgw_context->sgw_eps_bearer_context_information, - s11_actv_bearer_rsp->cause.cause_value, imsi64, &bearer_context, NULL, - LOG_SPGW_APP); + sgw_context_p, s11_actv_bearer_rsp->cause.cause_value, imsi64, + &bearer_context, nullptr, LOG_SPGW_APP); OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); } // If UE did not accept the request send reject to NW @@ -1585,63 +1639,81 @@ status_code_e sgw_handle_nw_initiated_actv_bearer_rsp( "UE rejected the request for EBI %u\n", bearer_context.eps_bearer_id); handle_failed_create_bearer_response( - &spgw_context->sgw_eps_bearer_context_information, - s11_actv_bearer_rsp->cause.cause_value, imsi64, &bearer_context, NULL, - LOG_SPGW_APP); + sgw_context_p, s11_actv_bearer_rsp->cause.cause_value, imsi64, + &bearer_context, nullptr, LOG_SPGW_APP); OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); } + magma::lte::oai::PgwCbrProcedure* pgw_ni_cbr_proc = nullptr; + uint8_t num_of_bearers_deleted = 0; + uint8_t num_of_pending_procedures = sgw_context_p->pending_procedures_size(); + for (uint8_t proc_index = 0; + proc_index < sgw_context_p->pending_procedures_size(); proc_index++) { + pgw_ni_cbr_proc = sgw_context_p->mutable_pending_procedures(proc_index); + if (!pgw_ni_cbr_proc) { + OAILOG_ERROR_UE( + LOG_SPGW_APP, sgw_context_p->imsi64(), + "Pending procedure within sgw_context is null for proc_index:%u", + proc_index); + OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); + } + if (pgw_ni_cbr_proc->type() == + PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST) { + num_of_bearers_deleted = pgw_ni_cbr_proc->pending_eps_bearers_size(); + for (uint8_t bearer_index = 0; + bearer_index < pgw_ni_cbr_proc->pending_eps_bearers_size(); + bearer_index++) { + magma::lte::oai::SgwEpsBearerContext* bearer_context_proto = + pgw_ni_cbr_proc->mutable_pending_eps_bearers(bearer_index); + if (!bearer_context_proto) { + OAILOG_ERROR_UE(LOG_SPGW_APP, sgw_context_p->imsi64(), + "Bearer context within pending procedure is null for " + "proc_index:%u bearer_index:%u", + proc_index, bearer_index); + OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); + } - sgw_eps_bearer_entry_p = LIST_FIRST(pgw_ni_cbr_proc->pending_eps_bearers); - while (sgw_eps_bearer_entry_p) { - if (bearer_context.s1u_sgw_fteid.teid == - sgw_eps_bearer_entry_p->sgw_eps_bearer_entry->s_gw_teid_S1u_S12_S4_up) { - eps_bearer_ctxt_p = sgw_eps_bearer_entry_p->sgw_eps_bearer_entry; - if (eps_bearer_ctxt_p) { - eps_bearer_ctxt_p->eps_bearer_id = bearer_context.eps_bearer_id; - - // Store enb-s1u teid and ip address - get_fteid_ip_address(&bearer_context.s1u_enb_fteid, - &eps_bearer_ctxt_p->enb_ip_address_S1u); - eps_bearer_ctxt_p->enb_teid_S1u = bearer_context.s1u_enb_fteid.teid; - - eps_bearer_ctxt_entry_p = sgw_cm_insert_eps_bearer_ctxt_in_collection( - &spgw_context->sgw_eps_bearer_context_information.pdn_connection, - eps_bearer_ctxt_p); - if (eps_bearer_ctxt_entry_p == NULL) { - OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, - "Failed to create new EPS bearer entry\n"); - increment_counter("s11_actv_bearer_rsp", 1, 2, "result", "failure", - "cause", "internal_software_error"); - } else { - OAILOG_INFO_UE( - LOG_SPGW_APP, imsi64, - "Successfully created new EPS bearer entry with EBI %d\n", - eps_bearer_ctxt_p->eps_bearer_id); - - cause = REQUEST_ACCEPTED; - strcpy(policy_rule_name, eps_bearer_ctxt_entry_p->policy_rule_name); - // setup GTPv1-U tunnel for each packet filter - // enb, UE and imsi are common across rules - add_tunnel_helper(spgw_context, eps_bearer_ctxt_entry_p, imsi64); + if (bearer_context_proto->sgw_teid_s1u_s12_s4_up() == + bearer_context.s1u_sgw_fteid.teid) { + bearer_context_proto->set_eps_bearer_id(bearer_context.eps_bearer_id); + FTEID_T_2_PROTO_IP(&bearer_context.s1u_enb_fteid, + bearer_context_proto->mutable_enb_s1u_ip_addr()); + bearer_context_proto->set_enb_teid_s1u( + bearer_context.s1u_enb_fteid.teid); + if (sgw_cm_insert_eps_bearer_ctxt_in_collection( + sgw_context_p->mutable_pdn_connection(), + bearer_context_proto) != magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE( + LOG_SPGW_APP, imsi64, + "Failed to create new EPS bearer entry for bearer id: %u\n", + bearer_context.eps_bearer_id); + increment_counter("s11_actv_bearer_rsp", 1, 2, "result", "failure", + "cause", "internal_software_error"); + } else { + OAILOG_INFO_UE( + LOG_SPGW_APP, imsi64, + "Successfully created new EPS bearer entry with EBI %u\n", + bearer_context.eps_bearer_id); + + cause = REQUEST_ACCEPTED; + snprintf(policy_rule_name, POLICY_RULE_NAME_MAXLEN + 1, "%s", + bearer_context_proto->policy_rule_name().c_str()); + // setup GTPv1-U tunnel for each packet filter + // enb, UE and imsi are common across rules + add_tunnel_helper(spgw_context, bearer_context_proto, imsi64); + } + --num_of_bearers_deleted; } - } - // Remove the temporary spgw entry - LIST_REMOVE(sgw_eps_bearer_entry_p, entries); - free_cpp_wrapper(reinterpret_cast(&sgw_eps_bearer_entry_p)); - break; + if (num_of_bearers_deleted == 0) { + pgw_ni_cbr_proc->clear_pending_eps_bearers(); + --num_of_pending_procedures; + } + } // end of bearer index loop } - sgw_eps_bearer_entry_p = LIST_NEXT(sgw_eps_bearer_entry_p, entries); - } - if (pgw_ni_cbr_proc && (LIST_EMPTY(pgw_ni_cbr_proc->pending_eps_bearers))) { - pgw_base_proc_t* base_proc1 = LIST_FIRST( - spgw_context->sgw_eps_bearer_context_information.pending_procedures); - LIST_REMOVE(base_proc1, entries); - free_cpp_wrapper(reinterpret_cast( - &spgw_context->sgw_eps_bearer_context_information.pending_procedures)); - free_cpp_wrapper( - reinterpret_cast(&pgw_ni_cbr_proc->pending_eps_bearers)); - pgw_free_procedure_create_bearer((pgw_ni_cbr_proc_t**)&pgw_ni_cbr_proc); + } // end of procedure index loop + if (num_of_pending_procedures == 0) { + sgw_context_p->clear_pending_procedures(); } + // Send ACTIVATE_DEDICATED_BEARER_RSP to PCRF rc = spgw_send_nw_init_activate_bearer_rsp( cause, imsi64, &bearer_context, default_bearer_id, policy_rule_name); @@ -1675,7 +1747,7 @@ status_code_e sgw_handle_nw_initiated_deactv_bearer_rsp( //-------------------------------------- // Get EPS bearer entry //-------------------------------------- - s_plus_p_gw_eps_bearer_context_information_t* spgw_ctxt = + magma::lte::oai::S11BearerContext* spgw_ctxt = sgw_cm_get_spgw_context(s11_pcrf_ded_bearer_deactv_rsp->s_gw_teid_s11_s4); if (!spgw_ctxt) { OAILOG_ERROR_UE( @@ -1684,7 +1756,9 @@ status_code_e sgw_handle_nw_initiated_deactv_bearer_rsp( s11_pcrf_ded_bearer_deactv_rsp->s_gw_teid_s11_s4); OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); } - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = NULL; + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + spgw_ctxt->mutable_sgw_eps_bearer_context(); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; // Remove the default bearer entry if (s11_pcrf_ded_bearer_deactv_rsp->delete_default_bearer) { if (!s11_pcrf_ded_bearer_deactv_rsp->lbi) { @@ -1692,67 +1766,94 @@ status_code_e sgw_handle_nw_initiated_deactv_bearer_rsp( OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); } // Delete all the dedicated bearers linked to this default bearer - for (int ebix = 0; ebix < BEARERS_PER_UE; ebix++) { - ebi = INDEX_TO_EBI(ebix); - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_ctxt->sgw_eps_bearer_context_information.pdn_connection, ebi); - - if (eps_bearer_ctxt_p) { - if (ebi != *s11_pcrf_ded_bearer_deactv_rsp->lbi) { + std::vector remove_bearer_list = {}; + if (sgw_context_p->mutable_pdn_connection()->eps_bearer_map_size()) { + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = + sgw_context_p->mutable_pdn_connection()->mutable_eps_bearer_map(); + for (auto itr = eps_bearer_map.map->begin(); + itr != eps_bearer_map.map->end(); itr++) { + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt = itr->second; + + if (eps_bearer_ctxt.eps_bearer_id() != + *s11_pcrf_ded_bearer_deactv_rsp->lbi) { struct in_addr enb = {.s_addr = 0}; - enb.s_addr = - eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv4_address.s_addr; - struct in6_addr* enb_ipv6 = NULL; - if (spgw_config.sgw_config.ipv6.s1_ipv6_enabled && - eps_bearer_ctxt_p->enb_ip_address_S1u.pdn_type == IPv6) { - enb_ipv6 = - &eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv6_address; - } - struct in6_addr* ue_ipv6 = NULL; - if ((eps_bearer_ctxt_p->paa.pdn_type == IPv6) || - (eps_bearer_ctxt_p->paa.pdn_type == IPv4_AND_v6)) { - ue_ipv6 = &eps_bearer_ctxt_p->paa.ipv6_address; + struct in6_addr enb_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_enb_s1u_ip_addr(), &enb, &enb_ipv6, + spgw_config.sgw_config.ipv6.s1_ipv6_enabled); + + struct in_addr ue_ipv4 = {.s_addr = 0}; + struct in6_addr ue_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_ue_ip_paa(), &ue_ipv4, &ue_ipv6, true); + bool is_ue_ipv6_pres = false; + if (((eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv6 || + eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4_AND_v6)) && + !(eps_bearer_ctxt.ue_ip_paa().ipv6_addr().empty())) { + is_ue_ipv6_pres = true; } + #if !MME_UNIT_TEST - if (gtp_tunnel_ops->del_tunnel( - enb, enb_ipv6, eps_bearer_ctxt_p->paa.ipv4_address, ue_ipv6, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->enb_teid_S1u, NULL) < 0) { + int rc = RETURNerror; + if (is_ue_ipv6_pres) { + rc = gtp_tunnel_ops->del_tunnel( + enb, &enb_ipv6, ue_ipv4, &ue_ipv6, + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.enb_teid_s1u(), nullptr); + } else { + rc = gtp_tunnel_ops->del_tunnel( + enb, &enb_ipv6, ue_ipv4, nullptr, + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.enb_teid_s1u(), nullptr); + } + if (rc != RETURNok) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "ERROR in deleting TUNNEL " TEID_FMT " (eNB) <-> (SGW) " TEID_FMT "\n", - eps_bearer_ctxt_p->enb_teid_S1u, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up); + eps_bearer_ctxt.enb_teid_s1u(), + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up()); } else { OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, "Removed dedicated bearer context for (ebi = %d)\n", ebi); } #endif - - sgw_free_eps_bearer_context( - &spgw_ctxt->sgw_eps_bearer_context_information.pdn_connection - .sgw_eps_bearers_array[EBI_TO_INDEX(ebi)]); + remove_bearer_list.push_back(eps_bearer_ctxt.eps_bearer_id()); } } + for (uint8_t i = 0; i < remove_bearer_list.size(); i++) { + sgw_remove_eps_bearer_context(sgw_context_p->mutable_pdn_connection(), + remove_bearer_list[i]); + } + remove_bearer_list.clear(); } - OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, "Removed default bearer context for (ebi = %d)\n", *s11_pcrf_ded_bearer_deactv_rsp->lbi); ebi = *s11_pcrf_ded_bearer_deactv_rsp->lbi; - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_ctxt->sgw_eps_bearer_context_information.pdn_connection, ebi); + if (sgw_cm_get_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + ebi, + &eps_bearer_ctxt) != magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, + "Failed to get eps_bearer_ctxt for bearer id:%u", ebi); + OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); + } sgi_delete_end_point_request.context_teid = - spgw_ctxt->sgw_eps_bearer_context_information.s_gw_teid_S11_S4; + sgw_context_p->sgw_teid_s11_s4(); sgi_delete_end_point_request.sgw_S1u_teid = - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up; + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(); sgi_delete_end_point_request.eps_bearer_id = ebi; sgi_delete_end_point_request.pdn_type = - spgw_ctxt->sgw_eps_bearer_context_information.saved_message.pdn_type; - memcpy(&sgi_delete_end_point_request.paa, &eps_bearer_ctxt_p->paa, - sizeof(paa_t)); + sgw_context_p->saved_message().pdn_type(); + + sgi_delete_end_point_request.paa.pdn_type = + (pdn_type_value_t)eps_bearer_ctxt.ue_ip_paa().pdn_type(); + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_ue_ip_paa(), + &sgi_delete_end_point_request.paa.ipv4_address, + &sgi_delete_end_point_request.paa.ipv6_address, true); sgw_handle_sgi_endpoint_deleted(&sgi_delete_end_point_request, imsi64); @@ -1761,55 +1862,63 @@ status_code_e sgw_handle_nw_initiated_deactv_bearer_rsp( } else { // Remove the dedicated bearer/s context for (i = 0; i < no_of_bearers; i++) { - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_ctxt->sgw_eps_bearer_context_information.pdn_connection, - s11_pcrf_ded_bearer_deactv_rsp->bearer_contexts.bearer_contexts[i] - .eps_bearer_id); - if (eps_bearer_ctxt_p) { - ebi = s11_pcrf_ded_bearer_deactv_rsp->bearer_contexts.bearer_contexts[i] - .eps_bearer_id; + ebi = s11_pcrf_ded_bearer_deactv_rsp->bearer_contexts.bearer_contexts[i] + .eps_bearer_id; + if (sgw_cm_get_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + ebi, &eps_bearer_ctxt) == + magma::PROTO_MAP_OK) { OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, - "Removed bearer context for (ebi = %d)\n", ebi); + "Removed bearer context for (ebi = %u)\n", ebi); // Get all the DL flow rules for this dedicated bearer - for (int itrn = 0; itrn < eps_bearer_ctxt_p->tft.numberofpacketfilters; - ++itrn) { + for (uint8_t itrn = 0; + itrn < eps_bearer_ctxt.tft().number_of_packet_filters(); ++itrn) { // Prepare DL flow rule from stored packet filters struct ip_flow_dl dlflow = {0}; - struct in6_addr* ue_ipv6 = NULL; - if ((eps_bearer_ctxt_p->paa.pdn_type == IPv6) || - (eps_bearer_ctxt_p->paa.pdn_type == IPv4_AND_v6)) { - ue_ipv6 = &eps_bearer_ctxt_p->paa.ipv6_address; + struct in_addr ue_ipv4 = {.s_addr = 0}; + struct in6_addr ue_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_ue_ip_paa(), &ue_ipv4, &ue_ipv6, true); + bool is_ue_ipv6_pres = false; + if (((eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv6 || + eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4_AND_v6)) && + !(eps_bearer_ctxt.ue_ip_paa().ipv6_addr().empty())) { + is_ue_ipv6_pres = true; } - generate_dl_flow( - &(eps_bearer_ctxt_p->tft.packetfilterlist.createnewtft[itrn] - .packetfiltercontents), - eps_bearer_ctxt_p->paa.ipv4_address.s_addr, ue_ipv6, &dlflow); - struct in_addr enb = {.s_addr = 0}; - enb.s_addr = - eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv4_address.s_addr; - struct in6_addr* enb_ipv6 = NULL; - if (spgw_config.sgw_config.ipv6.s1_ipv6_enabled && - eps_bearer_ctxt_p->enb_ip_address_S1u.pdn_type == IPv6) { - enb_ipv6 = - &eps_bearer_ctxt_p->enb_ip_address_S1u.address.ipv6_address; + + magma::lte::oai::PacketFilter create_new_tft = + eps_bearer_ctxt.tft().packet_filter_list().create_new_tft(itrn); + create_new_tft_t new_tft = {0}; + proto_to_packet_filter(create_new_tft, &new_tft); + if (is_ue_ipv6_pres) { + generate_dl_flow(&new_tft.packetfiltercontents, ue_ipv4.s_addr, + &ue_ipv6, &dlflow); + } else { + generate_dl_flow(&new_tft.packetfiltercontents, ue_ipv4.s_addr, + nullptr, &dlflow); } + + struct in_addr enb = {.s_addr = 0}; + struct in6_addr enb_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_enb_s1u_ip_addr(), &enb, &enb_ipv6, + spgw_config.sgw_config.ipv6.s1_ipv6_enabled); + #if !MME_UNIT_TEST if (gtp_tunnel_ops->del_tunnel( - enb, enb_ipv6, eps_bearer_ctxt_p->paa.ipv4_address, ue_ipv6, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_p->enb_teid_S1u, &dlflow) < 0) { + enb, &enb_ipv6, ue_ipv4, &ue_ipv6, + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.enb_teid_s1u(), &dlflow) < 0) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, "ERROR in deleting TUNNEL " TEID_FMT " (eNB) <-> (SGW) " TEID_FMT "\n", - eps_bearer_ctxt_p->enb_teid_S1u, - eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up); + eps_bearer_ctxt.enb_teid_s1u(), + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up()); } #endif } - sgw_free_eps_bearer_context( - &spgw_ctxt->sgw_eps_bearer_context_information.pdn_connection - .sgw_eps_bearers_array[EBI_TO_INDEX(ebi)]); + sgw_remove_eps_bearer_context(sgw_context_p->mutable_pdn_connection(), + eps_bearer_ctxt.eps_bearer_id()); } } } @@ -1829,52 +1938,55 @@ status_code_e sgw_handle_ip_allocation_rsp( OAILOG_DEBUG_UE(LOG_SPGW_APP, imsi64, "Received ip_allocation_rsp from gRPC task handler\n"); - s_plus_p_gw_eps_bearer_context_information_t* bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* bearer_ctxt_info_p = sgw_cm_get_spgw_context(ip_allocation_rsp->context_teid); if (!bearer_ctxt_info_p) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, - "Failed to get SPGW UE context for teid %u\n", + "Failed to get SPGW UE context for teid" TEID_FMT, ip_allocation_rsp->context_teid); OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); } - sgw_eps_bearer_ctxt_t* eps_bearer_ctx_p = sgw_cm_get_eps_bearer_entry( - &bearer_ctxt_info_p->sgw_eps_bearer_context_information.pdn_connection, - ip_allocation_rsp->eps_bearer_id); - if (!eps_bearer_ctx_p) { - OAILOG_ERROR_UE( - LOG_SPGW_APP, - bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi64, - "Failed to get default bearer context\n"); + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + bearer_ctxt_info_p->mutable_sgw_eps_bearer_context(); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctx; + if (sgw_cm_get_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + ip_allocation_rsp->eps_bearer_id, + &eps_bearer_ctx) != magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE(LOG_SPGW_APP, sgw_context_p->imsi64(), + "Failed to get default bearer context for bearer id: %u\n", + ip_allocation_rsp->eps_bearer_id); OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); } - char* imsi = - (char*)bearer_ctxt_info_p->sgw_eps_bearer_context_information.imsi.digit; + std::string imsi = sgw_context_p->imsi(); if (ip_allocation_rsp->status == SGI_STATUS_OK) { - memcpy(&eps_bearer_ctx_p->paa, &ip_allocation_rsp->paa, sizeof(paa_t)); - + eps_bearer_ctx.mutable_ue_ip_paa()->set_pdn_type( + ip_allocation_rsp->paa.pdn_type); // create session in PCEF s5_create_session_request_t session_req = {0}; session_req.context_teid = ip_allocation_rsp->context_teid; session_req.eps_bearer_id = ip_allocation_rsp->eps_bearer_id; session_req.status = ip_allocation_rsp->status; - struct pcef_create_session_data session_data; - get_session_req_data( - spgw_state, - &bearer_ctxt_info_p->sgw_eps_bearer_context_information.saved_message, - &session_data); + struct pcef_create_session_data session_data = {}; + get_session_req_data(spgw_state, sgw_context_p->mutable_saved_message(), + &session_data); // Create session based IPv4, IPv6 or IPv4v6 PDN type if (ip_allocation_rsp->paa.pdn_type == IPv4) { char ip_str[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &(ip_allocation_rsp->paa.ipv4_address.s_addr), ip_str, INET_ADDRSTRLEN); + eps_bearer_ctx.mutable_ue_ip_paa()->set_ipv4_addr(ip_str); pcef_create_session(imsi, ip_str, NULL, &session_data, session_req); } else if (ip_allocation_rsp->paa.pdn_type == IPv6) { char ip6_str[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &(ip_allocation_rsp->paa.ipv6_address), ip6_str, INET6_ADDRSTRLEN); + eps_bearer_ctx.mutable_ue_ip_paa()->set_ipv6_addr(ip6_str); + eps_bearer_ctx.mutable_ue_ip_paa()->set_ipv6_prefix_length( + ip_allocation_rsp->paa.ipv6_prefix_length); + eps_bearer_ctx.mutable_ue_ip_paa()->set_vlan(ip_allocation_rsp->paa.vlan); pcef_create_session(imsi, NULL, ip6_str, &session_data, session_req); } else if (ip_allocation_rsp->paa.pdn_type == IPv4_AND_v6) { char ip4_str[INET_ADDRSTRLEN]; @@ -1883,8 +1995,22 @@ status_code_e sgw_handle_ip_allocation_rsp( char ip6_str[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &(ip_allocation_rsp->paa.ipv6_address), ip6_str, INET6_ADDRSTRLEN); + eps_bearer_ctx.mutable_ue_ip_paa()->set_ipv4_addr(ip4_str); + eps_bearer_ctx.mutable_ue_ip_paa()->set_ipv6_addr(ip6_str); + eps_bearer_ctx.mutable_ue_ip_paa()->set_ipv6_prefix_length( + ip_allocation_rsp->paa.ipv6_prefix_length); + eps_bearer_ctx.mutable_ue_ip_paa()->set_vlan(ip_allocation_rsp->paa.vlan); pcef_create_session(imsi, ip4_str, ip6_str, &session_data, session_req); } + if (sgw_update_eps_bearer_entry(sgw_context_p->mutable_pdn_connection(), + ip_allocation_rsp->eps_bearer_id, + &eps_bearer_ctx) != magma::PROTO_MAP_OK) { + OAILOG_ERROR_UE( + LOG_SPGW_APP, sgw_context_p->imsi64(), + "Failed to update default bearer context for bearer id %u\n", + ip_allocation_rsp->eps_bearer_id); + OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNerror); + } } else { if (ip_allocation_rsp->status == SGI_STATUS_ERROR_SYSTEM_FAILURE) { /* @@ -1892,8 +2018,7 @@ status_code_e sgw_handle_ip_allocation_rsp( * Release the IP address so that subsequent attempt is successfull */ // TODO - Release the GTP-tunnel corresponding to this IP address - char* apn = (char*)bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection.apn_in_use; + std::string apn = sgw_context_p->pdn_connection().apn_in_use(); if (ip_allocation_rsp->paa.pdn_type == IPv4) { release_ipv4_address(imsi, apn, &ip_allocation_rsp->paa.ipv4_address); } else if (ip_allocation_rsp->paa.pdn_type == IPv6) { @@ -1915,30 +2040,24 @@ status_code_e sgw_handle_ip_allocation_rsp( OAILOG_FUNC_RETURN(LOG_SPGW_APP, RETURNok); } -bool is_enb_ip_address_same(const fteid_t* fte_p, ip_address_t* ip_p) { +bool is_enb_ip_address_same(const fteid_t* fte_p, struct in_addr ipv4, + struct in6_addr ipv6) { bool rc = true; - - switch ((ip_p)->pdn_type) { - case IPv4: - if ((ip_p)->address.ipv4_address.s_addr != (fte_p)->ipv4_address.s_addr) { - rc = false; - } - break; - case IPv4_AND_v6: - case IPv6: - if (memcmp(&(ip_p)->address.ipv6_address, &(fte_p)->ipv6_address, - sizeof((ip_p)->address.ipv6_address)) != 0) { - rc = false; - } - break; - default: - rc = true; - break; + if ((fte_p)->ipv4) { + if (ipv4.s_addr != (fte_p)->ipv4_address.s_addr) { + rc = false; + } + } else if ((fte_p)->ipv6) { + if (memcmp(&ipv6, &(fte_p)->ipv6_address, sizeof(struct in6_addr)) != 0) { + rc = false; + } + } else { + rc = true; } OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); } -void handle_failed_create_bearer_response( +void handle_failed_s8_create_bearer_response( sgw_eps_bearer_context_information_t* sgw_context_p, gtpv2c_cause_value_t cause, imsi64_t imsi64, bearer_context_within_create_bearer_response_t* bearer_context, @@ -2006,6 +2125,86 @@ void handle_failed_create_bearer_response( OAILOG_FUNC_OUT(module); } +void handle_failed_create_bearer_response( + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p, + gtpv2c_cause_value_t cause, imsi64_t imsi64, + bearer_context_within_create_bearer_response_t* bearer_context, + magma::lte::oai::SgwEpsBearerContext* dedicated_bearer_ctxt_p, + log_proto_t module) { + OAILOG_FUNC_IN(module); + char policy_rule_name[POLICY_RULE_NAME_MAXLEN + 1]; + ebi_t default_bearer_id = 0; + + if (sgw_context_p) { + if (!(sgw_context_p->pending_procedures_size())) { + OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, + "Failed to get create bearer procedure from temporary " + "stored context for EBI %u\n", + bearer_context->eps_bearer_id); + OAILOG_FUNC_OUT(module); + } + default_bearer_id = sgw_context_p->pdn_connection().default_bearer(); + + uint8_t num_of_bearers_deleted = 0; + uint8_t num_of_pending_procedures = + sgw_context_p->pending_procedures_size(); + for (uint8_t proc_index = 0; + proc_index < sgw_context_p->pending_procedures_size(); proc_index++) { + magma::lte::oai::PgwCbrProcedure* pgw_ni_cbr_proc = + sgw_context_p->mutable_pending_procedures(proc_index); + if (!pgw_ni_cbr_proc) { + OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, + "Failed to get create bearer procedure from temporary " + "stored context for EBI %u\n", + bearer_context->eps_bearer_id); + OAILOG_FUNC_OUT(module); + } + if (pgw_ni_cbr_proc->type() == + PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST) { + num_of_bearers_deleted = pgw_ni_cbr_proc->pending_eps_bearers_size(); + for (uint8_t bearer_index = 0; + bearer_index < pgw_ni_cbr_proc->pending_eps_bearers_size(); + bearer_index++) { + magma::lte::oai::SgwEpsBearerContext* stored_bearer_context_info = + pgw_ni_cbr_proc->mutable_pending_eps_bearers(bearer_index); + if (stored_bearer_context_info) { + if (bearer_context->s1u_sgw_fteid.teid == + stored_bearer_context_info->sgw_teid_s1u_s12_s4_up()) { + if (module == LOG_SPGW_APP) { + snprintf( + policy_rule_name, POLICY_RULE_NAME_MAXLEN + 1, "%s", + stored_bearer_context_info->policy_rule_name().c_str()); + } + if (dedicated_bearer_ctxt_p) { + memcpy(dedicated_bearer_ctxt_p, stored_bearer_context_info, + sizeof(dedicated_bearer_ctxt_p)); + } + } + --num_of_bearers_deleted; + } + if (num_of_bearers_deleted == 0) { + pgw_ni_cbr_proc->clear_pending_eps_bearers(); + --num_of_pending_procedures; + } + } + } + } + if (num_of_pending_procedures == 0) { + sgw_context_p->clear_pending_procedures(); + } + if (module == LOG_SPGW_APP) { + if (spgw_send_nw_init_activate_bearer_rsp(cause, imsi64, bearer_context, + default_bearer_id, + policy_rule_name) != RETURNok) { + OAILOG_ERROR_UE( + module, imsi64, + "Failed to send ACTIVATE_DEDICATED_BEARER_RSP to PCRF\n"); + } + } + } + OAILOG_FUNC_OUT(module); +} + // Fills up downlink (DL) flow match rule from packet filters of eps bearer void generate_dl_flow(packet_filter_contents_t* packet_filter, in_addr_t ipv4_s_addr, struct in6_addr* ue_ipv6, @@ -2022,13 +2221,12 @@ void generate_dl_flow(packet_filter_contents_t* packet_filter, */ if ((TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG & packet_filter->flags) == TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG) { - struct in_addr remoteaddr = {.s_addr = 0}; - remoteaddr.s_addr = + dlflow->src_ip.s_addr = (((uint32_t)packet_filter->ipv4remoteaddr[0].addr) << 24) + (((uint32_t)packet_filter->ipv4remoteaddr[1].addr) << 16) + (((uint32_t)packet_filter->ipv4remoteaddr[2].addr) << 8) + (((uint32_t)packet_filter->ipv4remoteaddr[3].addr)); - dlflow->src_ip.s_addr = ntohl(remoteaddr.s_addr); + dlflow->set_params |= SRC_IPV4; dlflow->dst_ip.s_addr = ipv4_s_addr; dlflow->set_params |= DST_IPV4; @@ -2049,13 +2247,11 @@ void generate_dl_flow(packet_filter_contents_t* packet_filter, dlflow->set_params |= DST_IPV4; if ((TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG & packet_filter->flags) == TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG) { - struct in_addr remoteaddr = {}; - remoteaddr.s_addr = + dlflow->src_ip.s_addr = (((uint32_t)packet_filter->ipv4remoteaddr[0].addr) << 24) + (((uint32_t)packet_filter->ipv4remoteaddr[1].addr) << 16) + (((uint32_t)packet_filter->ipv4remoteaddr[2].addr) << 8) + (((uint32_t)packet_filter->ipv4remoteaddr[3].addr)); - dlflow->src_ip.s_addr = ntohl(remoteaddr.s_addr); dlflow->set_params |= SRC_IPV4; } } else if (ue_ipv6) { @@ -2111,48 +2307,65 @@ void generate_dl_flow(packet_filter_contents_t* packet_filter, // Helper function to generate dl flows and add tunnel for ipv4/ipv6/ipv4v6 // bearers static void add_tunnel_helper( - s_plus_p_gw_eps_bearer_context_information_t* spgw_context, - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_entry_p, imsi64_t imsi64) { + magma::lte::oai::S11BearerContext* spgw_context, + magma::lte::oai::SgwEpsBearerContext* eps_bearer_ctxt_entry_p, + imsi64_t imsi64) { uint32_t rc = RETURNerror; struct in_addr enb = {.s_addr = 0}; - char* apn = (char*)spgw_context->sgw_eps_bearer_context_information - .pdn_connection.apn_in_use; - struct in6_addr* enb_ipv6 = NULL; + const char* apn = reinterpret_cast( + spgw_context->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection() + ->apn_in_use() + .c_str()); + struct in6_addr enb_ipv6 = {}; - enb.s_addr = - eps_bearer_ctxt_entry_p->enb_ip_address_S1u.address.ipv4_address.s_addr; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt_entry_p->mutable_enb_s1u_ip_addr(), &enb, &enb_ipv6, + spgw_config.sgw_config.ipv6.s1_ipv6_enabled); - if (spgw_config.sgw_config.ipv6.s1_ipv6_enabled && - eps_bearer_ctxt_entry_p->enb_ip_address_S1u.pdn_type == IPv6) { - enb_ipv6 = - &eps_bearer_ctxt_entry_p->enb_ip_address_S1u.address.ipv6_address; - } struct in_addr ue_ipv4 = {.s_addr = 0}; - ue_ipv4.s_addr = eps_bearer_ctxt_entry_p->paa.ipv4_address.s_addr; - struct in6_addr* ue_ipv6 = NULL; - if ((eps_bearer_ctxt_entry_p->paa.pdn_type == IPv6) || - (eps_bearer_ctxt_entry_p->paa.pdn_type == IPv4_AND_v6)) { - ue_ipv6 = &eps_bearer_ctxt_entry_p->paa.ipv6_address; + struct in6_addr ue_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt_entry_p->mutable_ue_ip_paa(), &ue_ipv4, &ue_ipv6, true); + + bool is_ue_ipv6_pres = false; + if (((eps_bearer_ctxt_entry_p->ue_ip_paa().pdn_type() == IPv6 || + eps_bearer_ctxt_entry_p->ue_ip_paa().pdn_type() == IPv4_AND_v6)) && + !(eps_bearer_ctxt_entry_p->ue_ip_paa().ipv6_addr().empty())) { + is_ue_ipv6_pres = true; } - int vlan = eps_bearer_ctxt_entry_p->paa.vlan; - Imsi_t imsi = spgw_context->sgw_eps_bearer_context_information.imsi; + int vlan = eps_bearer_ctxt_entry_p->ue_ip_paa().vlan(); + Imsi_t imsi; + memcpy(imsi.digit, + spgw_context->mutable_sgw_eps_bearer_context()->imsi().c_str(), + spgw_context->mutable_sgw_eps_bearer_context()->imsi().size()); OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, "Number of packet filter rules: %d\n", - eps_bearer_ctxt_entry_p->tft.numberofpacketfilters); - for (int i = 0; i < eps_bearer_ctxt_entry_p->tft.numberofpacketfilters; ++i) { + eps_bearer_ctxt_entry_p->tft().number_of_packet_filters()); + for (uint8_t i = 0; + i < eps_bearer_ctxt_entry_p->tft().number_of_packet_filters(); ++i) { struct ip_flow_dl dlflow = {0}; - generate_dl_flow( - &(eps_bearer_ctxt_entry_p->tft.packetfilterlist.createnewtft[i] - .packetfiltercontents), - ue_ipv4.s_addr, ue_ipv6, &dlflow); + magma::lte::oai::PacketFilter create_new_tft = + eps_bearer_ctxt_entry_p->tft().packet_filter_list().create_new_tft(i); + create_new_tft_t new_tft = {0}; + proto_to_packet_filter(create_new_tft, &new_tft); + if (is_ue_ipv6_pres) { + generate_dl_flow(&new_tft.packetfiltercontents, ue_ipv4.s_addr, &ue_ipv6, + &dlflow); + } else { + generate_dl_flow(&new_tft.packetfiltercontents, ue_ipv4.s_addr, nullptr, + &dlflow); + } #if !MME_UNIT_TEST - rc = gtpv1u_add_tunnel( - ue_ipv4, ue_ipv6, vlan, enb, enb_ipv6, - eps_bearer_ctxt_entry_p->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt_entry_p->enb_teid_S1u, imsi, &dlflow, - eps_bearer_ctxt_entry_p->tft.packetfilterlist.createnewtft[i] - .eval_precedence, - apn); + rc = gtpv1u_add_tunnel(ue_ipv4, &ue_ipv6, vlan, enb, &enb_ipv6, + eps_bearer_ctxt_entry_p->sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt_entry_p->enb_teid_s1u(), imsi, + &dlflow, + eps_bearer_ctxt_entry_p->tft() + .packet_filter_list() + .create_new_tft(i) + .eval_precedence(), + apn); if (rc != RETURNok) { OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, @@ -2161,16 +2374,18 @@ static void add_tunnel_helper( OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, "Successfully setup flow rule for EPS bearer id %u " "tunnel " TEID_FMT " (eNB) <-> (SGW) " TEID_FMT "\n", - eps_bearer_ctxt_entry_p->eps_bearer_id, - eps_bearer_ctxt_entry_p->enb_teid_S1u, - eps_bearer_ctxt_entry_p->s_gw_teid_S1u_S12_S4_up); + eps_bearer_ctxt_entry_p->eps_bearer_id(), + eps_bearer_ctxt_entry_p->enb_teid_s1u(), + eps_bearer_ctxt_entry_p->sgw_teid_s1u_s12_s4_up()); } #endif } } -bool does_bearer_context_hold_valid_enb_ip(ip_address_t enb_ip_address_S1u) { + +bool does_sgw_bearer_context_hold_valid_enb_ip( + ip_address_t enb_ip_address_S1u) { OAILOG_FUNC_IN(LOG_SPGW_APP); - static struct in6_addr ipv6_address = {0}; + static struct in6_addr ipv6_address = {}; switch (enb_ip_address_S1u.pdn_type) { case IPv4: if (enb_ip_address_S1u.address.ipv4_address.s_addr) { @@ -2197,6 +2412,33 @@ bool does_bearer_context_hold_valid_enb_ip(ip_address_t enb_ip_address_S1u) { OAILOG_FUNC_RETURN(LOG_SPGW_APP, false); } +bool does_bearer_context_hold_valid_enb_ip( + magma::lte::oai::IpTupple enb_ip_address_S1u) { + OAILOG_FUNC_IN(LOG_SPGW_APP); + switch (enb_ip_address_S1u.pdn_type()) { + case IPv4: + if (enb_ip_address_S1u.ipv4_addr().size()) { + OAILOG_FUNC_RETURN(LOG_SPGW_APP, true); + } + break; + case IPv4_AND_v6: + if ((enb_ip_address_S1u.ipv4_addr().size()) || + ((enb_ip_address_S1u.ipv6_addr().size()))) { + OAILOG_FUNC_RETURN(LOG_SPGW_APP, true); + } + break; + case IPv6: + if (enb_ip_address_S1u.ipv6_addr().size()) { + OAILOG_FUNC_RETURN(LOG_SPGW_APP, true); + } + break; + default: + OAILOG_ERROR(LOG_SPGW_APP, "Invalid pdn-type \n"); + break; + } + OAILOG_FUNC_RETURN(LOG_SPGW_APP, false); +} + void sgw_send_release_access_bearer_response( log_proto_t module, task_id_t origin_task_id, imsi64_t imsi64, gtpv2c_cause_value_t cause, @@ -2241,67 +2483,75 @@ void sgw_send_release_access_bearer_response( void sgw_process_release_access_bearer_request( log_proto_t module, imsi64_t imsi64, - sgw_eps_bearer_context_information_t* sgw_context) { + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context) { OAILOG_FUNC_IN(module); - int rv = RETURNok; + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; /* * Release the tunnels so that in idle state, DL packets are not sent * towards eNB. * These tunnels will be added again when UE moves back to connected mode. */ - for (int ebx = 0; ebx < BEARERS_PER_UE; ebx++) { - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt = - sgw_context->pdn_connection.sgw_eps_bearers_array[ebx]; - if (eps_bearer_ctxt) { + magma::lte::oai::SgwPdnConnection* pdn_connection_p = + sgw_context->mutable_pdn_connection(); + if (pdn_connection_p->eps_bearer_map_size()) { + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = pdn_connection_p->mutable_eps_bearer_map(); + for (auto itr = eps_bearer_map.map->begin(); + itr != eps_bearer_map.map->end(); itr++) { + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt = itr->second; + struct in_addr enb = {.s_addr = 0}; - struct in6_addr* enb_ipv6 = NULL; - enb.s_addr = - eps_bearer_ctxt->enb_ip_address_S1u.address.ipv4_address.s_addr; - if (spgw_config.sgw_config.ipv6.s1_ipv6_enabled && - eps_bearer_ctxt->enb_ip_address_S1u.pdn_type == IPv6) { - enb_ipv6 = &eps_bearer_ctxt->enb_ip_address_S1u.address.ipv6_address; - } + struct in6_addr enb_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_enb_s1u_ip_addr(), &enb, &enb_ipv6, true); - struct in6_addr* ue_ipv6 = NULL; - if ((eps_bearer_ctxt->paa.pdn_type == IPv6) || - (eps_bearer_ctxt->paa.pdn_type == IPv4_AND_v6)) { - ue_ipv6 = &eps_bearer_ctxt->paa.ipv6_address; - } struct in_addr ue_ipv4 = {.s_addr = 0}; - ue_ipv4.s_addr = eps_bearer_ctxt->paa.ipv4_address.s_addr; - struct in_addr pgw = {.s_addr = 0}; - pgw.s_addr = - eps_bearer_ctxt->p_gw_address_in_use_up.address.ipv4_address.s_addr; - struct in6_addr* pgw_ipv6 = NULL; - if ((eps_bearer_ctxt->p_gw_address_in_use_up.pdn_type == IPv6) || - (eps_bearer_ctxt->p_gw_address_in_use_up.pdn_type == IPv4_AND_v6)) { - pgw_ipv6 = - &eps_bearer_ctxt->p_gw_address_in_use_up.address.ipv6_address; + struct in6_addr ue_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt(eps_bearer_ctxt.mutable_ue_ip_paa(), + &ue_ipv4, &ue_ipv6, true); + bool is_ue_ipv6_pres = false; + if (((eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv6 || + eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4_AND_v6)) && + !(eps_bearer_ctxt.ue_ip_paa().ipv6_addr().empty())) { + is_ue_ipv6_pres = true; } - OAILOG_DEBUG_UE( - module, imsi64, - "Deleting tunnel for bearer_id %u ue addr %x enb_ip %x " - "s_gw_teid_S1u_S12_S4_up %x, enb_teid_S1u %x pgw_up_ip %x " - "pgw_up_teid %x " - "s_gw_ip_address_S5_S8_up %x" - "s_gw_teid_S5_S8_up %x \n ", - eps_bearer_ctxt->eps_bearer_id, ue_ipv4.s_addr, enb.s_addr, - eps_bearer_ctxt->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt->enb_teid_S1u, pgw.s_addr, - eps_bearer_ctxt->p_gw_teid_S5_S8_up, - eps_bearer_ctxt->s_gw_ip_address_S5_S8_up.address.ipv4_address.s_addr, - eps_bearer_ctxt->s_gw_teid_S5_S8_up); + + struct in_addr pgw = {.s_addr = 0}; + struct in6_addr pgw_ipv6 = {}; + convert_proto_ip_to_standard_ip_fmt( + eps_bearer_ctxt.mutable_pgw_address_up(), &pgw, &pgw_ipv6, true); + + OAILOG_DEBUG_UE(module, imsi64, + "Deleting tunnel for bearer_id %u ue addr %x enb_ip %x " + "sgw_teid_s1u_s12_s4_up %x, enb_teid_S1u %x pgw_up_ip %x " + "pgw_up_teid " TEID_FMT + "s_gw_ip_address_S5_S8_up %s" + "s_gw_teid_S5_S8_up " TEID_FMT, + eps_bearer_ctxt.eps_bearer_id(), ue_ipv4.s_addr, + enb.s_addr, eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.enb_teid_s1u(), pgw.s_addr, + eps_bearer_ctxt.pgw_teid_s5_s8_up(), + eps_bearer_ctxt.sgw_ip_address_s5_s8_up().c_str(), + eps_bearer_ctxt.sgw_teid_s5_s8_up()); #if !MME_UNIT_TEST // skip tunnel deletion for unit tests + int rv = RETURNok; if (module == LOG_SPGW_APP) { - rv = gtp_tunnel_ops->del_tunnel( - enb, enb_ipv6, eps_bearer_ctxt->paa.ipv4_address, ue_ipv6, - eps_bearer_ctxt->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt->enb_teid_S1u, NULL); + if (is_ue_ipv6_pres) { + rv = gtp_tunnel_ops->del_tunnel( + enb, &enb_ipv6, ue_ipv4, &ue_ipv6, + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.enb_teid_s1u(), nullptr); + } else { + rv = gtp_tunnel_ops->del_tunnel( + enb, &enb_ipv6, ue_ipv4, nullptr, + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.enb_teid_s1u(), nullptr); + } } else if (module == LOG_SGW_S8) { - rv = gtpv1u_del_s8_tunnel(enb, enb_ipv6, pgw, pgw_ipv6, - eps_bearer_ctxt->paa.ipv4_address, ue_ipv6, - eps_bearer_ctxt->s_gw_teid_S1u_S12_S4_up, - eps_bearer_ctxt->s_gw_teid_S5_S8_up); + rv = gtpv1u_del_s8_tunnel(enb, &enb_ipv6, pgw, &pgw_ipv6, ue_ipv4, + &ue_ipv6, + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up(), + eps_bearer_ctxt.sgw_teid_s5_s8_up()); } // TODO Need to add handling on failing to delete s1-u tunnel rules from @@ -2310,31 +2560,38 @@ void sgw_process_release_access_bearer_request( OAILOG_ERROR_UE(module, imsi64, "ERROR in deleting TUNNEL " TEID_FMT " (eNB) <-> (SGW) " TEID_FMT "\n", - eps_bearer_ctxt->enb_teid_S1u, - eps_bearer_ctxt->s_gw_teid_S1u_S12_S4_up); + eps_bearer_ctxt.enb_teid_s1u(), + eps_bearer_ctxt.sgw_teid_s1u_s12_s4_up()); } // Paging is performed without packet buffering - rv = gtp_tunnel_ops->add_paging_rule( - sgw_context->imsi, eps_bearer_ctxt->paa.ipv4_address, ue_ipv6); + Imsi_t imsi; + memcpy(imsi.digit, sgw_context->imsi().c_str(), + sgw_context->imsi().size()); + if (is_ue_ipv6_pres) { + rv = gtp_tunnel_ops->add_paging_rule(imsi, ue_ipv4, &ue_ipv6); + } else { + rv = gtp_tunnel_ops->add_paging_rule(imsi, ue_ipv4, nullptr); + } // Convert to string for logging - char* ip_str = inet_ntoa(eps_bearer_ctxt->paa.ipv4_address); + char* ip_str = inet_ntoa(ue_ipv4); if (rv < 0) { OAILOG_ERROR_UE(module, imsi64, "ERROR in setting paging rule for IP Addr: %s\n", ip_str); } - if ((eps_bearer_ctxt->paa.pdn_type == IPv6) || - (eps_bearer_ctxt->paa.pdn_type == IPv4_AND_v6)) { - char ip6_str[INET6_ADDRSTRLEN]; - inet_ntop(AF_INET6, (void*)&eps_bearer_ctxt->paa.ipv6_address, ip6_str, - INET6_ADDRSTRLEN); + if ((eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv6) || + (eps_bearer_ctxt.ue_ip_paa().pdn_type() == IPv4_AND_v6)) { OAILOG_DEBUG(module, "Set the paging rule for IPv6 Addr: %s\n", - ip6_str); + eps_bearer_ctxt.ue_ip_paa().ipv6_addr().c_str()); } else { OAILOG_DEBUG(module, "Set the paging rule for IP Addr: %s\n", ip_str); } #endif - sgw_release_all_enb_related_information(eps_bearer_ctxt); + // release enb's UP teid and IP address + eps_bearer_ctxt.clear_enb_s1u_ip_addr(); + eps_bearer_ctxt.set_enb_teid_s1u(INVALID_TEID); + eps_bearer_map.update_val(eps_bearer_ctxt.eps_bearer_id(), + &eps_bearer_ctxt); } } OAILOG_FUNC_OUT(module); @@ -2343,8 +2600,8 @@ void sgw_process_release_access_bearer_request( // Generates random s11 control plane teid static teid_t sgw_generate_new_s11_cp_teid(void) { OAILOG_FUNC_IN(LOG_SPGW_APP); - s_plus_p_gw_eps_bearer_context_information_t* - s_plus_p_gw_eps_bearer_ctxt_info_p = NULL; + magma::lte::oai::S11BearerContext* s_plus_p_gw_eps_bearer_ctxt_info_p = + nullptr; teid_t teid = INVALID_TEID; // note srand with seed is initialized at main do { @@ -2364,18 +2621,19 @@ void sgw_handle_delete_bearer_cmd( OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, "Received s11_delete_bearer_command for teid" TEID_FMT "\n", s11_delete_bearer_command->teid); - s_plus_p_gw_eps_bearer_context_information_t* spgw_ctxt = + magma::lte::oai::S11BearerContext* spgw_ctxt = sgw_cm_get_spgw_context(s11_delete_bearer_command->teid); if (!spgw_ctxt) { OAILOG_ERROR_UE( LOG_SPGW_APP, imsi64, - "failed to get s_plus_p_gw_eps_bearer_context for teid " TEID_FMT + "failed to get s_plus_pgw_eps bearer context for teid " TEID_FMT " while processing s11_delete_bearer_command\n", s11_delete_bearer_command->teid); OAILOG_FUNC_OUT(TASK_SPGW_APP); } - char* imsi = (char*)spgw_ctxt->sgw_eps_bearer_context_information.imsi.digit; + const char* imsi = reinterpret_cast( + spgw_ctxt->sgw_eps_bearer_context().imsi().c_str()); pcef_delete_dedicated_bearer(imsi, s11_delete_bearer_command->ebi_list); // Send itti_s11_nw_init_deactv_bearer_request_t to MME to delete the bearer/s @@ -2386,3 +2644,64 @@ void sgw_handle_delete_bearer_cmd( OAILOG_FUNC_OUT(TASK_SPGW_APP); } + +void convert_proto_ip_to_standard_ip_fmt(magma::lte::oai::IpTupple* proto_ip, + struct in_addr* ipv4, + struct in6_addr* ipv6, + bool ipv6_enabled) { + inet_pton(AF_INET, proto_ip->ipv4_addr().c_str(), &ipv4->s_addr); + if (ipv6_enabled && + (proto_ip->pdn_type() == IPv6 || proto_ip->pdn_type() == IPv4_AND_v6)) { + inet_pton(AF_INET6, proto_ip->ipv6_addr().c_str(), ipv6); + } +} + +static void get_session_req_data( + spgw_state_t* spgw_state, + const magma::lte::oai::CreateSessionMessage* saved_req, + struct pcef_create_session_data* data) { + data->msisdn_len = saved_req->msisdn().size(); + memcpy(data->msisdn, saved_req->msisdn().c_str(), data->msisdn_len); + data->imeisv_exists = saved_req->mei().size() > 0 ? true : false; + if (data->imeisv_exists) { + memcpy(data->imeisv, saved_req->mei().c_str(), saved_req->mei().size()); + } + + data->uli_exists = saved_req->uli().size() > 0 ? true : false; + if (data->uli_exists) { + memcpy(data->uli, saved_req->uli().c_str(), saved_req->uli().size()); + } + + data->mcc_mnc_len = saved_req->serving_network().mcc().size(); + memset(data->mcc_mnc, 0, 7); + memcpy(data->mcc_mnc, saved_req->serving_network().mcc().c_str(), + saved_req->serving_network().mcc().size()); + + memcpy(&data->mcc_mnc[data->mcc_mnc_len], + saved_req->serving_network().mnc().c_str(), + saved_req->serving_network().mnc().size()); + data->mcc_mnc_len += saved_req->serving_network().mnc().size(); + get_imsi_plmn_from_session_req(saved_req->imsi(), data); + + memcpy(data->charging_characteristics.value, + saved_req->charging_characteristics().c_str(), + saved_req->charging_characteristics().size()); + data->charging_characteristics.length = + saved_req->charging_characteristics().size(); + + memset(data->apn, 0, APN_MAX_LENGTH + 1); + memcpy(data->apn, saved_req->apn().c_str(), saved_req->apn().size()); + data->pdn_type = saved_req->pdn_type(); + + inet_ntop(AF_INET, &spgw_state->sgw_ip_address_S1u_S12_S4_up, data->sgw_ip, + INET_ADDRSTRLEN); + + // QoS Info + data->ambr_dl = saved_req->ambr().br_dl(); + data->ambr_ul = saved_req->ambr().br_ul(); + auto qos = saved_req->bearer_contexts_to_be_created(0).bearer_level_qos(); + data->pl = qos.pl(); + data->pci = qos.pci(); + data->pvi = qos.pvi(); + data->qci = qos.qci(); +} diff --git a/lte/gateway/c/core/oai/tasks/sgw/sgw_handlers.hpp b/lte/gateway/c/core/oai/tasks/sgw/sgw_handlers.hpp index 27f0745997d7..3b1492826f65 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/sgw_handlers.hpp +++ b/lte/gateway/c/core/oai/tasks/sgw/sgw_handlers.hpp @@ -76,7 +76,8 @@ status_code_e sgw_handle_ip_allocation_rsp( const itti_ip_allocation_response_t* ip_allocation_rsp, imsi64_t imsi64); uint32_t spgw_get_new_s1u_teid(spgw_state_t* state); -bool is_enb_ip_address_same(const fteid_t* fte_p, ip_address_t* ip_p); +bool is_enb_ip_address_same(const fteid_t* fte_p, struct in_addr ipv4, + struct in6_addr ipv6); status_code_e sgw_handle_sgi_endpoint_created( spgw_state_t* state, itti_sgi_create_end_point_response_t* const resp_p, imsi64_t imsi64); @@ -86,44 +87,61 @@ status_code_e send_mbr_failure( imsi64_t imsi64); void sgw_populate_mbr_bearer_contexts_removed( const itti_sgi_update_end_point_response_t* const resp_pP, imsi64_t imsi64, - sgw_eps_bearer_context_information_t* sgw_context_p, + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p, itti_s11_modify_bearer_response_t* modify_response_p); void sgw_populate_mbr_bearer_contexts_not_found( log_proto_t module, const itti_sgi_update_end_point_response_t* const resp_pP, itti_s11_modify_bearer_response_t* modify_response_p); + void populate_sgi_end_point_update( uint8_t sgi_rsp_idx, uint8_t idx, const itti_s11_modify_bearer_request_t* const modify_bearer_pP, - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p, + magma::lte::oai::SgwEpsBearerContext* eps_bearer_ctxt_p, itti_sgi_update_end_point_response_t* sgi_update_end_point_resp); -bool does_bearer_context_hold_valid_enb_ip(ip_address_t enb_ip_address_S1u); + +bool does_sgw_bearer_context_hold_valid_enb_ip(ip_address_t enb_ip_address_S1u); +bool does_bearer_context_hold_valid_enb_ip( + magma::lte::oai::IpTupple enb_ip_address_S1u); void sgw_process_release_access_bearer_request( log_proto_t module, imsi64_t imsi64, - sgw_eps_bearer_context_information_t* sgw_context); + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context); void sgw_send_release_access_bearer_response( log_proto_t module, task_id_t origin_task_id, imsi64_t imsi64, gtpv2c_cause_value_t cause, const itti_s11_release_access_bearers_request_t* const release_access_bearers_req_pP, teid_t mme_teid_s11); + status_code_e sgw_build_and_send_s11_create_bearer_request( - sgw_eps_bearer_context_information_t* sgw_eps_bearer_context_information, + magma::lte::oai::SgwEpsBearerContextInfo* + sgw_eps_bearer_context_information, const itti_gx_nw_init_actv_bearer_request_t* const bearer_req_p, pdn_type_t pdn_type, uint32_t sgw_ip_address_S1u_S12_S4_up, struct in6_addr* sgw_ipv6_address_S1u_S12_S4_up, teid_t s1_u_sgw_fteid, log_proto_t module); + status_code_e create_temporary_dedicated_bearer_context( - sgw_eps_bearer_context_information_t* sgw_ctxt_p, + magma::lte::oai::SgwEpsBearerContextInfo* sgw_ctxt_p, const itti_gx_nw_init_actv_bearer_request_t* const bearer_req_p, pdn_type_t pdn_type, uint32_t sgw_ip_address_S1u_S12_S4_up, struct in6_addr* sgw_ipv6_address_S1u_S12_S4_up, teid_t s1_u_sgw_fteid, uint32_t sequence_number, log_proto_t module); -void handle_failed_create_bearer_response( +// TODO(rsarwad): shall be removed while porting sgw_s8 context to protobuf +// github issue: 11191 +void handle_failed_s8_create_bearer_response( sgw_eps_bearer_context_information_t* sgw_context_p, gtpv2c_cause_value_t cause, imsi64_t imsi64, bearer_context_within_create_bearer_response_t* bearer_context, sgw_eps_bearer_ctxt_t* dedicated_bearer_ctxt_p, log_proto_t module); + +void handle_failed_create_bearer_response( + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p, + gtpv2c_cause_value_t cause, imsi64_t imsi64, + bearer_context_within_create_bearer_response_t* bearer_context, + magma::lte::oai::SgwEpsBearerContext* dedicated_bearer_ctxt_p, + log_proto_t module); + status_code_e spgw_build_and_send_s11_deactivate_bearer_req( imsi64_t imsi64, uint8_t no_of_bearers_to_be_deact, ebi_t* ebi_to_be_deactivated, bool delete_default_bearer, @@ -132,7 +150,29 @@ status_code_e spgw_build_and_send_s11_deactivate_bearer_req( void generate_dl_flow(packet_filter_contents_t* packet_filter, in_addr_t ipv4_s_addr, struct in6_addr* ue_ipv6, struct ip_flow_dl* dlflow); - void sgw_handle_delete_bearer_cmd( itti_s11_delete_bearer_command_t* s11_delete_bearer_command, imsi64_t imsi64); + +void convert_proto_ip_to_standard_ip_fmt(magma::lte::oai::IpTupple* proto_ip, + struct in_addr* ipv4, + struct in6_addr* ipv6, + bool ipv6_enabled); +void traffic_flow_template_to_proto( + const traffic_flow_template_t* tft_state, + magma::lte::oai::TrafficFlowTemplate* tft_proto); + +void eps_bearer_qos_to_proto( + const bearer_qos_t* eps_bearer_qos_state, + magma::lte::oai::SgwBearerQos* eps_bearer_qos_proto); + +void port_range_to_proto(const port_range_t* port_range, + magma::lte::oai::PortRange* port_range_proto); + +void sgw_create_session_message_to_proto( + const itti_s11_create_session_request_t* session_request, + magma::lte::oai::CreateSessionMessage* proto); + +void proto_to_packet_filter( + const magma::lte::oai::PacketFilter& packet_filter_proto, + packet_filter_t* packet_filter); diff --git a/lte/gateway/c/core/oai/tasks/sgw/spgw_state.cpp b/lte/gateway/c/core/oai/tasks/sgw/spgw_state.cpp index 28b47e9bf481..7abb54b359e1 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/spgw_state.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw/spgw_state.cpp @@ -86,42 +86,102 @@ void delete_spgw_ue_state(imsi64_t imsi64) { } void spgw_free_s11_bearer_context_information(void** ptr) { - if (ptr) { - s_plus_p_gw_eps_bearer_context_information_t* context_p = - reinterpret_cast(*ptr); + if (!ptr) { + OAILOG_ERROR(LOG_SPGW_APP, "Received null pointer"); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + + if (*ptr) { + magma::lte::oai::S11BearerContext* context_p = + reinterpret_cast(*ptr); if (context_p) { - sgw_free_pdn_connection( - &(context_p->sgw_eps_bearer_context_information.pdn_connection)); - clear_protocol_configuration_options( - &(context_p->sgw_eps_bearer_context_information.saved_message.pco)); - delete_pending_procedures( - &(context_p->sgw_eps_bearer_context_information)); - - free_cpp_wrapper(reinterpret_cast(ptr)); + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + context_p->mutable_sgw_eps_bearer_context(); + if (sgw_context_p) { + sgw_free_pdn_connection(sgw_context_p->mutable_pdn_connection()); + if (sgw_context_p->saved_message().has_pco()) { + if (sgw_context_p->saved_message().pco().pco_protocol_size()) { + sgw_context_p->mutable_saved_message() + ->mutable_pco() + ->clear_pco_protocol(); + } + sgw_context_p->mutable_saved_message()->clear_pco(); + } + if (sgw_context_p->pending_procedures_size()) { + sgw_context_p->clear_pending_procedures(); + } + if (sgw_context_p->has_mme_cp_ip_address_s11()) { + sgw_context_p->clear_mme_cp_ip_address_s11(); + } + } // end of sgw_context_p + context_p->clear_sgw_eps_bearer_context(); + context_p->clear_pgw_eps_bearer_context(); + } // end of s11_bearer_context_p + } // end of ptr + free_cpp_wrapper(ptr); +} + +void free_eps_bearer_context( + magma::lte::oai::SgwEpsBearerContext* bearer_context_p) { + OAILOG_FUNC_IN(LOG_SPGW_APP); + if (!bearer_context_p) { + OAILOG_ERROR(LOG_SPGW_APP, "Received nullptr for bearer context"); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + if (bearer_context_p->has_eps_bearer_qos()) { + if (bearer_context_p->eps_bearer_qos().has_mbr()) { + bearer_context_p->mutable_eps_bearer_qos()->clear_mbr(); + } + if (bearer_context_p->eps_bearer_qos().has_gbr()) { + bearer_context_p->mutable_eps_bearer_qos()->clear_gbr(); + } + bearer_context_p->clear_eps_bearer_qos(); + } + if (bearer_context_p->has_tft()) { + if (bearer_context_p->tft().has_packet_filter_list()) { + bearer_context_p->mutable_tft()->clear_packet_filter_list(); + } + if (bearer_context_p->tft().has_parameters_list()) { + bearer_context_p->mutable_tft()->clear_parameters_list(); } } + if (bearer_context_p->sdf_ids_size()) { + bearer_context_p->clear_sdf_ids(); + } + if (bearer_context_p->has_enb_s1u_ip_addr()) { + bearer_context_p->clear_enb_s1u_ip_addr(); + } + if (bearer_context_p->has_ue_ip_paa()) { + bearer_context_p->clear_ue_ip_paa(); + } } -void sgw_free_pdn_connection(sgw_pdn_connection_t* pdn_connection_p) { +void sgw_free_pdn_connection( + magma::lte::oai::SgwPdnConnection* pdn_connection_p) { if (pdn_connection_p) { - if (pdn_connection_p->apn_in_use) { - free_wrapper((void**)&pdn_connection_p->apn_in_use); - } - - for (auto& ebix : pdn_connection_p->sgw_eps_bearers_array) { - sgw_free_eps_bearer_context(&ebix); + if (pdn_connection_p->eps_bearer_map_size()) { + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = pdn_connection_p->mutable_eps_bearer_map(); + for (auto itr = eps_bearer_map.map->begin(); + itr != eps_bearer_map.map->end(); itr++) { + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt = itr->second; + free_eps_bearer_context(&eps_bearer_ctxt); + } + eps_bearer_map.clear(); } + pdn_connection_p->Clear(); } } -void sgw_free_eps_bearer_context(sgw_eps_bearer_ctxt_t** sgw_eps_bearer_ctxt) { - if (*sgw_eps_bearer_ctxt) { - if ((*sgw_eps_bearer_ctxt)->pgw_cp_ip_port) { - free_wrapper( - reinterpret_cast(&(*sgw_eps_bearer_ctxt)->pgw_cp_ip_port)); - } - free_cpp_wrapper(reinterpret_cast(sgw_eps_bearer_ctxt)); +void sgw_remove_eps_bearer_context( + magma::lte::oai::SgwPdnConnection* pdn_connection_p, uint32_t ebi) { + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = pdn_connection_p->mutable_eps_bearer_map(); + if (eps_bearer_map.get(ebi, &eps_bearer_ctxt) == magma::PROTO_MAP_OK) { + free_eps_bearer_context(&eps_bearer_ctxt); } + eps_bearer_map.remove(ebi); } void sgw_free_ue_context(void** ptr) { diff --git a/lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.cpp b/lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.cpp index a660a73e143f..c9474c5e8138 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.cpp @@ -22,7 +22,9 @@ extern "C" { } #include "lte/gateway/c/core/common/dynamic_memory_check.h" +#include "lte/gateway/c/core/oai/lib/pcef/pcef_handlers.hpp" #include "lte/gateway/c/core/oai/include/sgw_context_manager.hpp" +#include "lte/gateway/c/core/oai/tasks/sgw/sgw_handlers.hpp" using magma::lte::oai::CreateSessionMessage; using magma::lte::oai::GTPV1uData; @@ -59,540 +61,131 @@ void SpgwStateConverter::proto_to_state(const SpgwState& proto, } void SpgwStateConverter::spgw_bearer_context_to_proto( - const s_plus_p_gw_eps_bearer_context_information_t* spgw_bearer_state, + const S11BearerContext* spgw_bearer_state, S11BearerContext* spgw_bearer_proto) { spgw_bearer_proto->Clear(); - - auto* sgw_eps_bearer_proto = - spgw_bearer_proto->mutable_sgw_eps_bearer_context(); - auto* sgw_eps_bearer_state = - &spgw_bearer_state->sgw_eps_bearer_context_information; - - sgw_eps_bearer_proto->set_imsi((char*)sgw_eps_bearer_state->imsi.digit); - sgw_eps_bearer_proto->set_imsi64(sgw_eps_bearer_state->imsi64); - sgw_eps_bearer_proto->set_imsi_unauth_indicator( - sgw_eps_bearer_state->imsi_unauthenticated_indicator); - sgw_eps_bearer_proto->set_msisdn(sgw_eps_bearer_state->msisdn); - ecgi_to_proto(sgw_eps_bearer_state->last_known_cell_Id, - sgw_eps_bearer_proto->mutable_last_known_cell_id()); - - if (sgw_eps_bearer_state->trxn != nullptr) { - sgw_eps_bearer_proto->set_trxn((char*)sgw_eps_bearer_state->trxn); - } - - sgw_eps_bearer_proto->set_mme_teid_s11(sgw_eps_bearer_state->mme_teid_S11); - bstring ip_addr_bstr = - ip_address_to_bstring(&sgw_eps_bearer_state->mme_ip_address_S11); - BSTRING_TO_STRING(ip_addr_bstr, - sgw_eps_bearer_proto->mutable_mme_ip_address_s11()); - bdestroy_wrapper(&ip_addr_bstr); - - sgw_eps_bearer_proto->set_sgw_teid_s11_s4( - sgw_eps_bearer_state->s_gw_teid_S11_S4); - ip_addr_bstr = - ip_address_to_bstring(&sgw_eps_bearer_state->s_gw_ip_address_S11_S4); - BSTRING_TO_STRING(ip_addr_bstr, - sgw_eps_bearer_proto->mutable_sgw_ip_address_s11_s4()); - bdestroy_wrapper(&ip_addr_bstr); - - sgw_pdn_connection_to_proto(&sgw_eps_bearer_state->pdn_connection, - sgw_eps_bearer_proto->mutable_pdn_connection()); - - sgw_create_session_message_to_proto( - &sgw_eps_bearer_state->saved_message, - sgw_eps_bearer_proto->mutable_saved_message()); - sgw_pending_procedures_to_proto(sgw_eps_bearer_state->pending_procedures, - sgw_eps_bearer_proto); - - auto* pgw_eps_bearer_proto = - spgw_bearer_proto->mutable_pgw_eps_bearer_context(); - auto* pgw_eps_bearer_state = - &spgw_bearer_state->pgw_eps_bearer_context_information; - - pgw_eps_bearer_proto->set_imsi((char*)pgw_eps_bearer_state->imsi.digit); - pgw_eps_bearer_proto->set_imsi_unauth_indicator( - pgw_eps_bearer_state->imsi_unauthenticated_indicator); - pgw_eps_bearer_proto->set_msisdn(pgw_eps_bearer_state->msisdn); + spgw_bearer_proto->MergeFrom(*spgw_bearer_state); } void SpgwStateConverter::proto_to_spgw_bearer_context( const S11BearerContext& spgw_bearer_proto, - s_plus_p_gw_eps_bearer_context_information_t* spgw_bearer_state) { - auto* sgw_eps_bearer_context_state = - &spgw_bearer_state->sgw_eps_bearer_context_information; - auto& sgw_eps_bearer_context_proto = - spgw_bearer_proto.sgw_eps_bearer_context(); - - strncpy((char*)&sgw_eps_bearer_context_state->imsi.digit, - sgw_eps_bearer_context_proto.imsi().c_str(), - sgw_eps_bearer_context_proto.imsi().length()); - sgw_eps_bearer_context_state->imsi.length = - sgw_eps_bearer_context_proto.imsi().length(); - - strncpy(sgw_eps_bearer_context_state->msisdn, - sgw_eps_bearer_context_proto.msisdn().c_str(), - sgw_eps_bearer_context_proto.msisdn().length()); - sgw_eps_bearer_context_state->imsi_unauthenticated_indicator = - sgw_eps_bearer_context_proto.imsi_unauth_indicator(); - StateConverter::proto_to_ecgi( - sgw_eps_bearer_context_proto.last_known_cell_id(), - &sgw_eps_bearer_context_state->last_known_cell_Id); - - sgw_eps_bearer_context_state->trxn = - (void*)sgw_eps_bearer_context_proto.trxn().c_str(); - sgw_eps_bearer_context_state->mme_teid_S11 = - sgw_eps_bearer_context_proto.mme_teid_s11(); - bstring ip_addr_bstr = - bfromcstr(sgw_eps_bearer_context_proto.mme_ip_address_s11().c_str()); - bstring_to_ip_address(ip_addr_bstr, - &sgw_eps_bearer_context_state->mme_ip_address_S11); - bdestroy_wrapper(&ip_addr_bstr); - sgw_eps_bearer_context_state->imsi64 = sgw_eps_bearer_context_proto.imsi64(); - - sgw_eps_bearer_context_state->s_gw_teid_S11_S4 = - sgw_eps_bearer_context_proto.sgw_teid_s11_s4(); - ip_addr_bstr = - bfromcstr(sgw_eps_bearer_context_proto.sgw_ip_address_s11_s4().c_str()); - bstring_to_ip_address(ip_addr_bstr, - &sgw_eps_bearer_context_state->s_gw_ip_address_S11_S4); - bdestroy_wrapper(&ip_addr_bstr); - - proto_to_sgw_pdn_connection(sgw_eps_bearer_context_proto.pdn_connection(), - &sgw_eps_bearer_context_state->pdn_connection); - - proto_to_sgw_create_session_message( - sgw_eps_bearer_context_proto.saved_message(), - &sgw_eps_bearer_context_state->saved_message); - proto_to_sgw_pending_procedures( - sgw_eps_bearer_context_proto, - &sgw_eps_bearer_context_state->pending_procedures); - - auto* pgw_eps_bearer_context_state = - &spgw_bearer_state->pgw_eps_bearer_context_information; - auto& pgw_eps_bearer_context_proto = - spgw_bearer_proto.pgw_eps_bearer_context(); - - strncpy((char*)&pgw_eps_bearer_context_state->imsi.digit, - pgw_eps_bearer_context_proto.imsi().c_str(), - pgw_eps_bearer_context_proto.imsi().length()); - pgw_eps_bearer_context_state->imsi.length = - pgw_eps_bearer_context_proto.imsi().length(); - strncpy(pgw_eps_bearer_context_state->msisdn, - pgw_eps_bearer_context_proto.msisdn().c_str(), - pgw_eps_bearer_context_proto.msisdn().length()); - pgw_eps_bearer_context_state->imsi_unauthenticated_indicator = - pgw_eps_bearer_context_proto.imsi_unauth_indicator(); -} - -void SpgwStateConverter::sgw_pdn_connection_to_proto( - const sgw_pdn_connection_t* state_pdn, SgwPdnConnection* proto_pdn) { - proto_pdn->Clear(); - - if (state_pdn->apn_in_use) { - proto_pdn->set_apn_in_use(state_pdn->apn_in_use, - strlen(state_pdn->apn_in_use)); - } - bstring ip_addr_bstr = - ip_address_to_bstring(&state_pdn->p_gw_address_in_use_cp); - BSTRING_TO_STRING(ip_addr_bstr, proto_pdn->mutable_pgw_address_in_use_cp()); - bdestroy_wrapper(&ip_addr_bstr); - - ip_addr_bstr = ip_address_to_bstring(&state_pdn->p_gw_address_in_use_up); - BSTRING_TO_STRING(ip_addr_bstr, proto_pdn->mutable_pgw_address_in_use_up()); - bdestroy_wrapper(&ip_addr_bstr); - - proto_pdn->set_default_bearer(state_pdn->default_bearer); - proto_pdn->set_ue_suspended_for_ps_handover( - state_pdn->ue_suspended_for_ps_handover); - - for (auto& eps_bearer : state_pdn->sgw_eps_bearers_array) { - auto* proto_eps_bearer = proto_pdn->add_eps_bearer_list(); - if (eps_bearer != nullptr) { - sgw_eps_bearer_to_proto(eps_bearer, proto_eps_bearer); - } - } + S11BearerContext* spgw_bearer_state) { + spgw_bearer_state->Clear(); + spgw_bearer_state->MergeFrom(spgw_bearer_proto); } -void SpgwStateConverter::proto_to_sgw_pdn_connection( - const oai::SgwPdnConnection& proto, sgw_pdn_connection_t* state_pdn) { - if ((proto.apn_in_use().length())) { - state_pdn->apn_in_use = - strndup(proto.apn_in_use().c_str(), proto.apn_in_use().length()); - } - state_pdn->default_bearer = proto.default_bearer(); - state_pdn->ue_suspended_for_ps_handover = - proto.ue_suspended_for_ps_handover(); - - bstring ip_addr_bstr = bfromcstr(proto.pgw_address_in_use_cp().c_str()); - bstring_to_ip_address(ip_addr_bstr, &state_pdn->p_gw_address_in_use_cp); - bdestroy_wrapper(&ip_addr_bstr); - - ip_addr_bstr = bfromcstr(proto.pgw_address_in_use_up().c_str()); - bstring_to_ip_address(ip_addr_bstr, &state_pdn->p_gw_address_in_use_up); - bdestroy_wrapper(&ip_addr_bstr); - - for (int i = 0; i < BEARERS_PER_UE; i++) { - if (proto.eps_bearer_list(i).eps_bearer_id()) { - auto* eps_bearer_entry = new sgw_eps_bearer_ctxt_t(); - proto_to_sgw_eps_bearer(proto.eps_bearer_list(i), eps_bearer_entry); - state_pdn->sgw_eps_bearers_array[i] = eps_bearer_entry; - } - } -} - -void SpgwStateConverter::sgw_create_session_message_to_proto( - const itti_s11_create_session_request_t* session_request, - CreateSessionMessage* proto) { - proto->Clear(); - - if (session_request->trxn != nullptr) { - proto->set_trxn((char*)session_request->trxn); - } - - proto->set_teid(session_request->teid); - proto->set_imsi((char*)session_request->imsi.digit); - proto->set_msisdn((char*)session_request->msisdn.digit); - - if (MEI_IMEISV) { - memcpy(proto->mutable_mei(), &session_request->mei.choice.imeisv, - session_request->mei.choice.imeisv.length); - } else if (MEI_IMEI) { - memcpy(proto->mutable_mei(), &session_request->mei.choice.imei, - session_request->mei.choice.imei.length); - } - - if (session_request->uli.present) { - char uli[sizeof(Uli_t)] = ""; - memcpy(uli, &session_request->uli, sizeof(Uli_t)); - proto->set_uli(uli, sizeof(Uli_t)); - } - - const auto cc = session_request->charging_characteristics; - if (cc.length > 0) { - proto->set_charging_characteristics(cc.value, cc.length); - } - - proto->mutable_serving_network()->set_mcc( - (char*)session_request->serving_network.mcc, 3); - proto->mutable_serving_network()->set_mnc( - (char*)session_request->serving_network.mnc, 3); - - proto->set_rat_type(session_request->rat_type); - proto->set_pdn_type(session_request->pdn_type); - proto->mutable_ambr()->set_br_ul(session_request->ambr.br_ul); - proto->mutable_ambr()->set_br_dl(session_request->ambr.br_dl); - - proto->set_apn(session_request->apn, strlen(session_request->apn)); - bstring paa_addr_bstr = paa_to_bstring(&session_request->paa); - BSTRING_TO_STRING(paa_addr_bstr, proto->mutable_paa()); - bdestroy_wrapper(&paa_addr_bstr); - proto->set_peer_ip(session_request->edns_peer_ip.addr_v4.sin_addr.s_addr); - - proto->mutable_pco()->set_ext(session_request->pco.ext); - proto->mutable_pco()->set_spare(session_request->pco.spare); - proto->mutable_pco()->set_configuration_protocol( - session_request->pco.configuration_protocol); - proto->mutable_pco()->set_num_protocol_or_container_id( - session_request->pco.num_protocol_or_container_id); - - if (session_request->sender_fteid_for_cp.ipv4) { - proto->mutable_sender_fteid_for_cp()->set_ipv4_address( - session_request->sender_fteid_for_cp.ipv4_address.s_addr); - } else if (session_request->sender_fteid_for_cp.ipv6) { - memcpy(proto->mutable_sender_fteid_for_cp()->mutable_ipv6_address(), - &session_request->sender_fteid_for_cp.ipv6_address, 16); - } - - proto->mutable_sender_fteid_for_cp()->set_interface_type( - session_request->sender_fteid_for_cp.interface_type); - proto->mutable_sender_fteid_for_cp()->set_teid( - session_request->sender_fteid_for_cp.teid); - - proto->mutable_ue_time_zone()->set_time_zone( - session_request->ue_time_zone.time_zone); - proto->mutable_ue_time_zone()->set_daylight_saving_time( - session_request->ue_time_zone.daylight_saving_time); - - for (int i = 0; i < session_request->pco.num_protocol_or_container_id; i++) { - auto* pco_protocol = &session_request->pco.protocol_or_container_ids[i]; - auto* pco_protocol_proto = proto->mutable_pco()->add_pco_protocol(); - if (pco_protocol->contents) { - pco_protocol_proto->set_id(pco_protocol->id); - pco_protocol_proto->set_length(pco_protocol->length); - BSTRING_TO_STRING(pco_protocol->contents, - pco_protocol_proto->mutable_contents()); - } - } - for (int i = 0; - i < session_request->bearer_contexts_to_be_created.num_bearer_context; - i++) { - auto* bearer = - &session_request->bearer_contexts_to_be_created.bearer_contexts[i]; - auto* bearer_proto = proto->add_bearer_contexts_to_be_created(); - bearer_proto->set_eps_bearer_id(bearer->eps_bearer_id); - traffic_flow_template_to_proto(&bearer->tft, bearer_proto->mutable_tft()); - eps_bearer_qos_to_proto(&bearer->bearer_level_qos, - bearer_proto->mutable_bearer_level_qos()); - } -} - -void SpgwStateConverter::proto_to_sgw_create_session_message( - const oai::CreateSessionMessage& proto, - itti_s11_create_session_request_t* session_request) { - session_request->trxn = (void*)proto.trxn().c_str(); - session_request->teid = proto.teid(); - strncpy((char*)&session_request->imsi.digit, proto.imsi().c_str(), - proto.imsi().length()); - session_request->imsi.length = proto.imsi().length(); - - strncpy((char*)&session_request->msisdn.digit, proto.msisdn().c_str(), - proto.msisdn().length()); - session_request->msisdn.length = proto.msisdn().length(); - - if (MEI_IMEISV) { - memcpy(&session_request->mei.choice.imeisv, &proto.mei(), - proto.mei().length()); - } else if (MEI_IMEI) { - memcpy(&session_request->mei.choice.imei, &proto.mei(), - proto.mei().length()); - } - - if (proto.uli().length() > 0) { - memcpy(&session_request->uli, proto.uli().c_str(), sizeof(Uli_t)); - } - - const auto length = proto.charging_characteristics().length(); - session_request->charging_characteristics.length = length; - if (length > CHARGING_CHARACTERISTICS_LENGTH) { - session_request->charging_characteristics.length = - CHARGING_CHARACTERISTICS_LENGTH; - } - memcpy(&session_request->charging_characteristics.value, - proto.charging_characteristics().c_str(), length); - session_request->charging_characteristics.value[length] = '\0'; - - memcpy(&session_request->serving_network.mcc, - proto.serving_network().mcc().c_str(), 3); - memcpy(&session_request->serving_network.mnc, - proto.serving_network().mnc().c_str(), 3); - - session_request->rat_type = (rat_type_t)proto.rat_type(); - session_request->pdn_type = proto.pdn_type(); - session_request->ambr.br_dl = proto.ambr().br_dl(); - session_request->ambr.br_ul = proto.ambr().br_ul(); - - memcpy(&session_request->apn, proto.apn().c_str(), proto.apn().length()); - bstring paa_bstr = bfromcstr(proto.paa().c_str()); - bstring_to_paa(paa_bstr, &session_request->paa); - bdestroy_wrapper(&paa_bstr); - session_request->edns_peer_ip.addr_v4.sin_addr.s_addr = proto.peer_ip(); - - session_request->pco.ext = proto.pco().ext(); - session_request->pco.spare = proto.pco().spare(); - session_request->pco.configuration_protocol = - proto.pco().configuration_protocol(); - session_request->pco.num_protocol_or_container_id = - proto.pco().num_protocol_or_container_id(); - - if (proto.sender_fteid_for_cp().ipv4_address()) { - session_request->sender_fteid_for_cp.ipv4 = 1; - session_request->sender_fteid_for_cp.ipv4_address.s_addr = - proto.sender_fteid_for_cp().ipv4_address(); - } else if (proto.sender_fteid_for_cp().ipv6_address().length() > 0) { - session_request->sender_fteid_for_cp.ipv6 = 1; - memcpy(&session_request->sender_fteid_for_cp.ipv6_address, - proto.sender_fteid_for_cp().ipv6_address().c_str(), 16); - } - session_request->sender_fteid_for_cp.teid = - proto.sender_fteid_for_cp().teid(); - session_request->sender_fteid_for_cp.interface_type = - (interface_type_t)proto.sender_fteid_for_cp().interface_type(); - - session_request->ue_time_zone.time_zone = proto.ue_time_zone().time_zone(); - session_request->ue_time_zone.daylight_saving_time = - proto.ue_time_zone().daylight_saving_time(); - - for (int i = 0; i < proto.pco().pco_protocol_size(); i++) { - auto* protocol_or_container_id = - &session_request->pco.protocol_or_container_ids[i]; - auto protocol_proto = proto.pco().pco_protocol(i); - protocol_or_container_id->id = protocol_proto.id(); - protocol_or_container_id->length = protocol_proto.length(); - protocol_or_container_id->contents = - bfromcstr(protocol_proto.contents().c_str()); - } - - for (int i = 0; i < proto.bearer_contexts_to_be_created_size(); i++) { - auto* eps_bearer = - &session_request->bearer_contexts_to_be_created.bearer_contexts[i]; - auto eps_bearer_proto = proto.bearer_contexts_to_be_created(i); - eps_bearer->eps_bearer_id = eps_bearer_proto.eps_bearer_id(); - proto_to_traffic_flow_template(eps_bearer_proto.tft(), &eps_bearer->tft); - proto_to_eps_bearer_qos(eps_bearer_proto.bearer_level_qos(), - &eps_bearer->bearer_level_qos); - } -} - -void SpgwStateConverter::sgw_eps_bearer_to_proto( - const sgw_eps_bearer_ctxt_t* eps_bearer, - SgwEpsBearerContext* eps_bearer_proto) { - eps_bearer_proto->Clear(); - - eps_bearer_proto->set_eps_bearer_id(eps_bearer->eps_bearer_id); - - bstring ip_addr_bstr = - ip_address_to_bstring(&eps_bearer->p_gw_address_in_use_up); - BSTRING_TO_STRING(ip_addr_bstr, - eps_bearer_proto->mutable_pgw_address_in_use_up()); - bdestroy_wrapper(&ip_addr_bstr); - eps_bearer_proto->set_pgw_teid_s5_s8_up(eps_bearer->p_gw_teid_S5_S8_up); - - ip_addr_bstr = ip_address_to_bstring(&eps_bearer->s_gw_ip_address_S5_S8_up); - BSTRING_TO_STRING(ip_addr_bstr, - eps_bearer_proto->mutable_sgw_ip_address_s5_s8_up()); - bdestroy_wrapper(&ip_addr_bstr); - eps_bearer_proto->set_sgw_teid_s5_s8_up(eps_bearer->s_gw_teid_S5_S8_up); - - ip_addr_bstr = - ip_address_to_bstring(&eps_bearer->s_gw_ip_address_S1u_S12_S4_up); - if (eps_bearer->s_gw_ip_address_S1u_S12_S4_up.pdn_type == IPv4 || - eps_bearer->s_gw_ip_address_S1u_S12_S4_up.pdn_type == IPv4_AND_v6) { - BSTRING_TO_STRING(ip_addr_bstr, - eps_bearer_proto->mutable_sgw_ip_address_s1u_s12_s4_up()); - } else { - BSTRING_TO_STRING( - ip_addr_bstr, - eps_bearer_proto->mutable_sgw_ipv6_address_s1u_s12_s4_up()); - } - bdestroy_wrapper(&ip_addr_bstr); - eps_bearer_proto->set_sgw_teid_s1u_s12_s4_up( - eps_bearer->s_gw_teid_S1u_S12_S4_up); - - ip_addr_bstr = ip_address_to_bstring(&eps_bearer->enb_ip_address_S1u); - BSTRING_TO_STRING(ip_addr_bstr, - eps_bearer_proto->mutable_enb_ip_address_s1u()); - bdestroy_wrapper(&ip_addr_bstr); - eps_bearer_proto->set_enb_teid_s1u(eps_bearer->enb_teid_S1u); - - ip_addr_bstr = paa_to_bstring(&eps_bearer->paa); - BSTRING_TO_STRING(ip_addr_bstr, eps_bearer_proto->mutable_paa()); - bdestroy_wrapper(&ip_addr_bstr); - - eps_bearer_qos_to_proto(&eps_bearer->eps_bearer_qos, - eps_bearer_proto->mutable_eps_bearer_qos()); - traffic_flow_template_to_proto(&eps_bearer->tft, - eps_bearer_proto->mutable_tft()); - - eps_bearer_proto->set_num_sdf(eps_bearer->num_sdf); +void SpgwStateConverter::port_range_to_proto(const port_range_t* port_range, + oai::PortRange* port_range_proto) { + port_range_proto->Clear(); - for (const auto& sdf_id : eps_bearer->sdf_id) { - eps_bearer_proto->add_sdf_ids(sdf_id); - } + port_range_proto->set_low_limit(port_range->lowlimit); + port_range_proto->set_high_limit(port_range->highlimit); } -void SpgwStateConverter::proto_to_sgw_eps_bearer( - const oai::SgwEpsBearerContext& eps_bearer_proto, - sgw_eps_bearer_ctxt_t* eps_bearer) { - eps_bearer->eps_bearer_id = eps_bearer_proto.eps_bearer_id(); - - bstring ip_addr_bstr = - bfromcstr(eps_bearer_proto.pgw_address_in_use_up().c_str()); - bstring_to_ip_address(ip_addr_bstr, &eps_bearer->p_gw_address_in_use_up); - bdestroy_wrapper(&ip_addr_bstr); - eps_bearer->p_gw_teid_S5_S8_up = eps_bearer_proto.pgw_teid_s5_s8_up(); - - ip_addr_bstr = bfromcstr(eps_bearer_proto.sgw_ip_address_s5_s8_up().c_str()); - bstring_to_ip_address(ip_addr_bstr, &eps_bearer->s_gw_ip_address_S5_S8_up); - bdestroy_wrapper(&ip_addr_bstr); - eps_bearer->s_gw_teid_S5_S8_up = eps_bearer_proto.sgw_teid_s5_s8_up(); - - ip_addr_bstr = - bfromcstr(eps_bearer_proto.sgw_ip_address_s1u_s12_s4_up().c_str()), - bstring_to_ip_address(ip_addr_bstr, - &eps_bearer->s_gw_ip_address_S1u_S12_S4_up); - bdestroy_wrapper(&ip_addr_bstr); - - // if ipv6 addr is present it will overwrite, if not it will skip - ip_addr_bstr = - bfromcstr(eps_bearer_proto.sgw_ipv6_address_s1u_s12_s4_up().c_str()), - bstring_to_ip_address(ip_addr_bstr, - &eps_bearer->s_gw_ip_address_S1u_S12_S4_up); - - bdestroy_wrapper(&ip_addr_bstr); - eps_bearer->s_gw_teid_S1u_S12_S4_up = - eps_bearer_proto.sgw_teid_s1u_s12_s4_up(); - - ip_addr_bstr = bfromcstr(eps_bearer_proto.enb_ip_address_s1u().c_str()); - bstring_to_ip_address(ip_addr_bstr, &eps_bearer->enb_ip_address_S1u); - bdestroy_wrapper(&ip_addr_bstr); - eps_bearer->enb_teid_S1u = eps_bearer_proto.enb_teid_s1u(); - - ip_addr_bstr = bfromcstr(eps_bearer_proto.paa().c_str()); - bstring_to_paa(ip_addr_bstr, &eps_bearer->paa); - bdestroy_wrapper(&ip_addr_bstr); - - proto_to_eps_bearer_qos(eps_bearer_proto.eps_bearer_qos(), - &eps_bearer->eps_bearer_qos); - proto_to_traffic_flow_template(eps_bearer_proto.tft(), &eps_bearer->tft); - - eps_bearer->num_sdf = eps_bearer_proto.num_sdf(); - eps_bearer->update_teids = - true; // optimization purposes only, safe to set as true +void SpgwStateConverter::proto_to_port_range( + const oai::PortRange& port_range_proto, port_range_t* port_range) { + port_range->lowlimit = port_range_proto.low_limit(); + port_range->highlimit = port_range_proto.high_limit(); } -void SpgwStateConverter::traffic_flow_template_to_proto( - const traffic_flow_template_t* tft_state, TrafficFlowTemplate* tft_proto) { - tft_proto->Clear(); - - tft_proto->set_tft_operation_code(tft_state->tftoperationcode); - tft_proto->set_number_of_packet_filters(tft_state->numberofpacketfilters); - tft_proto->set_ebit(tft_state->ebit); +void SpgwStateConverter::proto_to_packet_filter( + const oai::PacketFilter& packet_filter_proto, + packet_filter_t* packet_filter) { + packet_filter->spare = packet_filter_proto.spare(); + packet_filter->direction = packet_filter_proto.direction(); + packet_filter->identifier = packet_filter_proto.identifier(); + packet_filter->eval_precedence = packet_filter_proto.eval_precedence(); + packet_filter->length = packet_filter_proto.length(); - // parameters_list member conversion - tft_proto->mutable_parameters_list()->set_num_parameters( - tft_state->parameterslist.num_parameters); - for (int i = 0; i < tft_state->parameterslist.num_parameters; i++) { - auto* parameter = &tft_state->parameterslist.parameter[i]; - if (parameter->contents) { - auto* param_proto = - tft_proto->mutable_parameters_list()->add_parameters(); - param_proto->set_parameter_identifier(parameter->parameteridentifier); - param_proto->set_length(parameter->length); - BSTRING_TO_STRING(parameter->contents, param_proto->mutable_contents()); + auto* packet_filter_contents = &packet_filter->packetfiltercontents; + for (uint8_t pf_idx = 0; + pf_idx < packet_filter_proto.packet_filter_contents_size(); pf_idx++) { + auto& packet_filter_content_proto = + packet_filter_proto.packet_filter_contents(pf_idx); + switch (packet_filter_content_proto.flags()) { + case TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR: { + if (packet_filter_content_proto.ipv4_remote_addresses_size()) { + packet_filter_contents->flags |= + TRAFFIC_FLOW_TEMPLATE_IPV4_REMOTE_ADDR_FLAG; + uint8_t local_idx = TRAFFIC_FLOW_TEMPLATE_IPV4_ADDR_SIZE - 1; + for (uint8_t idx = 0; idx < TRAFFIC_FLOW_TEMPLATE_IPV4_ADDR_SIZE; + idx++) { + packet_filter_contents->ipv4remoteaddr[local_idx].addr = + packet_filter_content_proto.ipv4_remote_addresses(0).addr() >> + (idx * 8); + packet_filter_contents->ipv4remoteaddr[local_idx].mask = + packet_filter_content_proto.ipv4_remote_addresses(0).mask() >> + (idx * 8); + --local_idx; + } + } + } break; + case TRAFFIC_FLOW_TEMPLATE_IPV6_REMOTE_ADDR: { + if (packet_filter_content_proto.ipv6_remote_addresses_size()) { + packet_filter_contents->flags |= + TRAFFIC_FLOW_TEMPLATE_IPV6_REMOTE_ADDR_FLAG; + uint8_t local_idx = TRAFFIC_FLOW_TEMPLATE_IPV6_ADDR_SIZE - 1; + for (uint8_t idx = 0; idx < TRAFFIC_FLOW_TEMPLATE_IPV6_ADDR_SIZE; + idx++) { + packet_filter_contents->ipv6remoteaddr[local_idx].addr = + packet_filter_content_proto.ipv6_remote_addresses(idx).addr(); + packet_filter_contents->ipv6remoteaddr[local_idx].mask = + packet_filter_content_proto.ipv6_remote_addresses(idx).mask(); + --local_idx; + } + } + } break; + case TRAFFIC_FLOW_TEMPLATE_PROTOCOL_NEXT_HEADER: { + packet_filter_contents->flags |= + TRAFFIC_FLOW_TEMPLATE_PROTOCOL_NEXT_HEADER_FLAG; + packet_filter_contents->protocolidentifier_nextheader = + packet_filter_content_proto.protocol_identifier_nextheader(); + } break; + case TRAFFIC_FLOW_TEMPLATE_SINGLE_LOCAL_PORT: { + packet_filter_contents->flags |= + TRAFFIC_FLOW_TEMPLATE_SINGLE_LOCAL_PORT_FLAG; + packet_filter_contents->singlelocalport = + packet_filter_content_proto.single_local_port(); + } break; + case TRAFFIC_FLOW_TEMPLATE_SINGLE_REMOTE_PORT: { + packet_filter_contents->flags |= + TRAFFIC_FLOW_TEMPLATE_SINGLE_REMOTE_PORT_FLAG; + packet_filter_contents->singleremoteport = + packet_filter_content_proto.single_remote_port(); + } break; + case TRAFFIC_FLOW_TEMPLATE_SECURITY_PARAMETER_INDEX: { + packet_filter_contents->flags |= + TRAFFIC_FLOW_TEMPLATE_SECURITY_PARAMETER_INDEX_FLAG; + packet_filter_contents->securityparameterindex = + packet_filter_content_proto.security_parameter_index(); + } break; + case TRAFFIC_FLOW_TEMPLATE_TYPE_OF_SERVICE_TRAFFIC_CLASS: { + packet_filter_contents->flags |= + TRAFFIC_FLOW_TEMPLATE_TYPE_OF_SERVICE_TRAFFIC_CLASS_FLAG; + packet_filter_contents->typdeofservice_trafficclass.value = + packet_filter_content_proto.type_of_service_traffic_class().value(); + packet_filter_contents->typdeofservice_trafficclass.mask = + packet_filter_content_proto.type_of_service_traffic_class().mask(); + } break; + case TRAFFIC_FLOW_TEMPLATE_FLOW_LABEL: { + packet_filter_contents->flags |= TRAFFIC_FLOW_TEMPLATE_FLOW_LABEL_FLAG; + packet_filter_contents->flowlabel = + packet_filter_content_proto.flow_label(); + } break; + case TRAFFIC_FLOW_TEMPLATE_LOCAL_PORT_RANGE: { + packet_filter_contents->flags |= + TRAFFIC_FLOW_TEMPLATE_LOCAL_PORT_RANGE_FLAG; + proto_to_port_range(packet_filter_content_proto.local_port_range(), + &packet_filter_contents->localportrange); + } break; + case TRAFFIC_FLOW_TEMPLATE_REMOTE_PORT_RANGE: { + packet_filter_contents->flags |= + TRAFFIC_FLOW_TEMPLATE_REMOTE_PORT_RANGE_FLAG; + proto_to_port_range(packet_filter_content_proto.remote_port_range(), + &packet_filter_contents->remoteportrange); + } break; } } - - // traffic_flow_template.packet_filter list member conversions - auto* pft_proto = tft_proto->mutable_packet_filter_list(); - auto pft_state = tft_state->packetfilterlist; - switch (tft_state->tftoperationcode) { - case TRAFFIC_FLOW_TEMPLATE_OPCODE_DELETE_PACKET_FILTERS_FROM_EXISTING_TFT: - for (int i = 0; i < tft_state->numberofpacketfilters; i++) { - pft_proto->add_delete_packet_filter_identifier( - pft_state.deletepacketfilter[i].identifier); - } - break; - case TRAFFIC_FLOW_TEMPLATE_OPCODE_CREATE_NEW_TFT: - for (int i = 0; i < tft_state->numberofpacketfilters; i++) { - packet_filter_to_proto(&pft_state.createnewtft[i], - pft_proto->add_create_new_tft()); - } - break; - case TRAFFIC_FLOW_TEMPLATE_OPCODE_ADD_PACKET_FILTER_TO_EXISTING_TFT: - for (int i = 0; i < tft_state->numberofpacketfilters; i++) { - packet_filter_to_proto(&pft_state.createnewtft[i], - pft_proto->add_add_packet_filter()); - } - break; - case TRAFFIC_FLOW_TEMPLATE_OPCODE_REPLACE_PACKET_FILTERS_IN_EXISTING_TFT: - for (int i = 0; i < tft_state->numberofpacketfilters; i++) { - packet_filter_to_proto(&pft_state.createnewtft[i], - pft_proto->add_replace_packet_filter()); - } - break; - default: - break; - }; } void SpgwStateConverter::proto_to_traffic_flow_template( @@ -649,22 +242,104 @@ void SpgwStateConverter::proto_to_traffic_flow_template( }; } -void SpgwStateConverter::port_range_to_proto(const port_range_t* port_range, - oai::PortRange* port_range_proto) { +void SpgwStateConverter::gtpv1u_data_to_proto(const gtpv1u_data_t* gtp_data, + GTPV1uData* gtp_proto) { + gtp_proto->Clear(); + gtp_proto->set_fd0(gtp_data->fd0); + gtp_proto->set_fd1u(gtp_data->fd1u); +} + +void SpgwStateConverter::proto_to_gtpv1u_data(const oai::GTPV1uData& gtp_proto, + gtpv1u_data_t* gtp_data) { + gtp_data->fd0 = gtp_proto.fd0(); + gtp_data->fd1u = gtp_proto.fd1u(); +} + +void SpgwStateConverter::ue_to_proto(const spgw_ue_context_t* ue_state, + oai::SpgwUeContext* ue_proto) { + if (ue_state && (!LIST_EMPTY(&ue_state->sgw_s11_teid_list))) { + sgw_s11_teid_t* s11_teid_p = nullptr; + LIST_FOREACH(s11_teid_p, &ue_state->sgw_s11_teid_list, entries) { + if (s11_teid_p) { + auto spgw_ctxt = sgw_cm_get_spgw_context(s11_teid_p->sgw_s11_teid); + if (spgw_ctxt) { + spgw_bearer_context_to_proto(spgw_ctxt, + ue_proto->add_s11_bearer_context()); + } + } + } + } +} + +void SpgwStateConverter::proto_to_ue(const oai::SpgwUeContext& ue_proto, + spgw_ue_context_t* ue_context_p) { + OAILOG_FUNC_IN(LOG_SPGW_APP); + map_uint64_spgw_ue_context_t* state_ue_map = nullptr; + state_teid_map_t* state_teid_map = nullptr; + if (ue_proto.s11_bearer_context_size()) { + state_teid_map = get_spgw_teid_state(); + if (!state_teid_map) { + OAILOG_ERROR(LOG_SPGW_APP, "Failed to get state_teid_map \n"); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + + state_ue_map = get_spgw_ue_state(); + if (!state_ue_map) { + OAILOG_ERROR(LOG_SPGW_APP, + "Failed to get state_ue_map from get_spgw_ue_state() \n"); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + + // All s11_bearer_context on this UE context will be of same imsi + imsi64_t imsi64 = + ue_proto.s11_bearer_context(0).sgw_eps_bearer_context().imsi64(); + if (ue_context_p) { + LIST_INIT(&ue_context_p->sgw_s11_teid_list); + state_ue_map->insert(imsi64, ue_context_p); + } else { + OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, + "Failed to allocate memory for UE context \n"); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + } else { + OAILOG_ERROR(LOG_SPGW_APP, + "There are no spgw_context stored to Redis DB \n"); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + for (int idx = 0; idx < ue_proto.s11_bearer_context_size(); idx++) { + oai::S11BearerContext S11BearerContext = ue_proto.s11_bearer_context(idx); + oai::S11BearerContext* spgw_context_p = new oai::S11BearerContext(); + + proto_to_spgw_bearer_context(S11BearerContext, spgw_context_p); + if ((state_teid_map->insert( + spgw_context_p->sgw_eps_bearer_context().sgw_teid_s11_s4(), + spgw_context_p) != magma::PROTO_MAP_OK)) { + OAILOG_ERROR(LOG_SPGW_APP, + "Failed to insert spgw_context_p for teid " TEID_FMT " \n", + spgw_context_p->sgw_eps_bearer_context().sgw_teid_s11_s4()); + OAILOG_FUNC_OUT(LOG_SPGW_APP); + } + spgw_update_teid_in_ue_context( + spgw_context_p->sgw_eps_bearer_context().imsi64(), + spgw_context_p->sgw_eps_bearer_context().sgw_teid_s11_s4()); + } + OAILOG_FUNC_OUT(LOG_SPGW_APP); +} + +} // namespace lte +} // namespace magma + +void port_range_to_proto(const port_range_t* port_range, + magma::lte::oai::PortRange* port_range_proto) { port_range_proto->Clear(); port_range_proto->set_low_limit(port_range->lowlimit); port_range_proto->set_high_limit(port_range->highlimit); } -void SpgwStateConverter::proto_to_port_range( - const oai::PortRange& port_range_proto, port_range_t* port_range) { - port_range->lowlimit = port_range_proto.low_limit(); - port_range->highlimit = port_range_proto.high_limit(); -} - -void SpgwStateConverter::packet_filter_to_proto( - const packet_filter_t* packet_filter, PacketFilter* packet_filter_proto) { +void packet_filter_to_proto( + const packet_filter_t* packet_filter, + magma::lte::oai::PacketFilter* packet_filter_proto) { packet_filter_proto->Clear(); packet_filter_proto->set_spare(packet_filter->spare); @@ -745,8 +420,34 @@ void SpgwStateConverter::packet_filter_to_proto( } } -void SpgwStateConverter::proto_to_packet_filter( - const oai::PacketFilter& packet_filter_proto, +void eps_bearer_qos_to_proto( + const bearer_qos_t* eps_bearer_qos_state, + magma::lte::oai::SgwBearerQos* eps_bearer_qos_proto) { + eps_bearer_qos_proto->Clear(); + + eps_bearer_qos_proto->set_pci(eps_bearer_qos_state->pci); + eps_bearer_qos_proto->set_pl(eps_bearer_qos_state->pl); + eps_bearer_qos_proto->set_pvi(eps_bearer_qos_state->pvi); + eps_bearer_qos_proto->set_qci(eps_bearer_qos_state->qci); + + eps_bearer_qos_proto->mutable_gbr()->set_br_ul( + eps_bearer_qos_state->gbr.br_ul); + eps_bearer_qos_proto->mutable_gbr()->set_br_dl( + eps_bearer_qos_state->gbr.br_dl); + + eps_bearer_qos_proto->mutable_mbr()->set_br_ul( + eps_bearer_qos_state->mbr.br_ul); + eps_bearer_qos_proto->mutable_mbr()->set_br_dl( + eps_bearer_qos_state->mbr.br_dl); +} +void proto_to_port_range(const magma::lte::oai::PortRange& port_range_proto, + port_range_t* port_range) { + port_range->lowlimit = port_range_proto.low_limit(); + port_range->highlimit = port_range_proto.high_limit(); +} + +void proto_to_packet_filter( + const magma::lte::oai::PacketFilter& packet_filter_proto, packet_filter_t* packet_filter) { packet_filter->spare = packet_filter_proto.spare(); packet_filter->direction = packet_filter_proto.direction(); @@ -755,7 +456,7 @@ void SpgwStateConverter::proto_to_packet_filter( packet_filter->length = packet_filter_proto.length(); auto* packet_filter_contents = &packet_filter->packetfiltercontents; - for (uint32_t i = 0; i < packet_filter_proto.packet_filter_contents_size(); + for (int32_t i = 0; i < packet_filter_proto.packet_filter_contents_size(); i++) { auto& packet_filter_content_proto = packet_filter_proto.packet_filter_contents(i); @@ -767,11 +468,9 @@ void SpgwStateConverter::proto_to_packet_filter( int local_idx = TRAFFIC_FLOW_TEMPLATE_IPV4_ADDR_SIZE - 1; for (int i = 0; i < TRAFFIC_FLOW_TEMPLATE_IPV4_ADDR_SIZE; i++) { packet_filter_contents->ipv4remoteaddr[local_idx].addr = - packet_filter_content_proto.ipv4_remote_addresses(0).addr() >> - (i * 8); + packet_filter_content_proto.ipv4_remote_addresses(i).addr(); packet_filter_contents->ipv4remoteaddr[local_idx].mask = - packet_filter_content_proto.ipv4_remote_addresses(0).mask() >> - (i * 8); + packet_filter_content_proto.ipv4_remote_addresses(0).mask(); --local_idx; } } @@ -780,13 +479,11 @@ void SpgwStateConverter::proto_to_packet_filter( if (packet_filter_content_proto.ipv6_remote_addresses_size()) { packet_filter_contents->flags |= TRAFFIC_FLOW_TEMPLATE_IPV6_REMOTE_ADDR_FLAG; - int local_idx = TRAFFIC_FLOW_TEMPLATE_IPV6_ADDR_SIZE - 1; for (int i = 0; i < TRAFFIC_FLOW_TEMPLATE_IPV6_ADDR_SIZE; i++) { - packet_filter_contents->ipv6remoteaddr[local_idx].addr = + packet_filter_contents->ipv6remoteaddr[i].addr = packet_filter_content_proto.ipv6_remote_addresses(i).addr(); - packet_filter_contents->ipv6remoteaddr[local_idx].mask = + packet_filter_contents->ipv6remoteaddr[i].mask = packet_filter_content_proto.ipv6_remote_addresses(i).mask(); - --local_idx; } } } break; @@ -843,195 +540,205 @@ void SpgwStateConverter::proto_to_packet_filter( } } -void SpgwStateConverter::eps_bearer_qos_to_proto( - const bearer_qos_t* eps_bearer_qos_state, - SgwBearerQos* eps_bearer_qos_proto) { - eps_bearer_qos_proto->Clear(); - - eps_bearer_qos_proto->set_pci(eps_bearer_qos_state->pci); - eps_bearer_qos_proto->set_pl(eps_bearer_qos_state->pl); - eps_bearer_qos_proto->set_pvi(eps_bearer_qos_state->pvi); - eps_bearer_qos_proto->set_qci(eps_bearer_qos_state->qci); - - eps_bearer_qos_proto->mutable_gbr()->set_br_ul( - eps_bearer_qos_state->gbr.br_ul); - eps_bearer_qos_proto->mutable_gbr()->set_br_dl( - eps_bearer_qos_state->gbr.br_dl); - - eps_bearer_qos_proto->mutable_mbr()->set_br_ul( - eps_bearer_qos_state->mbr.br_ul); - eps_bearer_qos_proto->mutable_mbr()->set_br_dl( - eps_bearer_qos_state->mbr.br_dl); -} +void traffic_flow_template_to_proto( + const traffic_flow_template_t* tft_state, + magma::lte::oai::TrafficFlowTemplate* tft_proto) { + tft_proto->Clear(); -void SpgwStateConverter::proto_to_eps_bearer_qos( - const SgwBearerQos& eps_bearer_qos_proto, - bearer_qos_t* eps_bearer_qos_state) { - eps_bearer_qos_state->pci = eps_bearer_qos_proto.pci(); - eps_bearer_qos_state->pl = eps_bearer_qos_proto.pl(); - eps_bearer_qos_state->pvi = eps_bearer_qos_proto.pvi(); - eps_bearer_qos_state->qci = eps_bearer_qos_proto.qci(); + tft_proto->set_tft_operation_code(tft_state->tftoperationcode); + tft_proto->set_number_of_packet_filters(tft_state->numberofpacketfilters); + tft_proto->set_ebit(tft_state->ebit); - eps_bearer_qos_state->gbr.br_ul = eps_bearer_qos_proto.gbr().br_ul(); - eps_bearer_qos_state->gbr.br_dl = eps_bearer_qos_proto.gbr().br_dl(); + // parameters_list member conversion + tft_proto->mutable_parameters_list()->set_num_parameters( + tft_state->parameterslist.num_parameters); + for (int idx = 0; idx < tft_state->parameterslist.num_parameters; idx++) { + auto* parameter = &tft_state->parameterslist.parameter[idx]; + if (parameter->contents) { + auto* param_proto = + tft_proto->mutable_parameters_list()->add_parameters(); + param_proto->set_parameter_identifier(parameter->parameteridentifier); + param_proto->set_length(parameter->length); + BSTRING_TO_STRING(parameter->contents, param_proto->mutable_contents()); + } + } - eps_bearer_qos_state->mbr.br_ul = eps_bearer_qos_proto.mbr().br_ul(); - eps_bearer_qos_state->mbr.br_dl = eps_bearer_qos_proto.mbr().br_dl(); + // traffic_flow_template.packet_filter list member conversions + auto* pft_proto = tft_proto->mutable_packet_filter_list(); + auto pft_state = tft_state->packetfilterlist; + switch (tft_state->tftoperationcode) { + case TRAFFIC_FLOW_TEMPLATE_OPCODE_DELETE_PACKET_FILTERS_FROM_EXISTING_TFT: + for (int idx = 0; idx < tft_state->numberofpacketfilters; idx++) { + pft_proto->add_delete_packet_filter_identifier( + pft_state.deletepacketfilter[idx].identifier); + } + break; + case TRAFFIC_FLOW_TEMPLATE_OPCODE_CREATE_NEW_TFT: + for (int idx = 0; idx < tft_state->numberofpacketfilters; idx++) { + packet_filter_to_proto(&pft_state.createnewtft[idx], + pft_proto->add_create_new_tft()); + } + break; + case TRAFFIC_FLOW_TEMPLATE_OPCODE_ADD_PACKET_FILTER_TO_EXISTING_TFT: + for (int idx = 0; idx < tft_state->numberofpacketfilters; idx++) { + packet_filter_to_proto(&pft_state.createnewtft[idx], + pft_proto->add_add_packet_filter()); + } + break; + case TRAFFIC_FLOW_TEMPLATE_OPCODE_REPLACE_PACKET_FILTERS_IN_EXISTING_TFT: + for (int idx = 0; idx < tft_state->numberofpacketfilters; idx++) { + packet_filter_to_proto(&pft_state.createnewtft[idx], + pft_proto->add_replace_packet_filter()); + } + break; + default: + OAILOG_ERROR(LOG_SPGW_APP, "Invalid TFT operation code:%u ", + tft_state->tftoperationcode); + break; + } } -void SpgwStateConverter::gtpv1u_data_to_proto(const gtpv1u_data_t* gtp_data, - GTPV1uData* gtp_proto) { - gtp_proto->Clear(); - gtp_proto->set_fd0(gtp_data->fd0); - gtp_proto->set_fd1u(gtp_data->fd1u); +void convert_serving_network_to_proto( + ServingNetwork_t serving_nw, + magma::lte::oai::ServingNetwork* serving_nw_proto) { + char mcc[3] = {0}; + char mnc[3] = {0}; + uint8_t mnc_len = 0; + + mcc[0] = convert_digit_to_char(serving_nw.mcc[0]); + mcc[1] = convert_digit_to_char(serving_nw.mcc[1]); + mcc[2] = convert_digit_to_char(serving_nw.mcc[2]); + mnc[0] = convert_digit_to_char(serving_nw.mnc[0]); + mnc[1] = convert_digit_to_char(serving_nw.mnc[1]); + if ((serving_nw.mnc[2] & 0xf) != 0xf) { + mnc[2] = convert_digit_to_char(serving_nw.mnc[2]); + mnc_len = 3; + } else { + mnc_len = 2; + } + serving_nw_proto->set_mcc(mcc, 3); + serving_nw_proto->set_mnc(mnc, mnc_len); } -void SpgwStateConverter::proto_to_gtpv1u_data(const oai::GTPV1uData& gtp_proto, - gtpv1u_data_t* gtp_data) { - gtp_data->fd0 = gtp_proto.fd0(); - gtp_data->fd1u = gtp_proto.fd1u(); -} +void sgw_create_session_message_to_proto( + const itti_s11_create_session_request_t* session_request, + magma::lte::oai::CreateSessionMessage* proto) { + proto->Clear(); -void SpgwStateConverter::sgw_pending_procedures_to_proto( - const sgw_eps_bearer_context_information_t::pending_procedures_s* - procedures, - SgwEpsBearerContextInfo* proto) { - if (procedures != nullptr) { - pgw_base_proc_t* base_proc = nullptr; + if (session_request->trxn != nullptr) { + proto->set_trxn(reinterpret_cast(session_request->trxn)); + } - LIST_FOREACH(base_proc, procedures, entries) { - if (base_proc->type == - PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST) { - auto* create_proc = (pgw_ni_cbr_proc_t*)base_proc; - auto* cbr_procedure_proto = proto->add_pending_procedures(); - cbr_procedure_proto->set_teid(create_proc->teid); - cbr_procedure_proto->set_sdf_id(create_proc->sdf_id); - cbr_procedure_proto->set_type(create_proc->proc.type); - sgw_eps_bearer_entry_wrapper_t* b1 = nullptr; - LIST_FOREACH(b1, create_proc->pending_eps_bearers, entries) { - sgw_eps_bearer_to_proto( - b1->sgw_eps_bearer_entry, - cbr_procedure_proto->add_pending_eps_bearers()); - } - } - } + proto->set_teid(session_request->teid); + proto->set_imsi(reinterpret_cast(session_request->imsi.digit)); + char msisdn[MSISDN_LENGTH + 1] = {}; + uint32_t msisdn_len = get_msisdn_from_session_req(session_request, msisdn); + proto->set_msisdn(msisdn); + + char imeisv[IMEISV_DIGITS_MAX + 1] = {}; + if (get_imeisv_from_session_req(session_request, imeisv)) { + convert_imeisv_to_string(imeisv); + proto->set_mei(imeisv, IMEISV_DIGITS_MAX); + OAILOG_DEBUG(LOG_SPGW_APP, "imeisv:%s \n", imeisv); } -} -void SpgwStateConverter::proto_to_sgw_pending_procedures( - const oai::SgwEpsBearerContextInfo& proto, - sgw_eps_bearer_context_information_t::pending_procedures_s** procedures_p) { - *procedures_p = - new sgw_eps_bearer_context_information_t::pending_procedures_s(); - LIST_INIT(*procedures_p); - for (auto& procedure_proto : proto.pending_procedures()) { - if (procedure_proto.type() == - PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST) { - insert_proc_into_sgw_pending_procedures(procedure_proto, *procedures_p); - } + char uli[14] = {}; + bool uli_exists = get_uli_from_session_req(session_request, uli); + if (uli_exists) { + proto->set_uli(uli, 14); } -} -void SpgwStateConverter::insert_proc_into_sgw_pending_procedures( - const oai::PgwCbrProcedure& proto, - sgw_eps_bearer_context_information_t::pending_procedures_s* - pending_procedures) { - pgw_ni_cbr_proc_t* s11_proc_create_bearer = new pgw_ni_cbr_proc_t(); - s11_proc_create_bearer->teid = proto.teid(); - s11_proc_create_bearer->sdf_id = (sdf_id_t)proto.sdf_id(); - pgw_base_proc_t* base_proc = (pgw_base_proc_t*)s11_proc_create_bearer; - base_proc->type = (pgw_base_proc_type_t)proto.type(); - LIST_INSERT_HEAD(pending_procedures, base_proc, entries); + const auto cc = session_request->charging_characteristics; + if (cc.length > 0) { + proto->set_charging_characteristics(cc.value, cc.length); + } - s11_proc_create_bearer->pending_eps_bearers = - new pgw_ni_cbr_proc_s::pending_eps_bearers_s(); - LIST_INIT(s11_proc_create_bearer->pending_eps_bearers); - for (auto& eps_bearer_proto : proto.pending_eps_bearers()) { - sgw_eps_bearer_ctxt_t* eps_bearer = new sgw_eps_bearer_ctxt_t(); + char mcc_mnc[7] = {}; + get_plmn_from_session_req(session_request, mcc_mnc); + convert_serving_network_to_proto(session_request->serving_network, + proto->mutable_serving_network()); - proto_to_sgw_eps_bearer(eps_bearer_proto, eps_bearer); + proto->set_rat_type(session_request->rat_type); + proto->set_pdn_type(session_request->pdn_type); + proto->mutable_ambr()->set_br_ul(session_request->ambr.br_ul); + proto->mutable_ambr()->set_br_dl(session_request->ambr.br_dl); - sgw_eps_bearer_entry_wrapper_t* sgw_eps_bearer_entry_wrapper = - new sgw_eps_bearer_entry_wrapper_t(); - sgw_eps_bearer_entry_wrapper->sgw_eps_bearer_entry = eps_bearer; - LIST_INSERT_HEAD((s11_proc_create_bearer->pending_eps_bearers), - sgw_eps_bearer_entry_wrapper, entries); + proto->set_apn(session_request->apn, strlen(session_request->apn)); + proto->mutable_ue_ip_paa()->set_pdn_type(session_request->paa.pdn_type); + + if (session_request->paa.pdn_type == IPv4) { + char ip_str[INET_ADDRSTRLEN]; + inet_ntop(AF_INET, &(session_request->paa.ipv4_address.s_addr), ip_str, + INET_ADDRSTRLEN); + proto->mutable_ue_ip_paa()->set_ipv4_addr(ip_str); + } else if (session_request->paa.pdn_type == IPv6) { + char ip6_str[INET6_ADDRSTRLEN]; + inet_ntop(AF_INET6, &(session_request->paa.ipv6_address), ip6_str, + INET6_ADDRSTRLEN); + proto->mutable_ue_ip_paa()->set_ipv6_addr(ip6_str); + proto->mutable_ue_ip_paa()->set_ipv6_prefix_length( + session_request->paa.ipv6_prefix_length); + proto->mutable_ue_ip_paa()->set_vlan(session_request->paa.vlan); + } else if (session_request->paa.pdn_type == IPv4_AND_v6) { + char ip4_str[INET_ADDRSTRLEN] = {}; + inet_ntop(AF_INET, &(session_request->paa.ipv4_address.s_addr), ip4_str, + INET_ADDRSTRLEN); + char ip6_str[INET6_ADDRSTRLEN] = {}; + inet_ntop(AF_INET6, &(session_request->paa.ipv6_address), ip6_str, + INET6_ADDRSTRLEN); + proto->mutable_ue_ip_paa()->set_ipv4_addr(ip4_str); + proto->mutable_ue_ip_paa()->set_ipv6_addr(ip6_str); + proto->mutable_ue_ip_paa()->set_ipv6_prefix_length( + session_request->paa.ipv6_prefix_length); + proto->mutable_ue_ip_paa()->set_vlan(session_request->paa.vlan); } -} -void SpgwStateConverter::ue_to_proto(const spgw_ue_context_t* ue_state, - oai::SpgwUeContext* ue_proto) { - if (ue_state && (!LIST_EMPTY(&ue_state->sgw_s11_teid_list))) { - sgw_s11_teid_t* s11_teid_p = nullptr; - LIST_FOREACH(s11_teid_p, &ue_state->sgw_s11_teid_list, entries) { - if (s11_teid_p) { - auto spgw_ctxt = sgw_cm_get_spgw_context(s11_teid_p->sgw_s11_teid); - if (spgw_ctxt) { - spgw_bearer_context_to_proto(spgw_ctxt, - ue_proto->add_s11_bearer_context()); - } - } - } + proto->set_peer_ip(session_request->edns_peer_ip.addr_v4.sin_addr.s_addr); + + proto->mutable_pco()->set_ext(session_request->pco.ext); + proto->mutable_pco()->set_spare(session_request->pco.spare); + proto->mutable_pco()->set_configuration_protocol( + session_request->pco.configuration_protocol); + proto->mutable_pco()->set_num_protocol_or_container_id( + session_request->pco.num_protocol_or_container_id); + + if (session_request->sender_fteid_for_cp.ipv4) { + proto->mutable_sender_fteid_for_cp()->set_ipv4_address( + session_request->sender_fteid_for_cp.ipv4_address.s_addr); + } else if (session_request->sender_fteid_for_cp.ipv6) { + memcpy(proto->mutable_sender_fteid_for_cp()->mutable_ipv6_address(), + &session_request->sender_fteid_for_cp.ipv6_address, 16); } -} -void SpgwStateConverter::proto_to_ue(const oai::SpgwUeContext& ue_proto, - spgw_ue_context_t* ue_context_p) { - OAILOG_FUNC_IN(LOG_SPGW_APP); - map_uint64_spgw_ue_context_t* state_ue_map = nullptr; - state_teid_map_t* state_teid_map = nullptr; - if (ue_proto.s11_bearer_context_size()) { - state_teid_map = get_spgw_teid_state(); - if (!state_teid_map) { - OAILOG_ERROR(LOG_SPGW_APP, "Failed to get state_teid_map \n"); - OAILOG_FUNC_OUT(LOG_SPGW_APP); - } + proto->mutable_sender_fteid_for_cp()->set_interface_type( + session_request->sender_fteid_for_cp.interface_type); + proto->mutable_sender_fteid_for_cp()->set_teid( + session_request->sender_fteid_for_cp.teid); - state_ue_map = get_spgw_ue_state(); - if (!state_ue_map) { - OAILOG_ERROR(LOG_SPGW_APP, - "Failed to get state_ue_map from get_spgw_ue_state() \n"); - OAILOG_FUNC_OUT(LOG_SPGW_APP); - } + proto->mutable_ue_time_zone()->set_time_zone( + session_request->ue_time_zone.time_zone); + proto->mutable_ue_time_zone()->set_daylight_saving_time( + session_request->ue_time_zone.daylight_saving_time); - // All s11_bearer_context on this UE context will be of same imsi - imsi64_t imsi64 = - ue_proto.s11_bearer_context(0).sgw_eps_bearer_context().imsi64(); - if (ue_context_p) { - LIST_INIT(&ue_context_p->sgw_s11_teid_list); - state_ue_map->insert(imsi64, ue_context_p); - } else { - OAILOG_ERROR_UE(LOG_SPGW_APP, imsi64, - "Failed to allocate memory for UE context \n"); - OAILOG_FUNC_OUT(LOG_SPGW_APP); + for (int i = 0; i < session_request->pco.num_protocol_or_container_id; i++) { + auto* pco_protocol = &session_request->pco.protocol_or_container_ids[i]; + auto* pco_protocol_proto = proto->mutable_pco()->add_pco_protocol(); + if (pco_protocol->contents) { + pco_protocol_proto->set_id(pco_protocol->id); + pco_protocol_proto->set_length(pco_protocol->length); + BSTRING_TO_STRING(pco_protocol->contents, + pco_protocol_proto->mutable_contents()); } - } else { - OAILOG_ERROR(LOG_SPGW_APP, - "There are no spgw_context stored to Redis DB \n"); - OAILOG_FUNC_OUT(LOG_SPGW_APP); } - for (int idx = 0; idx < ue_proto.s11_bearer_context_size(); idx++) { - oai::S11BearerContext S11BearerContext = ue_proto.s11_bearer_context(idx); - s_plus_p_gw_eps_bearer_context_information_t* spgw_context_p = - new s_plus_p_gw_eps_bearer_context_information_t(); - - proto_to_spgw_bearer_context(S11BearerContext, spgw_context_p); - if ((state_teid_map->insert( - spgw_context_p->sgw_eps_bearer_context_information - .s_gw_teid_S11_S4, - spgw_context_p) != magma::PROTO_MAP_OK)) { - OAILOG_ERROR( - LOG_SPGW_APP, - "Failed to insert spgw_context_p for teid " TEID_FMT " \n", - spgw_context_p->sgw_eps_bearer_context_information.s_gw_teid_S11_S4); - OAILOG_FUNC_OUT(LOG_SPGW_APP); - } - spgw_update_teid_in_ue_context( - spgw_context_p->sgw_eps_bearer_context_information.imsi64, - spgw_context_p->sgw_eps_bearer_context_information.s_gw_teid_S11_S4); + for (int i = 0; + i < session_request->bearer_contexts_to_be_created.num_bearer_context; + i++) { + auto* bearer = + &session_request->bearer_contexts_to_be_created.bearer_contexts[i]; + auto* bearer_proto = proto->add_bearer_contexts_to_be_created(); + bearer_proto->set_eps_bearer_id(bearer->eps_bearer_id); + traffic_flow_template_to_proto(&bearer->tft, bearer_proto->mutable_tft()); + eps_bearer_qos_to_proto(&bearer->bearer_level_qos, + bearer_proto->mutable_bearer_level_qos()); } - OAILOG_FUNC_OUT(LOG_SPGW_APP); } - -} // namespace lte -} // namespace magma diff --git a/lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.hpp b/lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.hpp index 37b67d631450..cd482a27959c 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.hpp +++ b/lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.hpp @@ -97,7 +97,7 @@ class SpgwStateConverter : StateConverter { * @param spgw_bearer_proto */ static void spgw_bearer_context_to_proto( - const s_plus_p_gw_eps_bearer_context_information_t* spgw_bearer_state, + const oai::S11BearerContext* spgw_bearer_state, oai::S11BearerContext* spgw_bearer_proto); /** @@ -107,7 +107,7 @@ class SpgwStateConverter : StateConverter { */ static void proto_to_spgw_bearer_context( const oai::S11BearerContext& spgw_bearer_proto, - s_plus_p_gw_eps_bearer_context_information_t* spgw_bearer_state); + oai::S11BearerContext* spgw_bearer_state); /** * Converts sgw eps bearer struct to proto, memory is owned by the caller diff --git a/lte/gateway/c/core/oai/tasks/sgw/spgw_state_manager.cpp b/lte/gateway/c/core/oai/tasks/sgw/spgw_state_manager.cpp index 5092e9314fae..65ccd1516a14 100644 --- a/lte/gateway/c/core/oai/tasks/sgw/spgw_state_manager.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw/spgw_state_manager.cpp @@ -49,8 +49,8 @@ void SpgwStateManager::create_state() { // Allocating spgw_state_p state_cache_p = (spgw_state_t*)calloc(1, sizeof(spgw_state_t)); - state_teid_map.map = new google::protobuf::Map< - uint32_t, struct s_plus_p_gw_eps_bearer_context_information_s*>(); + state_teid_map.map = + new google::protobuf::Map(); state_teid_map.set_name(S11_BEARER_CONTEXT_INFO_HT_NAME); state_teid_map.bind_callback(spgw_free_s11_bearer_context_information); diff --git a/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_handlers.cpp b/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_handlers.cpp index af176577fdc7..7767316709b4 100644 --- a/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_handlers.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_handlers.cpp @@ -79,6 +79,40 @@ static sgw_eps_bearer_context_information_t* update_sgw_context_to_s11_teid_map( sgw_state_t* sgw_state, s8_create_session_response_t* session_rsp_p, imsi64_t imsi64); +// TODO(rsarwad): shall be removed while porting sgw_s8 context to protobuf +// github issue: 11191 + +static void populate_s8_sgi_end_point_update( + uint8_t sgi_rsp_idx, uint8_t idx, + const itti_s11_modify_bearer_request_t* const modify_bearer_pP, + sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p, + itti_sgi_update_end_point_response_t* sgi_update_end_point_resp); + +static void sgw_s8_process_release_access_bearer_request( + log_proto_t module, imsi64_t imsi64, + sgw_eps_bearer_context_information_t* sgw_context); + +static void sgw_s8_release_all_enb_related_information( + sgw_eps_bearer_ctxt_t* const eps_bearer_ctxt); + +status_code_e sgw_build_and_send_s11_create_bearer_request( + sgw_eps_bearer_context_information_t* sgw_eps_bearer_context_information, + const itti_gx_nw_init_actv_bearer_request_t* const bearer_req_p, + pdn_type_t pdn_type, uint32_t sgw_ip_address_S1u_S12_S4_up, + struct in6_addr* sgw_ipv6_address_S1u_S12_S4_up, teid_t s1_u_sgw_fteid, + log_proto_t module); + +void sgw_s8_populate_mbr_bearer_contexts_removed( + const itti_sgi_update_end_point_response_t* const resp_pP, imsi64_t imsi64, + sgw_eps_bearer_context_information_t* sgw_context_p, + itti_s11_modify_bearer_response_t* modify_response_p); + +sgw_eps_bearer_ctxt_t* sgw_cm_insert_eps_bearer_ctxt_in_collection( + sgw_pdn_connection_t* const sgw_pdn_connection, + sgw_eps_bearer_ctxt_t* const sgw_eps_bearer_ctxt); + +bool is_sgw_enb_ip_address_same(const fteid_t* fte_p, ip_address_t* ip_p); + void sgw_remove_sgw_bearer_context_information(sgw_state_t* sgw_state, teid_t teid, imsi64_t imsi64) { OAILOG_FUNC_IN(LOG_SGW_S8); @@ -318,7 +352,8 @@ status_code_e sgw_s8_handle_s11_create_session_request( send_s8_create_session_request(temporary_create_session_procedure_id, session_req_pP, imsi64); - sgw_display_s11_bearer_context_information(LOG_SGW_S8, new_sgw_eps_context); + sgw_s8_display_s11_bearer_context_information(LOG_SGW_S8, + new_sgw_eps_context); OAILOG_FUNC_RETURN(LOG_SGW_S8, RETURNok); } @@ -327,7 +362,7 @@ int sgw_update_bearer_context_information_on_csrsp( const s8_create_session_response_t* const session_rsp_p, sgw_state_t* sgw_state) { OAILOG_FUNC_IN(LOG_SGW_S8); - sgw_eps_bearer_ctxt_t* default_bearer_ctx_p = sgw_cm_get_eps_bearer_entry( + sgw_eps_bearer_ctxt_t* default_bearer_ctx_p = sgw_s8_cm_get_eps_bearer_entry( &sgw_context_p->pdn_connection, session_rsp_p->eps_bearer_id); if (!default_bearer_ctx_p) { OAILOG_ERROR_UE( @@ -398,8 +433,9 @@ static int sgw_s8_send_create_session_response( spgw_config.sgw_config.ipv4.S11.s_addr; if (session_rsp_p->cause == REQUEST_ACCEPTED) { - sgw_eps_bearer_ctxt_t* default_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &sgw_context_p->pdn_connection, session_rsp_p->eps_bearer_id); + sgw_eps_bearer_ctxt_t* default_bearer_ctxt_p = + sgw_s8_cm_get_eps_bearer_entry(&sgw_context_p->pdn_connection, + session_rsp_p->eps_bearer_id); if (!default_bearer_ctxt_p) { OAILOG_ERROR_UE( LOG_SGW_S8, sgw_context_p->imsi64, @@ -591,9 +627,9 @@ static void insert_sgw_cp_and_up_teid_to_directoryd(sgw_state_t* sgw_state, sizeof(teidString) - strlen(teidString), "%u%c", teidlist[idx], separator); } - const char* ptr = "sgw_c_teid"; + std::string ptr = "sgw_c_teid"; if (teid_type == UP_TEID) { - ptr = "sgw_u_teid"; + ptr.assign("sgw_u_teid"); } directoryd_update_record_field(imsi_str, ptr, teidString); OAILOG_DEBUG_UE( @@ -646,8 +682,8 @@ void sgw_s8_handle_modify_bearer_request( idx++) { bearer_context_to_be_modified_t mbr_bearer_ctxt_p = modify_bearer_pP->bearer_contexts_to_be_modified.bearer_contexts[idx]; - bearer_ctx_p = sgw_cm_get_eps_bearer_entry(&sgw_context_p->pdn_connection, - mbr_bearer_ctxt_p.eps_bearer_id); + bearer_ctx_p = sgw_s8_cm_get_eps_bearer_entry( + &sgw_context_p->pdn_connection, mbr_bearer_ctxt_p.eps_bearer_id); if (!bearer_ctx_p) { OAILOG_ERROR_UE( LOG_SGW_S8, imsi64, @@ -674,10 +710,11 @@ void sgw_s8_handle_modify_bearer_request( #if !MME_UNIT_TEST // Send end marker to eNB and then delete the tunnel if enb_ip is // different - if (does_bearer_context_hold_valid_enb_ip( + if (does_sgw_bearer_context_hold_valid_enb_ip( bearer_ctx_p->enb_ip_address_S1u) && - is_enb_ip_address_same(&mbr_bearer_ctxt_p.s1_eNB_fteid, - &bearer_ctx_p->enb_ip_address_S1u) == false) { + is_sgw_enb_ip_address_same(&mbr_bearer_ctxt_p.s1_eNB_fteid, + &bearer_ctx_p->enb_ip_address_S1u) == + false) { struct in_addr ue_ipv4 = bearer_ctx_p->paa.ipv4_address; struct in6_addr* ue_ipv6 = NULL; if ((bearer_ctx_p->paa.pdn_type == IPv6) || @@ -697,8 +734,9 @@ void sgw_s8_handle_modify_bearer_request( bearer_ctx_p->s_gw_teid_S5_S8_up); } #endif - populate_sgi_end_point_update(sgi_rsp_idx, idx, modify_bearer_pP, - bearer_ctx_p, &sgi_update_end_point_resp); + populate_s8_sgi_end_point_update(sgi_rsp_idx, idx, modify_bearer_pP, + bearer_ctx_p, + &sgi_update_end_point_resp); sgi_rsp_idx++; } } // for loop @@ -707,7 +745,7 @@ void sgw_s8_handle_modify_bearer_request( for (idx = 0; idx < modify_bearer_pP->bearer_contexts_to_be_removed.num_bearer_context; idx++) { - bearer_ctx_p = sgw_cm_get_eps_bearer_entry( + bearer_ctx_p = sgw_s8_cm_get_eps_bearer_entry( &sgw_context_p->pdn_connection, modify_bearer_pP->bearer_contexts_to_be_removed.bearer_contexts[idx] .eps_bearer_id); @@ -752,8 +790,8 @@ static void sgw_send_modify_bearer_response( sgw_s8_populate_mbr_bearer_contexts_modified(resp_pP, imsi64, sgw_context_p, modify_response_p); - sgw_populate_mbr_bearer_contexts_removed(resp_pP, imsi64, sgw_context_p, - modify_response_p); + sgw_s8_populate_mbr_bearer_contexts_removed(resp_pP, imsi64, sgw_context_p, + modify_response_p); sgw_populate_mbr_bearer_contexts_not_found(LOG_SGW_S8, resp_pP, modify_response_p); send_msg_to_task(&sgw_s8_task_zmq_ctx, TASK_MME_APP, message_p); @@ -770,7 +808,7 @@ static void sgw_s8_populate_mbr_bearer_contexts_modified( sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = NULL; for (uint8_t idx = 0; idx < resp_pP->num_bearers_modified; idx++) { - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( + eps_bearer_ctxt_p = sgw_s8_cm_get_eps_bearer_entry( &sgw_context_p->pdn_connection, resp_pP->bearer_contexts_to_be_modified[idx].eps_bearer_id); @@ -1001,7 +1039,7 @@ static void delete_userplane_tunnels( for (int ebix = 0; ebix < BEARERS_PER_UE; ebix++) { ebi_t ebi = INDEX_TO_EBI(ebix); bearer_ctxt_p = - sgw_cm_get_eps_bearer_entry(&sgw_context_p->pdn_connection, ebi); + sgw_s8_cm_get_eps_bearer_entry(&sgw_context_p->pdn_connection, ebi); if (bearer_ctxt_p) { enb.s_addr = @@ -1218,8 +1256,8 @@ void sgw_s8_handle_release_access_bearers_request( sgw_eps_bearer_context_information_t* sgw_session_ctxt_p = sgw_get_sgw_eps_bearer_context(s11_teid_p->sgw_s11_teid); if (sgw_session_ctxt_p) { - sgw_process_release_access_bearer_request(LOG_SGW_S8, imsi64, - sgw_session_ctxt_p); + sgw_s8_process_release_access_bearer_request(LOG_SGW_S8, imsi64, + sgw_session_ctxt_p); cause = REQUEST_ACCEPTED; } } @@ -1318,8 +1356,8 @@ imsi64_t sgw_s8_handle_create_bearer_request( s8_bearer_context_t bc_cbreq = cb_req->bearer_context[bearer_idx]; sgw_eps_bearer_ctxt_t* bearer_ctxt_p = NULL; - bearer_ctxt_p = sgw_cm_get_eps_bearer_entry(&sgw_context_p->pdn_connection, - cb_req->linked_eps_bearer_id); + bearer_ctxt_p = sgw_s8_cm_get_eps_bearer_entry(&sgw_context_p->pdn_connection, + cb_req->linked_eps_bearer_id); if (bearer_ctxt_p == NULL) { OAILOG_ERROR_UE(LOG_SGW_S8, sgw_context_p->imsi64, "Failed to retrieve bearer ctxt\n"); @@ -1334,7 +1372,7 @@ imsi64_t sgw_s8_handle_create_bearer_request( sizeof(traffic_flow_template_t)); memcpy(&itti_bearer_req.eps_bearer_qos, &bc_cbreq.qos, sizeof(bearer_qos_t)); teid_t s1_u_sgw_fteid = sgw_get_new_s1u_teid(sgw_state); - int rc = create_temporary_dedicated_bearer_context( + int rc = create_temporary_s8_dedicated_bearer_context( sgw_context_p, &itti_bearer_req, bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.pdn_type, sgw_state->sgw_ip_address_S1u_S12_S4_up.s_addr, @@ -1384,9 +1422,9 @@ void sgw_s8_proc_s11_create_bearer_rsp( itti_s11_nw_init_actv_bearer_rsp_t* s11_actv_bearer_rsp, imsi64_t imsi64, sgw_state_t* sgw_state) { OAILOG_FUNC_IN(LOG_SGW_S8); - struct sgw_eps_bearer_entry_wrapper_s* sgw_eps_bearer_entry_p = NULL; - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = NULL; - pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = NULL; + struct sgw_eps_bearer_entry_wrapper_s* sgw_eps_bearer_entry_p = nullptr; + sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = nullptr; + pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = nullptr; pgw_ni_cbr_proc = pgw_get_procedure_create_bearer(sgw_context_p); if (!pgw_ni_cbr_proc) { @@ -1396,9 +1434,9 @@ void sgw_s8_proc_s11_create_bearer_rsp( "so did not create new EPS bearer entry for EBI %u for " "sgw_s11_teid " TEID_FMT "\n", bc_cbrsp->eps_bearer_id, s11_actv_bearer_rsp->sgw_s11_teid); - handle_failed_create_bearer_response(sgw_context_p, - s11_actv_bearer_rsp->cause.cause_value, - imsi64, bc_cbrsp, NULL, LOG_SGW_S8); + handle_failed_s8_create_bearer_response( + sgw_context_p, s11_actv_bearer_rsp->cause.cause_value, imsi64, bc_cbrsp, + nullptr, LOG_SGW_S8); OAILOG_FUNC_OUT(LOG_SGW_S8); } @@ -1417,7 +1455,7 @@ void sgw_s8_proc_s11_create_bearer_rsp( sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_entry_p = sgw_cm_insert_eps_bearer_ctxt_in_collection( &sgw_context_p->pdn_connection, eps_bearer_ctxt_p); - if (eps_bearer_ctxt_entry_p == NULL) { + if (eps_bearer_ctxt_entry_p == nullptr) { OAILOG_ERROR_UE( LOG_SGW_S8, imsi64, "Failed to create new EPS bearer entry for bearer_id :%u \n", @@ -1502,7 +1540,7 @@ void sgw_s8_handle_s11_create_bearer_response( "Did not create new EPS bearer entry as " "UE rejected the request for EBI %u for sgw_s11_teid " TEID_FMT "\n", bc_cbrsp.eps_bearer_id, s11_actv_bearer_rsp->sgw_s11_teid); - handle_failed_create_bearer_response( + handle_failed_s8_create_bearer_response( sgw_context_p, s11_actv_bearer_rsp->cause.cause_value, imsi64, &bc_cbrsp, &dedicated_bearer_ctxt, LOG_SGW_S8); sgw_s8_send_failed_create_bearer_response( @@ -1522,7 +1560,7 @@ void sgw_s8_handle_s11_create_bearer_response( idx < s11_actv_bearer_rsp->bearer_contexts.num_bearer_context; idx++) { bearer_context_within_create_bearer_response_t* bc_cbresp_msg = &s11_actv_bearer_rsp->bearer_contexts.bearer_contexts[idx]; - dedicated_bearer_ctx_p = sgw_cm_get_eps_bearer_entry( + dedicated_bearer_ctx_p = sgw_s8_cm_get_eps_bearer_entry( &sgw_context_p->pdn_connection, bc_cbresp_msg->eps_bearer_id); if (!dedicated_bearer_ctx_p) { OAILOG_ERROR_UE(LOG_SGW_S8, sgw_context_p->imsi64, @@ -1604,7 +1642,7 @@ int sgw_s8_handle_delete_bearer_request( } // Check if the received EBI is valid for (uint8_t idx = 0; idx < db_req->num_eps_bearer_id; idx++) { - sgw_eps_bearer_ctxt_t* bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( + sgw_eps_bearer_ctxt_t* bearer_ctxt_p = sgw_s8_cm_get_eps_bearer_entry( &sgw_context_p->pdn_connection, db_req->eps_bearer_id[idx]); if (bearer_ctxt_p) { bearer_ctxt_p->sgw_sequence_number = db_req->sequence_number; @@ -1689,7 +1727,7 @@ status_code_e sgw_s8_handle_s11_delete_bearer_response( OAILOG_ERROR_UE(LOG_SGW_S8, imsi64, "LBI received from MME is NULL\n"); OAILOG_FUNC_RETURN(LOG_SGW_S8, RETURNerror); } - eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( + eps_bearer_ctxt_p = sgw_s8_cm_get_eps_bearer_entry( &sgw_context_p->pdn_connection, *(s11_delete_bearer_response_p->lbi)); if (!eps_bearer_ctxt_p) { OAILOG_ERROR_UE(LOG_SGW_S8, imsi64, @@ -1719,7 +1757,7 @@ status_code_e sgw_s8_handle_s11_delete_bearer_response( ebi = s11_delete_bearer_response_p->bearer_contexts.bearer_contexts[i] .eps_bearer_id; eps_bearer_ctxt_p = - sgw_cm_get_eps_bearer_entry(&sgw_context_p->pdn_connection, ebi); + sgw_s8_cm_get_eps_bearer_entry(&sgw_context_p->pdn_connection, ebi); if (eps_bearer_ctxt_p) { OAILOG_INFO_UE(LOG_SPGW_APP, imsi64, "Removed bearer context for (ebi = %u)\n", ebi); @@ -1773,7 +1811,7 @@ status_code_e sgw_s8_handle_s11_delete_bearer_response( memcpy(pgw_cp_ip_port, eps_bearer_ctxt_p->pgw_cp_ip_port, pgw_ip_port_len); sequence_number = eps_bearer_ctxt_p->sgw_sequence_number; - sgw_free_eps_bearer_context(&eps_bearer_ctxt_p); + sgw_s8_free_eps_bearer_context(&eps_bearer_ctxt_p); sgw_context_p->pdn_connection.sgw_eps_bearers_array[EBI_TO_INDEX(ebi)] = NULL; insert_sgw_cp_and_up_teid_to_directoryd(sgw_state, imsi64, UP_TEID); @@ -1856,3 +1894,374 @@ sgw_eps_bearer_context_information_t* update_sgw_context_to_s11_teid_map( session_rsp_p->context_teid); OAILOG_FUNC_RETURN(LOG_SGW_S8, sgw_context_p); } + +//------------------------------------------------------------------------------ +static void sgw_s8_release_all_enb_related_information( + sgw_eps_bearer_ctxt_t* const eps_bearer_ctxt) { + OAILOG_FUNC_IN(LOG_SPGW_APP); + if (eps_bearer_ctxt) { + memset(&eps_bearer_ctxt->enb_ip_address_S1u, 0, + sizeof(eps_bearer_ctxt->enb_ip_address_S1u)); + eps_bearer_ctxt->enb_teid_S1u = INVALID_TEID; + } + OAILOG_FUNC_OUT(LOG_SPGW_APP); +} + +void sgw_s8_process_release_access_bearer_request( + log_proto_t module, imsi64_t imsi64, + sgw_eps_bearer_context_information_t* sgw_context) { + OAILOG_FUNC_IN(module); + int rv = RETURNok; + /* + * Release the tunnels so that in idle state, DL packets are not sent + * towards eNB. + * These tunnels will be added again when UE moves back to connected mode. + */ + for (uint8_t ebx = 0; ebx < BEARERS_PER_UE; ebx++) { + sgw_eps_bearer_ctxt_t* eps_bearer_ctxt = + sgw_context->pdn_connection.sgw_eps_bearers_array[ebx]; + if (eps_bearer_ctxt) { + struct in_addr enb = {.s_addr = 0}; + struct in6_addr* enb_ipv6 = nullptr; + enb.s_addr = + eps_bearer_ctxt->enb_ip_address_S1u.address.ipv4_address.s_addr; + if (spgw_config.sgw_config.ipv6.s1_ipv6_enabled && + eps_bearer_ctxt->enb_ip_address_S1u.pdn_type == IPv6) { + enb_ipv6 = &eps_bearer_ctxt->enb_ip_address_S1u.address.ipv6_address; + } + + struct in6_addr* ue_ipv6 = nullptr; + if ((eps_bearer_ctxt->paa.pdn_type == IPv6) || + (eps_bearer_ctxt->paa.pdn_type == IPv4_AND_v6)) { + ue_ipv6 = &eps_bearer_ctxt->paa.ipv6_address; + } + struct in_addr ue_ipv4 = {.s_addr = 0}; + ue_ipv4.s_addr = eps_bearer_ctxt->paa.ipv4_address.s_addr; + struct in_addr pgw = {.s_addr = 0}; + pgw.s_addr = + eps_bearer_ctxt->p_gw_address_in_use_up.address.ipv4_address.s_addr; + struct in6_addr* pgw_ipv6 = nullptr; + if ((eps_bearer_ctxt->p_gw_address_in_use_up.pdn_type == IPv6) || + (eps_bearer_ctxt->p_gw_address_in_use_up.pdn_type == IPv4_AND_v6)) { + pgw_ipv6 = + &eps_bearer_ctxt->p_gw_address_in_use_up.address.ipv6_address; + } + OAILOG_DEBUG_UE( + module, imsi64, + "Deleting tunnel for bearer_id %u ue addr %x enb_ip %x " + "sgw_teid_s1u_s12_s4_up " TEID_FMT "enb_teid_S1u " TEID_FMT + " pgw_up_ip %x " + "pgw_up_teid " TEID_FMT + "s_gw_ip_address_S5_S8_up %x" + "s_gw_teid_S5_S8_up " TEID_FMT, + eps_bearer_ctxt->eps_bearer_id, ue_ipv4.s_addr, enb.s_addr, + eps_bearer_ctxt->s_gw_teid_S1u_S12_S4_up, + eps_bearer_ctxt->enb_teid_S1u, pgw.s_addr, + eps_bearer_ctxt->p_gw_teid_S5_S8_up, + eps_bearer_ctxt->s_gw_ip_address_S5_S8_up.address.ipv4_address.s_addr, + eps_bearer_ctxt->s_gw_teid_S5_S8_up); +#if !MME_UNIT_TEST // skip tunnel deletion for unit tests + if (module == LOG_SPGW_APP) { + rv = gtp_tunnel_ops->del_tunnel( + enb, enb_ipv6, eps_bearer_ctxt->paa.ipv4_address, ue_ipv6, + eps_bearer_ctxt->s_gw_teid_S1u_S12_S4_up, + eps_bearer_ctxt->enb_teid_S1u, nullptr); + } else if (module == LOG_SGW_S8) { + rv = gtpv1u_del_s8_tunnel(enb, enb_ipv6, pgw, pgw_ipv6, + eps_bearer_ctxt->paa.ipv4_address, ue_ipv6, + eps_bearer_ctxt->s_gw_teid_S1u_S12_S4_up, + eps_bearer_ctxt->s_gw_teid_S5_S8_up); + } + + // TODO Need to add handling on failing to delete s1-u tunnel rules from + // ovs flow table + if (rv < 0) { + OAILOG_ERROR_UE(module, imsi64, + "ERROR in deleting TUNNEL " TEID_FMT + " (eNB) <-> (SGW) " TEID_FMT "\n", + eps_bearer_ctxt->enb_teid_S1u, + eps_bearer_ctxt->s_gw_teid_S1u_S12_S4_up); + } + // Paging is performed without packet buffering + rv = gtp_tunnel_ops->add_paging_rule( + sgw_context->imsi, eps_bearer_ctxt->paa.ipv4_address, ue_ipv6); + // Convert to string for logging + char* ip_str = inet_ntoa(eps_bearer_ctxt->paa.ipv4_address); + if (rv < 0) { + OAILOG_ERROR_UE(module, imsi64, + "ERROR in setting paging rule for IP Addr: %s\n", + ip_str); + } + if ((eps_bearer_ctxt->paa.pdn_type == IPv6) || + (eps_bearer_ctxt->paa.pdn_type == IPv4_AND_v6)) { + char ip6_str[INET6_ADDRSTRLEN]; + inet_ntop(AF_INET6, + reinterpret_cast(&eps_bearer_ctxt->paa.ipv6_address), + ip6_str, INET6_ADDRSTRLEN); + OAILOG_DEBUG(module, "Set the paging rule for IPv6 Addr: %s\n", + ip6_str); + } else { + OAILOG_DEBUG(module, "Set the paging rule for IP Addr: %s\n", ip_str); + } +#endif + sgw_s8_release_all_enb_related_information(eps_bearer_ctxt); + } + } + OAILOG_FUNC_OUT(module); +} + +// Create temporary dedicated bearer context +status_code_e create_temporary_s8_dedicated_bearer_context( + sgw_eps_bearer_context_information_t* sgw_ctxt_p, + const itti_gx_nw_init_actv_bearer_request_t* const bearer_req_p, + pdn_type_t pdn_type, uint32_t sgw_ip_address_S1u_S12_S4_up, + struct in6_addr* sgw_ipv6_address_S1u_S12_S4_up, teid_t s1_u_sgw_fteid, + uint32_t sequence_number, log_proto_t module) { + OAILOG_FUNC_IN(module); + sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = new sgw_eps_bearer_ctxt_t(); + + // Copy PAA from default bearer cntxt + sgw_eps_bearer_ctxt_t* default_eps_bearer_entry_p = + sgw_s8_cm_get_eps_bearer_entry(&sgw_ctxt_p->pdn_connection, + sgw_ctxt_p->pdn_connection.default_bearer); + + if (!default_eps_bearer_entry_p) { + OAILOG_ERROR_UE(module, sgw_ctxt_p->imsi64, + "Failed to get default bearer context for bearer id :%u", + sgw_ctxt_p->pdn_connection.default_bearer); + OAILOG_FUNC_RETURN(module, RETURNerror); + } + + eps_bearer_ctxt_p->eps_bearer_id = 0; + eps_bearer_ctxt_p->paa = default_eps_bearer_entry_p->paa; + // SGW FTEID + eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up = s1_u_sgw_fteid; + + if (pdn_type == IPv4 || pdn_type == IPv4_AND_v6) { + eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.pdn_type = IPv4; + eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.address.ipv4_address + .s_addr = sgw_ip_address_S1u_S12_S4_up; + } else { + eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.pdn_type = IPv6; + memcpy( + &eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.address.ipv6_address, + &sgw_ipv6_address_S1u_S12_S4_up, + sizeof(eps_bearer_ctxt_p->s_gw_ip_address_S1u_S12_S4_up.address + .ipv6_address)); + } + // DL TFT + memcpy(&eps_bearer_ctxt_p->tft, &bearer_req_p->dl_tft, + sizeof(traffic_flow_template_t)); + // QoS + memcpy(&eps_bearer_ctxt_p->eps_bearer_qos, &bearer_req_p->eps_bearer_qos, + sizeof(bearer_qos_t)); + // Save Policy Rule Name + snprintf(eps_bearer_ctxt_p->policy_rule_name, POLICY_RULE_NAME_MAXLEN + 1, + "%s", bearer_req_p->policy_rule_name); + eps_bearer_ctxt_p->sgw_sequence_number = sequence_number; + OAILOG_INFO_UE(module, sgw_ctxt_p->imsi64, + "Number of DL packet filter rules: %d\n", + eps_bearer_ctxt_p->tft.numberofpacketfilters); + + // Create temporary spgw bearer context entry + pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = + pgw_get_procedure_create_bearer(sgw_ctxt_p); + if (!pgw_ni_cbr_proc) { + OAILOG_DEBUG_UE(module, sgw_ctxt_p->imsi64, + "Creating a new temporary eps bearer context entry\n"); + pgw_ni_cbr_proc = pgw_create_procedure_create_bearer(sgw_ctxt_p); + if (!pgw_ni_cbr_proc) { + OAILOG_ERROR_UE(module, sgw_ctxt_p->imsi64, + "Failed to create temporary eps bearer context entry\n"); + OAILOG_FUNC_RETURN(module, RETURNerror); + } + } + struct sgw_eps_bearer_entry_wrapper_s* sgw_eps_bearer_entry_p = + new sgw_eps_bearer_entry_wrapper_s(); + sgw_eps_bearer_entry_p->sgw_eps_bearer_entry = eps_bearer_ctxt_p; + LIST_INSERT_HEAD((pgw_ni_cbr_proc->pending_eps_bearers), + sgw_eps_bearer_entry_p, entries); + OAILOG_FUNC_RETURN(module, RETURNok); +} + +// Build and send ITTI message, s11_create_bearer_request to MME APP +status_code_e sgw_build_and_send_s11_create_bearer_request( + sgw_eps_bearer_context_information_t* sgw_eps_bearer_context_information, + const itti_gx_nw_init_actv_bearer_request_t* const bearer_req_p, + pdn_type_t pdn_type, uint32_t sgw_ip_address_S1u_S12_S4_up, + struct in6_addr* sgw_ipv6_address_S1u_S12_S4_up, teid_t s1_u_sgw_fteid, + log_proto_t module) { + OAILOG_FUNC_IN(module); + MessageDef* message_p = NULL; + status_code_e rc = RETURNerror; + + message_p = itti_alloc_new_message( + (module == LOG_SPGW_APP ? TASK_SPGW_APP : TASK_SGW_S8), + S11_NW_INITIATED_ACTIVATE_BEARER_REQUEST); + if (!message_p) { + OAILOG_ERROR_UE(module, sgw_eps_bearer_context_information->imsi64, + "Failed to allocate message_p for" + "S11_NW_INITIATED_BEARER_ACTV_REQUEST\n"); + OAILOG_FUNC_RETURN(module, rc); + } + + itti_s11_nw_init_actv_bearer_request_t* s11_actv_bearer_request = + &message_p->ittiMsg.s11_nw_init_actv_bearer_request; + memset(s11_actv_bearer_request, 0, + sizeof(itti_s11_nw_init_actv_bearer_request_t)); + // Context TEID + s11_actv_bearer_request->s11_mme_teid = + sgw_eps_bearer_context_information->mme_teid_S11; + // LBI + s11_actv_bearer_request->lbi = bearer_req_p->lbi; + // UL TFT to be sent to UE + memcpy(&s11_actv_bearer_request->tft, &bearer_req_p->ul_tft, + sizeof(traffic_flow_template_t)); + // QoS + memcpy(&s11_actv_bearer_request->eps_bearer_qos, + &bearer_req_p->eps_bearer_qos, sizeof(bearer_qos_t)); + // S1U SGW F-TEID + s11_actv_bearer_request->s1_u_sgw_fteid.teid = s1_u_sgw_fteid; + s11_actv_bearer_request->s1_u_sgw_fteid.interface_type = S1_U_SGW_GTP_U; + // Set IPv4 address type bit + + if (pdn_type == IPv4 || pdn_type == IPv4_AND_v6) { + s11_actv_bearer_request->s1_u_sgw_fteid.ipv4 = true; + s11_actv_bearer_request->s1_u_sgw_fteid.ipv4_address.s_addr = + sgw_ip_address_S1u_S12_S4_up; + } else { + s11_actv_bearer_request->s1_u_sgw_fteid.ipv6 = true; + memcpy(&s11_actv_bearer_request->s1_u_sgw_fteid.ipv6_address, + sgw_ipv6_address_S1u_S12_S4_up, + sizeof(s11_actv_bearer_request->s1_u_sgw_fteid.ipv6_address)); + } + message_p->ittiMsgHeader.imsi = sgw_eps_bearer_context_information->imsi64; + OAILOG_INFO_UE(module, sgw_eps_bearer_context_information->imsi64, + "Sending S11 Create Bearer Request to MME_APP for LBI %d \n", + bearer_req_p->lbi); + if (module == LOG_SPGW_APP) { + rc = send_msg_to_task(&spgw_app_task_zmq_ctx, TASK_MME_APP, message_p); + } else if (module == LOG_SGW_S8) { + rc = send_msg_to_task(&sgw_s8_task_zmq_ctx, TASK_MME_APP, message_p); + } else { + OAILOG_ERROR_UE(module, sgw_eps_bearer_context_information->imsi64, + "Invalid module \n"); + } + OAILOG_FUNC_RETURN(module, rc); +} + +//----------------------------------------------------------------------------- +sgw_eps_bearer_ctxt_t* sgw_cm_insert_eps_bearer_ctxt_in_collection( + sgw_pdn_connection_t* const sgw_pdn_connection, + sgw_eps_bearer_ctxt_t* const sgw_eps_bearer_ctxt) { + if (!sgw_eps_bearer_ctxt) { + OAILOG_ERROR(LOG_SPGW_APP, + "Failed to insert EPS bearer context : nullptr context\n"); + return nullptr; + } + + if (!sgw_pdn_connection->sgw_eps_bearers_array[EBI_TO_INDEX( + sgw_eps_bearer_ctxt->eps_bearer_id)]) { + sgw_pdn_connection->sgw_eps_bearers_array[EBI_TO_INDEX( + sgw_eps_bearer_ctxt->eps_bearer_id)] = sgw_eps_bearer_ctxt; + OAILOG_DEBUG(LOG_SPGW_APP, + "Inserted new EPS bearer entry for EPS bearer id %u \n", + sgw_eps_bearer_ctxt->eps_bearer_id); + } else { + OAILOG_WARNING( + LOG_SPGW_APP, + "Could not create new EPS bearer ctxt for EPS bearer id %u : already " + "exist\n", + sgw_eps_bearer_ctxt->eps_bearer_id); + } + return sgw_eps_bearer_ctxt; +} + +bool is_sgw_enb_ip_address_same(const fteid_t* fte_p, ip_address_t* ip_p) { + bool rc = true; + + switch ((ip_p)->pdn_type) { + case IPv4: + if ((ip_p)->address.ipv4_address.s_addr != (fte_p)->ipv4_address.s_addr) { + rc = false; + } + break; + case IPv4_AND_v6: + case IPv6: + if (memcmp(&(ip_p)->address.ipv6_address, &(fte_p)->ipv6_address, + sizeof((ip_p)->address.ipv6_address)) != 0) { + rc = false; + } + break; + default: + rc = true; + break; + } + OAILOG_FUNC_RETURN(LOG_SPGW_APP, rc); +} + +void sgw_s8_populate_mbr_bearer_contexts_removed( + const itti_sgi_update_end_point_response_t* const resp_pP, imsi64_t imsi64, + sgw_eps_bearer_context_information_t* sgw_context_p, + itti_s11_modify_bearer_response_t* modify_response_p) { + OAILOG_FUNC_IN(LOG_SPGW_APP); + uint8_t rsp_idx = 0; + sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = nullptr; + for (uint8_t idx = 0; idx < resp_pP->num_bearers_removed; idx++) { + eps_bearer_ctxt_p = sgw_s8_cm_get_eps_bearer_entry( + &(sgw_context_p->pdn_connection), + resp_pP->bearer_contexts_to_be_removed[idx]); + /* If context is found, delete the context and set cause as + * REQUEST_ACCEPTED. If context is not found set the cause as + * CONTEXT_NOT_FOUND. MME App sends bearer deactivation message to UE for + * the bearers with cause CONTEXT_NOT_FOUND + */ + if (eps_bearer_ctxt_p != nullptr) { + sgw_s8_free_eps_bearer_context( + &(sgw_context_p->pdn_connection.sgw_eps_bearers_array[EBI_TO_INDEX( + eps_bearer_ctxt_p->eps_bearer_id)])); + modify_response_p->bearer_contexts_marked_for_removal + .bearer_contexts[rsp_idx] + .cause.cause_value = REQUEST_ACCEPTED; + } else { + OAILOG_ERROR_UE( + LOG_SPGW_APP, imsi64, + "Rx SGI_UPDATE_ENDPOINT_RESPONSE: eps_bearer_ctxt_p not found for " + "bearer to be removed ebi %u\n", + resp_pP->bearer_contexts_to_be_removed[idx]); + modify_response_p->bearer_contexts_marked_for_removal + .bearer_contexts[rsp_idx] + .cause.cause_value = CONTEXT_NOT_FOUND; + } + modify_response_p->bearer_contexts_marked_for_removal + .bearer_contexts[rsp_idx++] + .eps_bearer_id = resp_pP->bearer_contexts_to_be_removed[idx]; + modify_response_p->bearer_contexts_marked_for_removal.num_bearer_context++; + } + OAILOG_FUNC_OUT(LOG_SPGW_APP); +} + +void populate_s8_sgi_end_point_update( + uint8_t sgi_rsp_idx, uint8_t idx, + const itti_s11_modify_bearer_request_t* const modify_bearer_pP, + sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p, + itti_sgi_update_end_point_response_t* sgi_update_end_point_resp) { + OAILOG_FUNC_IN(LOG_SPGW_APP); + + FTEID_T_2_IP_ADDRESS_T( + (&modify_bearer_pP->bearer_contexts_to_be_modified.bearer_contexts[idx] + .s1_eNB_fteid), + (&eps_bearer_ctxt_p->enb_ip_address_S1u)); + eps_bearer_ctxt_p->enb_teid_S1u = + modify_bearer_pP->bearer_contexts_to_be_modified.bearer_contexts[idx] + .s1_eNB_fteid.teid; + sgi_update_end_point_resp->bearer_contexts_to_be_modified[sgi_rsp_idx] + .sgw_S1u_teid = eps_bearer_ctxt_p->s_gw_teid_S1u_S12_S4_up; + sgi_update_end_point_resp->bearer_contexts_to_be_modified[sgi_rsp_idx] + .enb_S1u_teid = eps_bearer_ctxt_p->enb_teid_S1u; + sgi_update_end_point_resp->bearer_contexts_to_be_modified[sgi_rsp_idx] + .eps_bearer_id = eps_bearer_ctxt_p->eps_bearer_id; + sgi_update_end_point_resp->num_bearers_modified++; + + OAILOG_FUNC_OUT(LOG_SPGW_APP); +} diff --git a/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_s11_handlers.hpp b/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_s11_handlers.hpp index cbf096cb3592..81f69c698cac 100644 --- a/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_s11_handlers.hpp +++ b/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_s11_handlers.hpp @@ -118,3 +118,10 @@ void sgw_s8_send_failed_delete_bearer_response( gtpv2c_cause_value_t cause_value, Imsi_t imsi, teid_t pgw_s8_teid); void print_bearer_ids_helper(const ebi_t* ebi, uint32_t no_of_bearers); + +status_code_e create_temporary_s8_dedicated_bearer_context( + sgw_eps_bearer_context_information_t* sgw_ctxt_p, + const itti_gx_nw_init_actv_bearer_request_t* const bearer_req_p, + pdn_type_t pdn_type, uint32_t sgw_ip_address_S1u_S12_S4_up, + struct in6_addr* sgw_ipv6_address_S1u_S12_S4_up, teid_t s1_u_sgw_fteid, + uint32_t sequence_number, log_proto_t module); diff --git a/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_state.cpp b/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_state.cpp index 328da8ed77db..edc3deb589f8 100644 --- a/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_state.cpp +++ b/lte/gateway/c/core/oai/tasks/sgw_s8/sgw_s8_state.cpp @@ -59,6 +59,28 @@ void put_sgw_ue_state(sgw_state_t* sgw_state, imsi64_t imsi64) { return; } void delete_sgw_ue_state(imsi64_t imsi64) { return; } +void sgw_s8_free_eps_bearer_context( + sgw_eps_bearer_ctxt_t** sgw_eps_bearer_ctxt) { + if (*sgw_eps_bearer_ctxt) { + if ((*sgw_eps_bearer_ctxt)->pgw_cp_ip_port) { + free_wrapper( + reinterpret_cast(&(*sgw_eps_bearer_ctxt)->pgw_cp_ip_port)); + } + free_cpp_wrapper(reinterpret_cast(sgw_eps_bearer_ctxt)); + } +} + +void sgw_s8_free_pdn_connection(sgw_pdn_connection_t* pdn_connection_p) { + if (pdn_connection_p) { + if (pdn_connection_p->apn_in_use) { + free_wrapper(reinterpret_cast(&pdn_connection_p->apn_in_use)); + } + + for (auto& ebix : pdn_connection_p->sgw_eps_bearers_array) { + sgw_s8_free_eps_bearer_context(&ebix); + } + } +} void sgw_free_s11_bearer_context_information(void** ptr) { if (!ptr) { return; @@ -66,7 +88,7 @@ void sgw_free_s11_bearer_context_information(void** ptr) { sgw_eps_bearer_context_information_t* sgw_eps_context = reinterpret_cast(*ptr); if (sgw_eps_context) { - sgw_free_pdn_connection(&sgw_eps_context->pdn_connection); + sgw_s8_free_pdn_connection(&sgw_eps_context->pdn_connection); delete_pending_procedures(sgw_eps_context); free_cpp_wrapper(reinterpret_cast(ptr)); } diff --git a/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_dedicated_bearer.cpp b/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_dedicated_bearer.cpp index b4a266f2eb91..84e6e39c6de3 100644 --- a/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_dedicated_bearer.cpp +++ b/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_dedicated_bearer.cpp @@ -51,7 +51,7 @@ TEST_F(SgwS8ConfigAndCreateMock, check_dedicated_bearer_creation_request) { memcpy(&itti_bearer_req.eps_bearer_qos, &bc_cbreq.qos, sizeof(bearer_qos_t)); teid_t s1_u_sgw_fteid = sgw_get_new_s1u_teid(sgw_state); // Validates temporary bearer context is created - EXPECT_EQ(create_temporary_dedicated_bearer_context( + EXPECT_EQ(create_temporary_s8_dedicated_bearer_context( sgw_pdn_session, &itti_bearer_req, IPv4, sgw_state->sgw_ip_address_S1u_S12_S4_up.s_addr, &sgw_state->sgw_ipv6_address_S1u_S12_S4_up, s1_u_sgw_fteid, @@ -133,7 +133,7 @@ TEST_F(SgwS8ConfigAndCreateMock, check_failed_to_create_dedicated_bearer) { sizeof(traffic_flow_template_t)); memcpy(&itti_bearer_req.eps_bearer_qos, &bc_cbreq.qos, sizeof(bearer_qos_t)); teid_t s1_u_sgw_fteid = sgw_get_new_s1u_teid(sgw_state); - create_temporary_dedicated_bearer_context( + create_temporary_s8_dedicated_bearer_context( sgw_pdn_session, &itti_bearer_req, IPv4, sgw_state->sgw_ip_address_S1u_S12_S4_up.s_addr, &sgw_state->sgw_ipv6_address_S1u_S12_S4_up, s1_u_sgw_fteid, @@ -147,7 +147,7 @@ TEST_F(SgwS8ConfigAndCreateMock, check_failed_to_create_dedicated_bearer) { fill_create_bearer_response(&s11_actv_bearer_rsp, csresp.context_teid, default_eps_bearer_id, s1_u_sgw_fteid, REQUEST_REJECTED); - handle_failed_create_bearer_response( + handle_failed_s8_create_bearer_response( sgw_pdn_session, s11_actv_bearer_rsp.cause.cause_value, imsi64, &s11_actv_bearer_rsp.bearer_contexts.bearer_contexts[0], NULL, LOG_SGW_S8); @@ -185,7 +185,7 @@ TEST_F(SgwS8ConfigAndCreateMock, delete_bearer_response_invalid_teid) { memcpy(&itti_bearer_req.eps_bearer_qos, &bc_cbreq.qos, sizeof(bearer_qos_t)); teid_t s1_u_sgw_fteid = sgw_get_new_s1u_teid(sgw_state); // Validates temporary bearer context is created - create_temporary_dedicated_bearer_context( + create_temporary_s8_dedicated_bearer_context( sgw_pdn_session, &itti_bearer_req, IPv4, sgw_state->sgw_ip_address_S1u_S12_S4_up.s_addr, &sgw_state->sgw_ipv6_address_S1u_S12_S4_up, s1_u_sgw_fteid, @@ -240,7 +240,7 @@ TEST_F(SgwS8ConfigAndCreateMock, create_bearer_req_fails_to_find_ctxt) { memcpy(&itti_bearer_req.eps_bearer_qos, &bc_cbreq.qos, sizeof(bearer_qos_t)); teid_t s1_u_sgw_fteid = sgw_get_new_s1u_teid(sgw_state); // Validates temporary bearer context is created - EXPECT_EQ(create_temporary_dedicated_bearer_context( + EXPECT_EQ(create_temporary_s8_dedicated_bearer_context( sgw_pdn_session, &itti_bearer_req, IPv4, sgw_state->sgw_ip_address_S1u_S12_S4_up.s_addr, &sgw_state->sgw_ipv6_address_S1u_S12_S4_up, s1_u_sgw_fteid, diff --git a/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_s8_test_attach_proc.cpp b/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_s8_test_attach_proc.cpp index 11a85e5686b5..f9d4598fede1 100644 --- a/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_s8_test_attach_proc.cpp +++ b/lte/gateway/c/core/oai/test/sgw_s8_task/sgw_s8_test_attach_proc.cpp @@ -121,7 +121,7 @@ TEST_F(SgwS8ConfigAndCreateMock, update_pdn_session_on_cs_rsp) { RETURNok); cv.wait_for(lock, std::chrono::milliseconds(END_OF_TESTCASE_SLEEP_MS)); EXPECT_TRUE((sgw_get_sgw_eps_bearer_context(csresp.context_teid)) != nullptr); - sgw_eps_bearer_ctxt_t* bearer_ctx_p = sgw_cm_get_eps_bearer_entry( + sgw_eps_bearer_ctxt_t* bearer_ctx_p = sgw_s8_cm_get_eps_bearer_entry( &sgw_pdn_session->pdn_connection, csresp.eps_bearer_id); EXPECT_TRUE(bearer_ctx_p != nullptr); @@ -248,7 +248,7 @@ TEST_F(SgwS8ConfigAndCreateMock, delete_session_req_handling) { cv.wait_for(lock, std::chrono::milliseconds(END_OF_TESTCASE_SLEEP_MS)); EXPECT_TRUE((sgw_get_sgw_eps_bearer_context(csresp.context_teid)) != nullptr); - sgw_eps_bearer_ctxt_t* bearer_ctx_p = sgw_cm_get_eps_bearer_entry( + sgw_eps_bearer_ctxt_t* bearer_ctx_p = sgw_s8_cm_get_eps_bearer_entry( &sgw_pdn_session->pdn_connection, csresp.eps_bearer_id); EXPECT_TRUE(bearer_ctx_p != nullptr); @@ -358,7 +358,7 @@ TEST_F(SgwS8ConfigAndCreateMock, update_s1u_bearer_info_on_mbr) { cv.wait_for(lock, std::chrono::milliseconds(END_OF_TESTCASE_SLEEP_MS)); EXPECT_TRUE((sgw_get_sgw_eps_bearer_context(csresp.context_teid)) != nullptr); - sgw_eps_bearer_ctxt_t* bearer_ctx_p = sgw_cm_get_eps_bearer_entry( + sgw_eps_bearer_ctxt_t* bearer_ctx_p = sgw_s8_cm_get_eps_bearer_entry( &sgw_pdn_session->pdn_connection, csresp.eps_bearer_id); EXPECT_TRUE(bearer_ctx_p != nullptr); @@ -376,8 +376,8 @@ TEST_F(SgwS8ConfigAndCreateMock, update_s1u_bearer_info_on_mbr) { sgw_s8_handle_modify_bearer_request(sgw_state, &mbr_req, imsi64); cv.wait_for(lock, std::chrono::milliseconds(END_OF_TESTCASE_SLEEP_MS)); - bearer_ctx_p = sgw_cm_get_eps_bearer_entry(&sgw_pdn_session->pdn_connection, - csresp.eps_bearer_id); + bearer_ctx_p = sgw_s8_cm_get_eps_bearer_entry( + &sgw_pdn_session->pdn_connection, csresp.eps_bearer_id); EXPECT_TRUE(bearer_ctx_p != nullptr); EXPECT_TRUE(bearer_ctx_p->enb_teid_S1u == diff --git a/lte/gateway/c/core/oai/test/spgw_task/BUILD.bazel b/lte/gateway/c/core/oai/test/spgw_task/BUILD.bazel index 53438b9ba845..33746d17d2fe 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/BUILD.bazel +++ b/lte/gateway/c/core/oai/test/spgw_task/BUILD.bazel @@ -132,16 +132,3 @@ cc_test( "@com_google_googletest//:gtest_main", ], ) - -cc_test( - name = "spgw_state_converter_test", - size = "small", - srcs = [ - "test_spgw_state_converter.cpp", - ], - deps = [ - ":spgw_test_core", - "//lte/gateway/c/core:lib_agw_of", - "@com_google_googletest//:gtest", - ], -) diff --git a/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000001_SPGW_ATTACHED b/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000001_SPGW_ATTACHED index 6c580004034c..05d591205069 100755 Binary files a/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000001_SPGW_ATTACHED and b/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000001_SPGW_ATTACHED differ diff --git a/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000002_SPGW_ATTACHED b/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000002_SPGW_ATTACHED index f8f8baf60a70..3f3ec0177be2 100755 Binary files a/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000002_SPGW_ATTACHED and b/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000002_SPGW_ATTACHED differ diff --git a/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000008_SPGW_ATTACHED b/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000008_SPGW_ATTACHED index f3b257def490..69151e516606 100755 Binary files a/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000008_SPGW_ATTACHED and b/lte/gateway/c/core/oai/test/spgw_task/data/IMSI001010000000008_SPGW_ATTACHED differ diff --git a/lte/gateway/c/core/oai/test/spgw_task/spgw_procedures_test_fixture.cpp b/lte/gateway/c/core/oai/test/spgw_task/spgw_procedures_test_fixture.cpp index 1a3c2324f21d..7f5300891baa 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/spgw_procedures_test_fixture.cpp +++ b/lte/gateway/c/core/oai/test/spgw_task/spgw_procedures_test_fixture.cpp @@ -35,7 +35,6 @@ extern "C" { namespace magma { namespace lte { - task_zmq_ctx_t task_zmq_ctx_main_spgw; static int handle_message(zloop_t* loop, zsock_t* reader, void* arg) { @@ -114,15 +113,16 @@ teid_t SPGWAppProcedureTest::create_default_session(spgw_state_t* spgw_state) { LIST_FIRST(&ue_context_p->sgw_s11_teid_list)->sgw_s11_teid; // Verify that no IP address is allocated for this UE - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - DEFAULT_EPS_BEARER_ID); - - EXPECT_TRUE(eps_bearer_ctxt_p->paa.ipv4_address.s_addr == UNASSIGNED_UE_IP); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + magma::proto_map_rc_t rc = sgw_cm_get_eps_bearer_entry( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + DEFAULT_EPS_BEARER_ID, &eps_bearer_ctxt); + EXPECT_TRUE(eps_bearer_ctxt.ue_ip_paa().ipv4_addr().size() == + UNASSIGNED_UE_IP); // send an IP alloc response to SPGW itti_ip_allocation_response_t test_ip_alloc_resp = {}; @@ -135,7 +135,14 @@ teid_t SPGWAppProcedureTest::create_default_session(spgw_state_t* spgw_state) { EXPECT_EQ(return_code, RETURNok); // check if IP address is allocated after this message is done - EXPECT_TRUE(eps_bearer_ctxt_p->paa.ipv4_address.s_addr == DEFAULT_UE_IP); + sgw_cm_get_eps_bearer_entry( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + DEFAULT_EPS_BEARER_ID, &eps_bearer_ctxt); + struct in_addr ue_ipv4 = {}; + uint32_t ue_ip = DEFAULT_UE_IP; + inet_pton(AF_INET, eps_bearer_ctxt.ue_ip_paa().ipv4_addr().c_str(), &ue_ipv4); + EXPECT_TRUE(!(memcmp(&ue_ipv4, &ue_ip, sizeof(DEFAULT_UE_IP)))); // send pcef create session response to SPGW itti_pcef_create_session_response_t sample_pcef_csr_resp; @@ -173,7 +180,7 @@ teid_t SPGWAppProcedureTest::create_default_session(spgw_state_t* spgw_state) { ebi_t SPGWAppProcedureTest ::activate_dedicated_bearer( spgw_state_t* spgw_state, - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p, + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p, teid_t ue_sgw_teid) { status_code_e return_code = RETURNerror; // send network initiated dedicated bearer activation request from Session @@ -199,20 +206,27 @@ ebi_t SPGWAppProcedureTest ::activate_dedicated_bearer( EXPECT_EQ(return_code, RETURNok); + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context(); // check number of pending procedures - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 1); + EXPECT_EQ(get_num_pending_create_bearer_procedures(sgw_context_p), 1); // fetch new SGW teid for the pending bearer procedure - pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = pgw_get_procedure_create_bearer( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information); - EXPECT_TRUE(pgw_ni_cbr_proc != nullptr); - sgw_eps_bearer_entry_wrapper_t* spgw_eps_bearer_entry_p = - LIST_FIRST(pgw_ni_cbr_proc->pending_eps_bearers); - teid_t ue_ded_bearer_sgw_teid = - spgw_eps_bearer_entry_p->sgw_eps_bearer_entry->s_gw_teid_S1u_S12_S4_up; + teid_t ue_ded_bearer_sgw_teid = 0; + for (int proc_index = 0; + proc_index < sgw_context_p->pending_procedures_size(); proc_index++) { + magma::lte::oai::PgwCbrProcedure* pgw_ni_cbr_proc = + sgw_context_p->mutable_pending_procedures(proc_index); + EXPECT_TRUE(pgw_ni_cbr_proc->type() == + PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST); + for (uint8_t bearer_index = 0; + bearer_index < pgw_ni_cbr_proc->pending_eps_bearers_size(); + bearer_index++) { + magma::lte::oai::SgwEpsBearerContext* bearer_context_proto = + pgw_ni_cbr_proc->mutable_pending_eps_bearers(bearer_index); + ue_ded_bearer_sgw_teid = bearer_context_proto->sgw_teid_s1u_s12_s4_up(); + } + } // send bearer activation response from MME ebi_t ded_eps_bearer_id = DEFAULT_EPS_BEARER_ID + 1; @@ -230,10 +244,9 @@ ebi_t SPGWAppProcedureTest ::activate_dedicated_bearer( EXPECT_TRUE(is_num_s1_bearers_valid(ue_sgw_teid, 2)); // check that no pending procedure is left - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 0); + EXPECT_EQ(get_num_pending_create_bearer_procedures( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context()), + 0); return ded_eps_bearer_id; } diff --git a/lte/gateway/c/core/oai/test/spgw_task/spgw_procedures_test_fixture.hpp b/lte/gateway/c/core/oai/test/spgw_task/spgw_procedures_test_fixture.hpp index 02d1a97cbff3..31f4dc1f6b6d 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/spgw_procedures_test_fixture.hpp +++ b/lte/gateway/c/core/oai/test/spgw_task/spgw_procedures_test_fixture.hpp @@ -77,7 +77,7 @@ class SPGWAppProcedureTest : public ::testing::Test { teid_t create_default_session(spgw_state_t* spgw_state); ebi_t activate_dedicated_bearer( spgw_state_t* spgw_state, - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p, + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p, teid_t ue_sgw_teid); void deactivate_dedicated_bearer(spgw_state_t* spgw_state, teid_t ue_sgw_teid, ebi_t ded_eps_bearer_id); diff --git a/lte/gateway/c/core/oai/test/spgw_task/spgw_test_util.cpp b/lte/gateway/c/core/oai/test/spgw_task/spgw_test_util.cpp index 2b176960638a..fc1b519a3898 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/spgw_test_util.cpp +++ b/lte/gateway/c/core/oai/test/spgw_task/spgw_test_util.cpp @@ -62,20 +62,21 @@ bool is_num_cp_teids_valid(uint64_t imsi64, int expected_num_teids) { bool is_num_s1_bearers_valid(teid_t context_teid, int expected_num_active_bearers) { - s_plus_p_gw_eps_bearer_context_information_t* ctxt_p = + magma::lte::oai::S11BearerContext* ctxt_p = sgw_cm_get_spgw_context(context_teid); if (ctxt_p == nullptr) { return false; } - sgw_eps_bearer_context_information_t sgw_context_p = - ctxt_p->sgw_eps_bearer_context_information; + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + ctxt_p->mutable_sgw_eps_bearer_context(); int num_active_bearers = 0; - for (int ebx = 0; ebx < BEARERS_PER_UE; ebx++) { - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt = - sgw_context_p.pdn_connection.sgw_eps_bearers_array[ebx]; - if ((eps_bearer_ctxt) && - (eps_bearer_ctxt->enb_ip_address_S1u.address.ipv4_address.s_addr != - 0)) { + map_uint32_spgw_eps_bearer_context_t eps_bearer_map; + eps_bearer_map.map = + sgw_context_p->mutable_pdn_connection()->mutable_eps_bearer_map(); + for (auto itr = eps_bearer_map.map->begin(); itr != eps_bearer_map.map->end(); + itr++) { + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt = itr->second; + if (eps_bearer_ctxt.enb_s1u_ip_addr().ipv4_addr().size()) { num_active_bearers++; } } @@ -86,23 +87,11 @@ bool is_num_s1_bearers_valid(teid_t context_teid, } int get_num_pending_create_bearer_procedures( - sgw_eps_bearer_context_information_t* ctxt_p) { + magma::lte::oai::SgwEpsBearerContextInfo* ctxt_p) { if (ctxt_p == nullptr) { return 0; } - - int num_pending_create_procedures = 0; - if (ctxt_p->pending_procedures) { - pgw_base_proc_t* base_proc = NULL; - - LIST_FOREACH(base_proc, ctxt_p->pending_procedures, entries) { - if (PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST == - base_proc->type) { - num_pending_create_procedures++; - } - } - } - return num_pending_create_procedures; + return ctxt_p->pending_procedures_size(); } void fill_create_session_request( @@ -374,7 +363,7 @@ void fill_nw_initiated_deactivate_bearer_response( nw_deactv_bearer_resp->bearer_contexts.bearer_contexts[0] .cause.cause_value = cause; } else { - for (int i = 0; i < num_bearer_context; i++) { + for (unsigned int i = 0; i < num_bearer_context; i++) { nw_deactv_bearer_resp->bearer_contexts.bearer_contexts[i].eps_bearer_id = ebi[i]; nw_deactv_bearer_resp->bearer_contexts.bearer_contexts[i] diff --git a/lte/gateway/c/core/oai/test/spgw_task/spgw_test_util.h b/lte/gateway/c/core/oai/test/spgw_task/spgw_test_util.h index 14d4a1045629..8f6299c6522c 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/spgw_test_util.h +++ b/lte/gateway/c/core/oai/test/spgw_task/spgw_test_util.h @@ -54,7 +54,7 @@ bool is_num_s1_bearers_valid(teid_t context_teid, int expected_num_active_bearers); int get_num_pending_create_bearer_procedures( - sgw_eps_bearer_context_information_t* ctxt_p); + magma::lte::oai::SgwEpsBearerContextInfo* ctxt_p); void fill_create_session_request( itti_s11_create_session_request_t* session_request_p, diff --git a/lte/gateway/c/core/oai/test/spgw_task/state_creators.cpp b/lte/gateway/c/core/oai/test/spgw_task/state_creators.cpp index a19cb180cfb7..a6708ab6bda4 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/state_creators.cpp +++ b/lte/gateway/c/core/oai/test/spgw_task/state_creators.cpp @@ -37,50 +37,4 @@ spgw_state_t make_spgw_state(uint32_t gtpv1u_teid, int fd0, int fd1u) { return result; } -// make_bearer_context creates a test bearer context with default values. -s_plus_p_gw_eps_bearer_context_information_t* make_bearer_context(imsi64_t imsi, - teid_t teid) { - // Insert ue into map - spgw_create_or_get_ue_context(imsi); - spgw_update_teid_in_ue_context(imsi, teid); - - // Create underlying object - auto ctx = sgw_cm_create_bearer_context_information_in_collection(teid); - auto sgw = &ctx->sgw_eps_bearer_context_information; - auto pgw = &ctx->pgw_eps_bearer_context_information; - - auto msisdn = "some msisdn"; - - // Set PGW context values - IMSI64_TO_STRING(imsi, (char*)(&pgw->imsi.digit), IMSI_BCD_DIGITS_MAX); - pgw->imsi_unauthenticated_indicator = 100; - strncpy(pgw->msisdn, msisdn, strlen(msisdn)); - - // Set SGW context values - sgw->imsi64 = imsi; - IMSI64_TO_STRING(imsi, (char*)(&sgw->imsi.digit), IMSI_BCD_DIGITS_MAX); - sgw->imsi_unauthenticated_indicator = 20; - strncpy(pgw->msisdn, msisdn, strlen(msisdn)); - sgw->mme_teid_S11 = 300 + teid; - sgw->s_gw_teid_S11_S4 = 400 + teid; - - std::string ip_str = "191.1.3.0"; - bstring ip_bstr; - STRING_TO_BSTRING(ip_str, ip_bstr); - bstring_to_ip_address(ip_bstr, &sgw->mme_ip_address_S11); - bdestroy(ip_bstr); - - ip_str = "192.0.2.1"; - STRING_TO_BSTRING(ip_str, ip_bstr); - bstring_to_ip_address(ip_bstr, &sgw->s_gw_ip_address_S11_S4); - bdestroy(ip_bstr); - - strncpy((char*)&sgw->last_known_cell_Id.plmn, "\x01\x02\x03\x04\x05\x06", 6); - sgw->last_known_cell_Id.cell_identity.enb_id = 500; - sgw->last_known_cell_Id.cell_identity.cell_id = 60; - sgw->last_known_cell_Id.cell_identity.empty = 7; - - return ctx; -} - } // namespace magma diff --git a/lte/gateway/c/core/oai/test/spgw_task/state_creators.hpp b/lte/gateway/c/core/oai/test/spgw_task/state_creators.hpp index 0e6f2cd98995..532bd91c35ab 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/state_creators.hpp +++ b/lte/gateway/c/core/oai/test/spgw_task/state_creators.hpp @@ -21,7 +21,4 @@ gtpv1u_data_t make_gtpv1u_data(int fd0, int fd1u); spgw_state_t make_spgw_state(uint32_t gtpv1u_teid, int fd0, int fd1u); -s_plus_p_gw_eps_bearer_context_information_t* make_bearer_context(imsi64_t imsi, - teid_t teid); - } // namespace magma diff --git a/lte/gateway/c/core/oai/test/spgw_task/test_pgw_pco.cpp b/lte/gateway/c/core/oai/test/spgw_task/test_pgw_pco.cpp index f66546a0a664..8e1a47aee905 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/test_pgw_pco.cpp +++ b/lte/gateway/c/core/oai/test/spgw_task/test_pgw_pco.cpp @@ -79,10 +79,10 @@ class SPGWPcoTest : public ::testing::Test { const uint8_t test_pcscf_ipv4_addr[4] = DEFAULT_PCSCF_IPV4_ARRAY; const std::string test_pcscf_ipv6_addr = DEFAULT_PCSCF_IPV6; - void fill_ipcp(pco_protocol_or_container_id_t* poc_id, char* primary_dns, + void fill_ipcp(magma::lte::oai::PcoProtocol* poc_id, char* primary_dns, char* secondary_dns) { - poc_id->id = PCO_PI_IPCP; - poc_id->length = PCO_PI_IPCP_LEN; + poc_id->set_id(PCO_PI_IPCP); + poc_id->set_length(PCO_PI_IPCP_LEN); char poc_content[PCO_PI_IPCP_LEN]; @@ -103,7 +103,7 @@ class SPGWPcoTest : public ::testing::Test { poc_content[14] = secondary_dns[2]; poc_content[15] = secondary_dns[3]; - poc_id->contents = blk2bstr(poc_content, PCO_PI_IPCP_LEN); + poc_id->set_contents(poc_content, PCO_PI_IPCP_LEN); } void clear_pco(protocol_configuration_options_t* pco) { @@ -143,13 +143,13 @@ class SPGWPcoTest : public ::testing::Test { TEST_F(SPGWPcoTest, TestIPCPWithNoDNS) { status_code_e return_code = RETURNerror; protocol_configuration_options_t pco_resp = {}; - pco_protocol_or_container_id_t poc_id = {}; + magma::lte::oai::PcoProtocol poc_id = {}; char no_dns[4] = {0x00, 0x00, 0x00, 0x00}; fill_ipcp(&poc_id, no_dns, no_dns); - return_code = pgw_process_pco_request_ipcp(&pco_resp, &poc_id); + return_code = pgw_process_pco_request_ipcp(&pco_resp, poc_id); EXPECT_EQ(return_code, RETURNok); EXPECT_EQ(pco_resp.num_protocol_or_container_id, 1); @@ -157,8 +157,9 @@ TEST_F(SPGWPcoTest, TestIPCPWithNoDNS) { // compare the values in pco_resp with those in the poc_id EXPECT_EQ(pco_resp.protocol_or_container_ids[0].id, PCO_PI_IPCP); EXPECT_EQ(pco_resp.protocol_or_container_ids[0].length, PCO_PI_IPCP_LEN); + std::string contents = poc_id.contents(); EXPECT_EQ(pco_resp.protocol_or_container_ids[0].contents->data[1], - poc_id.contents->data[1]); // Identifier is same as poc_id + contents.at(1)); // Identifier is same as poc_id // check that return code is NACK EXPECT_EQ(pco_resp.protocol_or_container_ids[0].contents->data[0], @@ -173,21 +174,20 @@ TEST_F(SPGWPcoTest, TestIPCPWithNoDNS) { test_dns_secondary, sizeof(test_dns_secondary)), 0); - bdestroy_wrapper(&poc_id.contents); clear_pco(&pco_resp); } TEST_F(SPGWPcoTest, TestIPCPWithRandomDNS) { status_code_e return_code = RETURNerror; protocol_configuration_options_t pco_resp = {}; - pco_protocol_or_container_id_t poc_id = {}; + magma::lte::oai::PcoProtocol poc_id = {}; char primary_dns[4] = {0x01, 0x02, 0x03, 0x04}; // 1.2.3.4 char secondary_dns[4] = {0x05, 0x06, 0x07, 0x08}; // 5.6.7.8 fill_ipcp(&poc_id, primary_dns, secondary_dns); - return_code = pgw_process_pco_request_ipcp(&pco_resp, &poc_id); + return_code = pgw_process_pco_request_ipcp(&pco_resp, poc_id); EXPECT_EQ(return_code, RETURNok); EXPECT_EQ(pco_resp.num_protocol_or_container_id, 1); @@ -195,8 +195,9 @@ TEST_F(SPGWPcoTest, TestIPCPWithRandomDNS) { // compare the values in pco_resp with those in the poc_id EXPECT_EQ(pco_resp.protocol_or_container_ids[0].id, PCO_PI_IPCP); EXPECT_EQ(pco_resp.protocol_or_container_ids[0].length, PCO_PI_IPCP_LEN); + std::string contents = poc_id.contents(); EXPECT_EQ(pco_resp.protocol_or_container_ids[0].contents->data[1], - poc_id.contents->data[1]); // Identifier is same as poc_id + contents.at(1)); // Identifier is same as poc_id // check that return code is NACK EXPECT_EQ(pco_resp.protocol_or_container_ids[0].contents->data[0], @@ -210,21 +211,20 @@ TEST_F(SPGWPcoTest, TestIPCPWithRandomDNS) { test_dns_secondary, sizeof(test_dns_secondary)), 0); - bdestroy_wrapper(&poc_id.contents); clear_pco(&pco_resp); } TEST_F(SPGWPcoTest, TestIPCPWithMatchingDNS) { status_code_e return_code = RETURNerror; protocol_configuration_options_t pco_resp = {}; - pco_protocol_or_container_id_t poc_id = {}; + magma::lte::oai::PcoProtocol poc_id = {}; char primary_dns[4] = DEFAULT_DNS_PRIMARY_ARRAY; char secondary_dns[4] = DEFAULT_DNS_SECONDARY_ARRAY; fill_ipcp(&poc_id, primary_dns, secondary_dns); - return_code = pgw_process_pco_request_ipcp(&pco_resp, &poc_id); + return_code = pgw_process_pco_request_ipcp(&pco_resp, poc_id); EXPECT_EQ(return_code, RETURNok); EXPECT_EQ(pco_resp.num_protocol_or_container_id, 1); @@ -232,8 +232,9 @@ TEST_F(SPGWPcoTest, TestIPCPWithMatchingDNS) { // compare the values in pco_resp with those in the poc_id EXPECT_EQ(pco_resp.protocol_or_container_ids[0].id, PCO_PI_IPCP); EXPECT_EQ(pco_resp.protocol_or_container_ids[0].length, PCO_PI_IPCP_LEN); + std::string contents = poc_id.contents(); EXPECT_EQ(pco_resp.protocol_or_container_ids[0].contents->data[1], - poc_id.contents->data[1]); // Identifier is same as poc_id + contents.at(1)); // Identifier is same as poc_id // check that return code is ACK EXPECT_EQ(pco_resp.protocol_or_container_ids[0].contents->data[0], @@ -248,7 +249,6 @@ TEST_F(SPGWPcoTest, TestIPCPWithMatchingDNS) { test_dns_secondary, sizeof(test_dns_secondary)), 0); - bdestroy_wrapper(&poc_id.contents); clear_pco(&pco_resp); } @@ -256,7 +256,7 @@ TEST_F(SPGWPcoTest, TestIpv4DnsServerRequest) { status_code_e return_code = RETURNerror; protocol_configuration_options_t pco_resp = {}; - return_code = pgw_process_pco_dns_server_request(&pco_resp, NULL); + return_code = pgw_process_pco_dns_server_request(&pco_resp); EXPECT_EQ(return_code, RETURNok); EXPECT_EQ(pco_resp.num_protocol_or_container_id, 1); @@ -277,7 +277,7 @@ TEST_F(SPGWPcoTest, TestLinkMtuRequest) { protocol_configuration_options_t pco_resp = {}; - return_code = pgw_process_pco_link_mtu_request(&pco_resp, NULL); + return_code = pgw_process_pco_link_mtu_request(&pco_resp); EXPECT_EQ(return_code, RETURNok); EXPECT_EQ(pco_resp.protocol_or_container_ids[0].id, PCO_CI_IPV4_LINK_MTU); @@ -292,15 +292,15 @@ TEST_F(SPGWPcoTest, TestLinkMtuRequest) { TEST_F(SPGWPcoTest, TestPcoRequestIpv6DNS) { status_code_e return_code = RETURNerror; - protocol_configuration_options_t pco_req = {}; + magma::lte::oai::Pco pco_req = {}; protocol_configuration_options_t pco_resp = {}; protocol_configuration_options_ids_t pco_ids = {}; - pco_req.configuration_protocol = - PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE; - pco_req.num_protocol_or_container_id = 1; - pco_req.protocol_or_container_ids[0].id = - PCO_CI_DNS_SERVER_IPV6_ADDRESS_REQUEST; + pco_req.set_configuration_protocol( + PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE); + pco_req.set_num_protocol_or_container_id(1); + magma::lte::oai::PcoProtocol* pco_protocol = pco_req.add_pco_protocol(); + pco_protocol->set_id(PCO_CI_DNS_SERVER_IPV6_ADDRESS_REQUEST); return_code = pgw_process_pco_request(&pco_req, &pco_resp, &pco_ids); @@ -321,14 +321,15 @@ TEST_F(SPGWPcoTest, TestPcoRequestIpv6DNS) { TEST_F(SPGWPcoTest, TestPcoRequestPcscfIpv4) { status_code_e return_code = RETURNerror; - protocol_configuration_options_t pco_req = {}; + magma::lte::oai::Pco pco_req = {}; protocol_configuration_options_t pco_resp = {}; protocol_configuration_options_ids_t pco_ids = {}; - pco_req.configuration_protocol = - PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE; - pco_req.num_protocol_or_container_id = 1; - pco_req.protocol_or_container_ids[0].id = PCO_CI_P_CSCF_IPV4_ADDRESS_REQUEST; + pco_req.set_configuration_protocol( + PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE); + pco_req.set_num_protocol_or_container_id(1); + magma::lte::oai::PcoProtocol* pco_protocol = pco_req.add_pco_protocol(); + pco_protocol->set_id(PCO_CI_P_CSCF_IPV4_ADDRESS_REQUEST); // process PCO for PCSCF without initializing SPGW config return_code = pgw_process_pco_request(&pco_req, &pco_resp, &pco_ids); @@ -357,14 +358,15 @@ TEST_F(SPGWPcoTest, TestPcoRequestPcscfIpv4) { TEST_F(SPGWPcoTest, TestPcoRequestPcscfIpv6) { status_code_e return_code = RETURNerror; - protocol_configuration_options_t pco_req = {}; + magma::lte::oai::Pco pco_req = {}; protocol_configuration_options_t pco_resp = {}; protocol_configuration_options_ids_t pco_ids = {}; - pco_req.configuration_protocol = - PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE; - pco_req.num_protocol_or_container_id = 1; - pco_req.protocol_or_container_ids[0].id = PCO_CI_P_CSCF_IPV6_ADDRESS_REQUEST; + pco_req.set_configuration_protocol( + PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE); + pco_req.set_num_protocol_or_container_id(1); + magma::lte::oai::PcoProtocol* pco_protocol = pco_req.add_pco_protocol(); + pco_protocol->set_id(PCO_CI_P_CSCF_IPV6_ADDRESS_REQUEST); // process PCO for PCSCF without initializing SPGW config return_code = pgw_process_pco_request(&pco_req, &pco_resp, &pco_ids); @@ -395,20 +397,20 @@ TEST_F(SPGWPcoTest, TestPcoRequestPcscfIpv6) { TEST_F(SPGWPcoTest, TestPcoRequestNasSignallingIPCP) { status_code_e return_code = RETURNerror; - protocol_configuration_options_t pco_req = {}; + magma::lte::oai::Pco pco_req = {}; protocol_configuration_options_t pco_resp = {}; protocol_configuration_options_ids_t pco_ids = {}; char no_dns[4] = {0x00, 0x00, 0x00, 0x00}; - pco_req.configuration_protocol = - PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE; - pco_req.num_protocol_or_container_id = 2; + pco_req.set_configuration_protocol( + PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE); + pco_req.set_num_protocol_or_container_id(2); - pco_req.protocol_or_container_ids[0].id = - PCO_CI_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING; + magma::lte::oai::PcoProtocol* pco_protocol = pco_req.add_pco_protocol(); + pco_protocol->set_id(PCO_CI_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING); - fill_ipcp(&pco_req.protocol_or_container_ids[1], no_dns, no_dns); + fill_ipcp(pco_req.add_pco_protocol(), no_dns, no_dns); return_code = pgw_process_pco_request(&pco_req, &pco_resp, &pco_ids); @@ -422,9 +424,9 @@ TEST_F(SPGWPcoTest, TestPcoRequestNasSignallingIPCP) { // compare the values in pco_resp with those in the poc_id EXPECT_EQ(pco_resp.protocol_or_container_ids[0].id, PCO_PI_IPCP); EXPECT_EQ(pco_resp.protocol_or_container_ids[0].length, PCO_PI_IPCP_LEN); + std::string contents = pco_req.pco_protocol(1).contents(); EXPECT_EQ(pco_resp.protocol_or_container_ids[0].contents->data[1], - pco_req.protocol_or_container_ids[1] - .contents->data[1]); // Identifier is same as poc_id + contents.at(1)); // check that return code is NACK EXPECT_EQ(pco_resp.protocol_or_container_ids[0].contents->data[0], @@ -439,20 +441,20 @@ TEST_F(SPGWPcoTest, TestPcoRequestNasSignallingIPCP) { test_dns_secondary, sizeof(test_dns_secondary)), 0); - bdestroy_wrapper(&pco_req.protocol_or_container_ids[1].contents); clear_pco(&pco_resp); } TEST_F(SPGWPcoTest, TestPcoRequestForcePush) { status_code_e return_code = RETURNerror; - protocol_configuration_options_t pco_req = {}; + magma::lte::oai::Pco pco_req = {}; protocol_configuration_options_t pco_resp = {}; protocol_configuration_options_ids_t pco_ids = {}; // pco request without poc_ids - pco_req.num_protocol_or_container_id = 0; - pco_req.configuration_protocol = - PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE; + + pco_req.set_num_protocol_or_container_id(0); + pco_req.set_configuration_protocol( + PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE); // Disable PCO force push spgw_config.pgw_config.force_push_pco = false; @@ -475,16 +477,15 @@ TEST_F(SPGWPcoTest, TestPcoRequestForcePush) { TEST_F(SPGWPcoTest, TestPcoRequestDNSReqForcePush) { status_code_e return_code = RETURNerror; - protocol_configuration_options_t pco_req = {}; + magma::lte::oai::Pco pco_req = {}; protocol_configuration_options_t pco_resp = {}; protocol_configuration_options_ids_t pco_ids = {}; // pco request with DNS request - pco_req.configuration_protocol = - PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE; - pco_req.num_protocol_or_container_id = 1; - pco_req.protocol_or_container_ids[0].id = - PCO_CI_DNS_SERVER_IPV4_ADDRESS_REQUEST; + pco_req.set_configuration_protocol( + PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE); + pco_req.set_num_protocol_or_container_id(1); + pco_req.add_pco_protocol()->set_id(PCO_CI_DNS_SERVER_IPV4_ADDRESS_REQUEST); // Disable PCO force push spgw_config.pgw_config.force_push_pco = false; @@ -512,15 +513,15 @@ TEST_F(SPGWPcoTest, TestPcoRequestDNSReqForcePush) { TEST_F(SPGWPcoTest, TestPcoRequestMTUReqForcePush) { status_code_e return_code = RETURNerror; - protocol_configuration_options_t pco_req = {}; + magma::lte::oai::Pco pco_req = {}; protocol_configuration_options_t pco_resp = {}; protocol_configuration_options_ids_t pco_ids = {}; // pco request with MTU request - pco_req.configuration_protocol = - PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE; - pco_req.num_protocol_or_container_id = 1; - pco_req.protocol_or_container_ids[0].id = PCO_CI_IPV4_LINK_MTU; + pco_req.set_configuration_protocol( + PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE); + pco_req.set_num_protocol_or_container_id(1); + pco_req.add_pco_protocol()->set_id(PCO_CI_IPV4_LINK_MTU); // Disable PCO force push spgw_config.pgw_config.force_push_pco = false; @@ -548,28 +549,28 @@ TEST_F(SPGWPcoTest, TestPcoRequestMTUReqForcePush) { TEST_F(SPGWPcoTest, TestPcoRequestConfigurationProtocol) { status_code_e return_code = RETURNerror; - protocol_configuration_options_t pco_req = {}; + magma::lte::oai::Pco pco_req = {}; protocol_configuration_options_t pco_resp = {}; protocol_configuration_options_ids_t pco_ids = {}; // pco request without poc_ids - pco_req.num_protocol_or_container_id = 0; + pco_req.set_num_protocol_or_container_id(0); // PCO request with random configuration protocol - pco_req.configuration_protocol = + pco_req.set_configuration_protocol( 1 + - PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE; + PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE); return_code = pgw_process_pco_request(&pco_req, &pco_resp, &pco_ids); EXPECT_EQ(return_code, RETURNok); EXPECT_EQ(pco_resp.configuration_protocol, 0); PCO_IDS_EXPECT_EQ(0, 0, 0, 0, 0); // PCO request with configuration protocol set - pco_req.configuration_protocol = - PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE; + pco_req.set_configuration_protocol( + PCO_CONFIGURATION_PROTOCOL_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE); return_code = pgw_process_pco_request(&pco_req, &pco_resp, &pco_ids); EXPECT_EQ(return_code, RETURNok); - EXPECT_EQ(pco_resp.configuration_protocol, pco_req.configuration_protocol); + EXPECT_EQ(pco_resp.configuration_protocol, pco_req.configuration_protocol()); PCO_IDS_EXPECT_EQ(0, 0, 0, 0, 0); clear_pco(&pco_resp); } diff --git a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures.cpp b/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures.cpp index 3f9703178f36..68c48cd70e59 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures.cpp +++ b/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures.cpp @@ -21,7 +21,6 @@ namespace magma { namespace lte { - TEST_F(SPGWAppProcedureTest, TestModifyBearerFailure) { status_code_e return_code = RETURNerror; @@ -102,7 +101,7 @@ TEST_F(SPGWAppProcedureTest, TestSuspendNotification) { // Create session teid_t ue_sgw_teid = create_default_session(spgw_state); - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); // trigger suspend notification to SPGW task @@ -115,8 +114,8 @@ TEST_F(SPGWAppProcedureTest, TestSuspendNotification) { EXPECT_CALL(*mme_app_handler, mme_app_handle_suspend_acknowledge(check_params_in_suspend_ack( REQUEST_ACCEPTED, - spgw_eps_bearer_ctxt_info_p - ->sgw_eps_bearer_context_information.mme_teid_S11))) + spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context() + .mme_teid_s11()))) .Times(1); return_code = sgw_handle_suspend_notification(&sample_suspend_notification, test_imsi64); @@ -134,14 +133,9 @@ TEST_F(SPGWAppProcedureTest, TestDeleteBearerCommand) { // Create session teid_t ue_sgw_teid = create_default_session(spgw_state); - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); - sgw_cm_get_eps_bearer_entry( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - DEFAULT_EPS_BEARER_ID); - // Activate dedicated bearer ebi_t ded_eps_bearer_id = activate_dedicated_bearer( spgw_state, spgw_eps_bearer_ctxt_info_p, ue_sgw_teid); @@ -181,6 +175,5 @@ TEST_F(SPGWAppProcedureTest, TestDeleteBearerCommand) { // Sleep to ensure that messages are received and contexts are released std::this_thread::sleep_for(std::chrono::milliseconds(END_OF_TEST_SLEEP_MS)); } - } // namespace lte } // namespace magma diff --git a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_dedicated_bearer.cpp b/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_dedicated_bearer.cpp index 95b83c0984c7..c929e0b13d6e 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_dedicated_bearer.cpp +++ b/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_dedicated_bearer.cpp @@ -40,14 +40,13 @@ extern "C" { namespace magma { namespace lte { - TEST_F(SPGWAppProcedureTest, TestDedicatedBearerActivation) { spgw_state_t* spgw_state = get_spgw_state(false); // Create session teid_t ue_sgw_teid = create_default_session(spgw_state); - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); // Activate dedicated bearer @@ -64,7 +63,7 @@ TEST_F(SPGWAppProcedureTest, TestDedicatedBearerDeactivation) { // Create session teid_t ue_sgw_teid = create_default_session(spgw_state); - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); // Activate dedicated bearer @@ -94,13 +93,14 @@ TEST_F(SPGWAppProcedureTest, // Create session teid_t ue_sgw_teid = create_default_session(spgw_state); - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - DEFAULT_EPS_BEARER_ID); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + sgw_cm_get_eps_bearer_entry( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + DEFAULT_EPS_BEARER_ID, &eps_bearer_ctxt); // Activate dedicated bearer ebi_t ded_eps_bearer_id = activate_dedicated_bearer( @@ -157,13 +157,15 @@ TEST_F(SPGWAppProcedureTest, TestDedicatedBearerActivationInvalidImsiLbi) { // Create session teid_t ue_sgw_teid = create_default_session(spgw_state); - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - DEFAULT_EPS_BEARER_ID); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + EXPECT_EQ((sgw_cm_get_eps_bearer_entry( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + DEFAULT_EPS_BEARER_ID, &eps_bearer_ctxt)), + magma::PROTO_MAP_OK); // send network initiated dedicated bearer activation request with // invalid imsi @@ -190,10 +192,9 @@ TEST_F(SPGWAppProcedureTest, TestDedicatedBearerActivationInvalidImsiLbi) { EXPECT_EQ(failed_cause, REQUEST_REJECTED); // check number of pending procedures - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 0); + EXPECT_EQ(get_num_pending_create_bearer_procedures( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context()), + 0); // check that dedicated bearer is not created EXPECT_TRUE(is_num_s1_bearers_valid(ue_sgw_teid, 1)); @@ -220,10 +221,9 @@ TEST_F(SPGWAppProcedureTest, TestDedicatedBearerActivationInvalidImsiLbi) { EXPECT_EQ(failed_cause, REQUEST_REJECTED); // check number of pending procedures - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 0); + EXPECT_EQ(get_num_pending_create_bearer_procedures( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context()), + 0); // check that dedicated bearer is not created EXPECT_TRUE(is_num_s1_bearers_valid(ue_sgw_teid, 1)); @@ -239,13 +239,15 @@ TEST_F(SPGWAppProcedureTest, TestDedicatedBearerDeactivationInvalidImsiLbi) { // Create session teid_t ue_sgw_teid = create_default_session(spgw_state); - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - DEFAULT_EPS_BEARER_ID); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + EXPECT_EQ((sgw_cm_get_eps_bearer_entry( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + DEFAULT_EPS_BEARER_ID, &eps_bearer_ctxt)), + magma::PROTO_MAP_OK); // Activate dedicated bearer ebi_t ded_eps_bearer_id = activate_dedicated_bearer( @@ -308,14 +310,9 @@ TEST_F(SPGWAppProcedureTest, TestDedicatedBearerActivationReject) { // Create session teid_t ue_sgw_teid = create_default_session(spgw_state); - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - DEFAULT_EPS_BEARER_ID); - // send network initiated dedicated bearer activation request from Session // Manager itti_gx_nw_init_actv_bearer_request_t sample_gx_nw_init_ded_bearer_actv_req = @@ -339,20 +336,23 @@ TEST_F(SPGWAppProcedureTest, TestDedicatedBearerActivationReject) { EXPECT_EQ(return_code, RETURNok); + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context(); // check number of pending procedures - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 1); + EXPECT_EQ(get_num_pending_create_bearer_procedures( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context()), + 1); // fetch new SGW teid for the pending bearer procedure - pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = pgw_get_procedure_create_bearer( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information); - EXPECT_TRUE(pgw_ni_cbr_proc != nullptr); - sgw_eps_bearer_entry_wrapper_t* spgw_eps_bearer_entry_p = - LIST_FIRST(pgw_ni_cbr_proc->pending_eps_bearers); - teid_t ue_ded_bearer_sgw_teid = - spgw_eps_bearer_entry_p->sgw_eps_bearer_entry->s_gw_teid_S1u_S12_S4_up; + teid_t ue_ded_bearer_sgw_teid = 0; + for (uint8_t proc_index = 0; + proc_index < sgw_context_p->pending_procedures_size(); proc_index++) { + magma::lte::oai::PgwCbrProcedure pgw_ni_cbr_proc = + sgw_context_p->pending_procedures(proc_index); + magma::lte::oai::SgwEpsBearerContext bearer_context_proto = + pgw_ni_cbr_proc.pending_eps_bearers(0); + ue_ded_bearer_sgw_teid = bearer_context_proto.sgw_teid_s1u_s12_s4_up(); + } // send bearer activation response from MME with cause=REQUEST_REJECTED ebi_t ded_eps_bearer_id = DEFAULT_EPS_BEARER_ID + 1; @@ -370,10 +370,7 @@ TEST_F(SPGWAppProcedureTest, TestDedicatedBearerActivationReject) { EXPECT_TRUE(is_num_s1_bearers_valid(ue_sgw_teid, 1)); // check that no pending procedure is left - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 0); + EXPECT_EQ(get_num_pending_create_bearer_procedures(sgw_context_p), 0); // Sleep to ensure that messages are received and contexts are released std::this_thread::sleep_for(std::chrono::milliseconds(END_OF_TEST_SLEEP_MS)); diff --git a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_session.cpp b/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_session.cpp index a4d9cf12ce7a..4963e49cecee 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_session.cpp +++ b/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_session.cpp @@ -75,15 +75,17 @@ TEST_F(SPGWAppProcedureTest, TestCreateSessionIPAllocFailure) { LIST_FIRST(&ue_context_p->sgw_s11_teid_list)->sgw_s11_teid; // Verify that no IP address is allocated for this UE - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - DEFAULT_EPS_BEARER_ID); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + magma::proto_map_rc_t rc = sgw_cm_get_eps_bearer_entry( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + DEFAULT_EPS_BEARER_ID, &eps_bearer_ctxt); - ASSERT_TRUE(eps_bearer_ctxt_p->paa.ipv4_address.s_addr == UNASSIGNED_UE_IP); + ASSERT_TRUE(eps_bearer_ctxt.ue_ip_paa().ipv4_addr().size() == + UNASSIGNED_UE_IP); // send an IP alloc response to SPGW with status as failure itti_ip_allocation_response_t test_ip_alloc_resp = {}; @@ -124,15 +126,17 @@ TEST_F(SPGWAppProcedureTest, TestCreateSessionPCEFFailure) { LIST_FIRST(&ue_context_p->sgw_s11_teid_list)->sgw_s11_teid; // Verify that no IP address is allocated for this UE - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - DEFAULT_EPS_BEARER_ID); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + magma::proto_map_rc_t rc = sgw_cm_get_eps_bearer_entry( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + DEFAULT_EPS_BEARER_ID, &eps_bearer_ctxt); - ASSERT_TRUE(eps_bearer_ctxt_p->paa.ipv4_address.s_addr == UNASSIGNED_UE_IP); + ASSERT_TRUE(eps_bearer_ctxt.ue_ip_paa().ipv4_addr().size() == + UNASSIGNED_UE_IP); // send an IP alloc response to SPGW itti_ip_allocation_response_t test_ip_alloc_resp = {}; @@ -142,7 +146,14 @@ TEST_F(SPGWAppProcedureTest, TestCreateSessionPCEFFailure) { sgw_handle_ip_allocation_rsp(spgw_state, &test_ip_alloc_resp, test_imsi64); // check if IP address is allocated after this message is done - ASSERT_TRUE(eps_bearer_ctxt_p->paa.ipv4_address.s_addr == DEFAULT_UE_IP); + sgw_cm_get_eps_bearer_entry( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + DEFAULT_EPS_BEARER_ID, &eps_bearer_ctxt); + struct in_addr ue_ipv4 = {}; + int ue_ip = DEFAULT_UE_IP; + inet_pton(AF_INET, eps_bearer_ctxt.ue_ip_paa().ipv4_addr().c_str(), &ue_ipv4); + ASSERT_TRUE(!(memcmp(&ue_ipv4, &ue_ip, sizeof(DEFAULT_UE_IP)))); // send pcef create session response to SPGW itti_pcef_create_session_response_t sample_pcef_csr_resp; diff --git a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_with_injected_state.cpp b/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_with_injected_state.cpp index ec5da4da099e..08f4bdfdfe69 100644 --- a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_with_injected_state.cpp +++ b/lte/gateway/c/core/oai/test/spgw_task/test_spgw_procedures_with_injected_state.cpp @@ -186,15 +186,18 @@ TEST_F(SPGWAppInjectedStateProcedureTest, TestDeleteSessionSuccess) { teid_t ue_sgw_teid = LIST_FIRST(&ue_context_p->sgw_s11_teid_list)->sgw_s11_teid; - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); - sgw_eps_bearer_ctxt_t* eps_bearer_ctxt_p = sgw_cm_get_eps_bearer_entry( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information - .pdn_connection, - DEFAULT_EPS_BEARER_ID); - - ASSERT_TRUE(eps_bearer_ctxt_p->paa.ipv4_address.s_addr == test_ue_ip); + magma::lte::oai::SgwEpsBearerContext eps_bearer_ctxt; + EXPECT_EQ((sgw_cm_get_eps_bearer_entry( + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context() + ->mutable_pdn_connection(), + DEFAULT_EPS_BEARER_ID, &eps_bearer_ctxt)), + magma::PROTO_MAP_OK); + struct in_addr ue_ipv4 = {}; + inet_pton(AF_INET, eps_bearer_ctxt.ue_ip_paa().ipv4_addr().c_str(), &ue_ipv4); + ASSERT_TRUE(!(memcmp(&ue_ipv4, &test_ue_ip, sizeof(test_ue_ip)))); // verify that exactly one session exists in SPGW state ASSERT_TRUE(is_num_ue_contexts_valid(name_of_ue_samples.size())); @@ -254,8 +257,6 @@ TEST_F(SPGWAppInjectedStateProcedureTest, TestModifyBearerFailure) { } TEST_F(SPGWAppInjectedStateProcedureTest, TestReleaseBearerSuccess) { - status_code_e return_code = RETURNerror; - spgw_ue_context_t* ue_context_p = spgw_get_ue_context(test_imsi64); teid_t ue_sgw_teid = @@ -287,7 +288,6 @@ TEST_F(SPGWAppInjectedStateProcedureTest, TestReleaseBearerSuccess) { } TEST_F(SPGWAppInjectedStateProcedureTest, TestReleaseBearerWithInvalidImsi64) { - status_code_e return_code = RETURNerror; spgw_ue_context_t* ue_context_p = spgw_get_ue_context(test_imsi64); teid_t ue_sgw_teid = LIST_FIRST(&ue_context_p->sgw_s11_teid_list)->sgw_s11_teid; @@ -327,7 +327,7 @@ TEST_F(SPGWAppInjectedStateProcedureTest, TestDedicatedBearerActivation) { teid_t ue_sgw_teid = LIST_FIRST(&ue_context_p->sgw_s11_teid_list)->sgw_s11_teid; - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); // verify that exactly one session exists in SPGW state @@ -357,20 +357,27 @@ TEST_F(SPGWAppInjectedStateProcedureTest, TestDedicatedBearerActivation) { EXPECT_EQ(return_code, RETURNok); + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context(); // check number of pending procedures - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 1); + EXPECT_EQ(get_num_pending_create_bearer_procedures(sgw_context_p), 1); // fetch new SGW teid for the pending bearer procedure - pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = pgw_get_procedure_create_bearer( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information); - EXPECT_TRUE(pgw_ni_cbr_proc != nullptr); - sgw_eps_bearer_entry_wrapper_t* spgw_eps_bearer_entry_p = - LIST_FIRST(pgw_ni_cbr_proc->pending_eps_bearers); - teid_t ue_ded_bearer_sgw_teid = - spgw_eps_bearer_entry_p->sgw_eps_bearer_entry->s_gw_teid_S1u_S12_S4_up; + teid_t ue_ded_bearer_sgw_teid = 0; + for (int proc_index = 0; + proc_index < sgw_context_p->pending_procedures_size(); proc_index++) { + magma::lte::oai::PgwCbrProcedure* pgw_ni_cbr_proc = + sgw_context_p->mutable_pending_procedures(proc_index); + EXPECT_TRUE(pgw_ni_cbr_proc->type() == + PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST); + for (int bearer_index = 0; + bearer_index < pgw_ni_cbr_proc->pending_eps_bearers_size(); + bearer_index++) { + magma::lte::oai::SgwEpsBearerContext* bearer_context_proto = + pgw_ni_cbr_proc->mutable_pending_eps_bearers(bearer_index); + ue_ded_bearer_sgw_teid = bearer_context_proto->sgw_teid_s1u_s12_s4_up(); + } + } // send bearer activation response from MME itti_s11_nw_init_actv_bearer_rsp_t sample_nw_init_ded_bearer_actv_resp = {}; @@ -387,10 +394,7 @@ TEST_F(SPGWAppInjectedStateProcedureTest, TestDedicatedBearerActivation) { EXPECT_TRUE(is_num_s1_bearers_valid(ue_sgw_teid, 2)); // check that no pending procedure is left - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 0); + EXPECT_EQ(get_num_pending_create_bearer_procedures(sgw_context_p), 0); // Sleep to ensure that messages are received and contexts are released std::this_thread::sleep_for(std::chrono::milliseconds(END_OF_TEST_SLEEP_MS)); @@ -404,7 +408,7 @@ TEST_F(SPGWAppInjectedStateProcedureTest, TestDedicatedBearerDeactivation) { teid_t ue_sgw_teid = LIST_FIRST(&ue_context_p->sgw_s11_teid_list)->sgw_s11_teid; - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); // verify that exactly one session exists in SPGW state @@ -434,20 +438,21 @@ TEST_F(SPGWAppInjectedStateProcedureTest, TestDedicatedBearerDeactivation) { EXPECT_EQ(return_code, RETURNok); + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context(); // check number of pending procedures - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 1); + EXPECT_EQ(get_num_pending_create_bearer_procedures(sgw_context_p), 1); // fetch new SGW teid for the pending bearer procedure - pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = pgw_get_procedure_create_bearer( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information); - EXPECT_TRUE(pgw_ni_cbr_proc != nullptr); - sgw_eps_bearer_entry_wrapper_t* spgw_eps_bearer_entry_p = - LIST_FIRST(pgw_ni_cbr_proc->pending_eps_bearers); - teid_t ue_ded_bearer_sgw_teid = - spgw_eps_bearer_entry_p->sgw_eps_bearer_entry->s_gw_teid_S1u_S12_S4_up; + teid_t ue_ded_bearer_sgw_teid = 0; + for (int proc_index = 0; + proc_index < sgw_context_p->pending_procedures_size(); proc_index++) { + magma::lte::oai::PgwCbrProcedure* pgw_ni_cbr_proc = + sgw_context_p->mutable_pending_procedures(proc_index); + magma::lte::oai::SgwEpsBearerContext* bearer_context_proto = + pgw_ni_cbr_proc->mutable_pending_eps_bearers(0); + ue_ded_bearer_sgw_teid = bearer_context_proto->sgw_teid_s1u_s12_s4_up(); + } // send bearer activation response from MME ebi_t ded_eps_bearer_id = DEFAULT_EPS_BEARER_ID + 1; @@ -465,10 +470,7 @@ TEST_F(SPGWAppInjectedStateProcedureTest, TestDedicatedBearerDeactivation) { EXPECT_TRUE(is_num_s1_bearers_valid(ue_sgw_teid, 2)); // check that no pending procedure is left - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 0); + EXPECT_EQ(get_num_pending_create_bearer_procedures(sgw_context_p), 0); // send deactivate request for dedicated bearer from Session Manager itti_gx_nw_init_deactv_bearer_request_t @@ -519,7 +521,7 @@ TEST_F(SPGWAppInjectedStateProcedureTest, spgw_ue_context_t* ue_context_p = spgw_get_ue_context(test_imsi64); teid_t ue_sgw_teid = LIST_FIRST(&ue_context_p->sgw_s11_teid_list)->sgw_s11_teid; - s_plus_p_gw_eps_bearer_context_information_t* spgw_eps_bearer_ctxt_info_p = + magma::lte::oai::S11BearerContext* spgw_eps_bearer_ctxt_info_p = sgw_cm_get_spgw_context(ue_sgw_teid); // verify that exactly one session exists in SPGW state @@ -549,21 +551,27 @@ TEST_F(SPGWAppInjectedStateProcedureTest, EXPECT_EQ(return_code, RETURNok); + magma::lte::oai::SgwEpsBearerContextInfo* sgw_context_p = + spgw_eps_bearer_ctxt_info_p->mutable_sgw_eps_bearer_context(); // check number of pending procedures - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 1); + EXPECT_EQ(get_num_pending_create_bearer_procedures(sgw_context_p), 1); // fetch new SGW teid for the pending bearer procedure - pgw_ni_cbr_proc_t* pgw_ni_cbr_proc = pgw_get_procedure_create_bearer( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information); - EXPECT_TRUE(pgw_ni_cbr_proc != nullptr); - sgw_eps_bearer_entry_wrapper_t* spgw_eps_bearer_entry_p = - LIST_FIRST(pgw_ni_cbr_proc->pending_eps_bearers); - teid_t ue_ded_bearer_sgw_teid = - spgw_eps_bearer_entry_p->sgw_eps_bearer_entry->s_gw_teid_S1u_S12_S4_up; - + teid_t ue_ded_bearer_sgw_teid = 0; + for (uint8_t proc_index = 0; + proc_index < sgw_context_p->pending_procedures_size(); proc_index++) { + magma::lte::oai::PgwCbrProcedure pgw_ni_cbr_proc = + sgw_context_p->pending_procedures(proc_index); + EXPECT_TRUE(pgw_ni_cbr_proc.type() == + PGW_BASE_PROC_TYPE_NETWORK_INITATED_CREATE_BEARER_REQUEST); + for (uint8_t bearer_index = 0; + bearer_index < pgw_ni_cbr_proc.pending_eps_bearers_size(); + bearer_index++) { + magma::lte::oai::SgwEpsBearerContext bearer_context_proto = + pgw_ni_cbr_proc.pending_eps_bearers(bearer_index); + ue_ded_bearer_sgw_teid = bearer_context_proto.sgw_teid_s1u_s12_s4_up(); + } + } // send bearer activation response from MME ebi_t ded_eps_bearer_id = DEFAULT_EPS_BEARER_ID + 1; itti_s11_nw_init_actv_bearer_rsp_t sample_nw_init_ded_bearer_actv_resp = {}; @@ -580,10 +588,7 @@ TEST_F(SPGWAppInjectedStateProcedureTest, EXPECT_TRUE(is_num_s1_bearers_valid(ue_sgw_teid, 2)); // check that no pending procedure is left - EXPECT_EQ( - get_num_pending_create_bearer_procedures( - &spgw_eps_bearer_ctxt_info_p->sgw_eps_bearer_context_information), - 0); + EXPECT_EQ(get_num_pending_create_bearer_procedures(sgw_context_p), 0); // send deactivate request for dedicated bearer from Session Manager itti_gx_nw_init_deactv_bearer_request_t @@ -628,6 +633,5 @@ TEST_F(SPGWAppInjectedStateProcedureTest, // Sleep to ensure that messages are received and contexts are released std::this_thread::sleep_for(std::chrono::milliseconds(END_OF_TEST_SLEEP_MS)); } - } // namespace lte } // namespace magma diff --git a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_state_converter.cpp b/lte/gateway/c/core/oai/test/spgw_task/test_spgw_state_converter.cpp deleted file mode 100644 index a637829a7481..000000000000 --- a/lte/gateway/c/core/oai/test/spgw_task/test_spgw_state_converter.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright 2020 The Magma Authors. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - * - * 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. - */ -#include -#include -#include -#include - -#include "lte/gateway/c/core/oai/tasks/sgw/spgw_state_converter.hpp" -#include "lte/gateway/c/core/oai/tasks/sgw/spgw_state_manager.hpp" -#include "lte/gateway/c/core/oai/test/spgw_task/state_creators.hpp" -#include "lte/gateway/c/core/oai/tasks/sgw/sgw_defs.hpp" -#include "lte/protos/oai/mme_nas_state.pb.h" -#include "lte/gateway/c/core/oai/include/spgw_state.hpp" - -extern "C" { -#include "lte/gateway/c/core/oai/lib/message_utils/ie_to_bytes.h" -} - -namespace magma { -namespace lte { - -TEST(SPGWStateConverterTest, TestSPGWStateConversion) { - std::vector original_states{ - make_spgw_state(4, 8, 12), - make_spgw_state(500, 900, 1300), - make_spgw_state(6000, 1000, 1400), - make_spgw_state(0, 0, 32), - }; - - for (spgw_state_t& initial_state : original_states) { - oai::SpgwState proto_state; - spgw_state_t final_state; - - SpgwStateConverter::state_to_proto(&initial_state, &proto_state); - SpgwStateConverter::proto_to_state(proto_state, &final_state); - - EXPECT_EQ(initial_state.gtpv1u_teid, final_state.gtpv1u_teid); - - gtpv1u_data_t initial_gtp_data = initial_state.gtpv1u_data; - gtpv1u_data_t final_gtp_data = final_state.gtpv1u_data; - EXPECT_EQ(initial_gtp_data.fd0, final_gtp_data.fd0); - EXPECT_EQ(initial_gtp_data.fd1u, final_gtp_data.fd1u); - } -} - -TEST(SPGWStateConverterTest, TestUEContextConversion) { - // Inits spgw's configuration and state information - spgw_config_t* spgw_config_p = - (spgw_config_t*)calloc(1, sizeof(spgw_config_t)); - spgw_config_init(spgw_config_p); - spgw_state_init(false, spgw_config_p); - - // Create some UE contexts, populate them with TEIDs - std::vector bearer_ctxs{ - make_bearer_context(10, 100), - make_bearer_context(20, 200), - make_bearer_context(30, 300), - }; - - // Repeat for each UE context - for (s_plus_p_gw_eps_bearer_context_information_t* want : bearer_ctxs) { - auto imsi = want->sgw_eps_bearer_context_information.imsi64; - - // Convert to proto and back - auto initial_ctx = spgw_create_or_get_ue_context(imsi); - auto want_teid = LIST_FIRST(&initial_ctx->sgw_s11_teid_list)->sgw_s11_teid; - - oai::SpgwUeContext proto_ctx; - spgw_ue_context_t* final_ctx = new spgw_ue_context_t(); - SpgwStateConverter::ue_to_proto(initial_ctx, &proto_ctx); - SpgwStateConverter::proto_to_ue(proto_ctx, final_ctx); - - // Ensure underlying bearer contexts match - auto got = sgw_cm_get_spgw_context(want_teid); - EXPECT_NE(got, nullptr); - - // Ensure PGW context matches - auto want_pgw = want->pgw_eps_bearer_context_information; - auto got_pgw = got->pgw_eps_bearer_context_information; - - EXPECT_TRUE(!memcmp(&want_pgw.imsi, &got_pgw.imsi, sizeof(want_pgw.imsi))); - - EXPECT_EQ(want_pgw.imsi_unauthenticated_indicator, - got_pgw.imsi_unauthenticated_indicator); - EXPECT_EQ(std::string(want_pgw.msisdn), std::string(got_pgw.msisdn)); - - // Ensure SGW context matches - auto want_sgw = want->sgw_eps_bearer_context_information; - auto got_sgw = got->sgw_eps_bearer_context_information; - - EXPECT_TRUE(!memcmp(&want_sgw.imsi, &got_sgw.imsi, sizeof(want_sgw.imsi))); - - EXPECT_EQ(want_sgw.imsi64, got_sgw.imsi64); - EXPECT_EQ(want_sgw.imsi_unauthenticated_indicator, - got_sgw.imsi_unauthenticated_indicator); - EXPECT_EQ(std::string(want_sgw.msisdn), std::string(got_sgw.msisdn)); - EXPECT_EQ(want_sgw.mme_teid_S11, got_sgw.mme_teid_S11); - EXPECT_EQ(want_sgw.s_gw_teid_S11_S4, got_sgw.s_gw_teid_S11_S4); - - EXPECT_TRUE(!memcmp(&want_sgw.mme_ip_address_S11, - &got_sgw.mme_ip_address_S11, - sizeof(want_sgw.mme_ip_address_S11))); - - EXPECT_TRUE(!memcmp(&want_sgw.s_gw_ip_address_S11_S4, - &got_sgw.s_gw_ip_address_S11_S4, - sizeof(want_sgw.s_gw_ip_address_S11_S4))); - - EXPECT_TRUE(!memcmp(&want_sgw.last_known_cell_Id, - &got_sgw.last_known_cell_Id, - sizeof(want_sgw.last_known_cell_Id))); - sgw_free_ue_context(reinterpret_cast(&final_ctx)); - } -} -} // namespace lte -} // namespace magma diff --git a/lte/gateway/python/integ_tests/s1aptests/test_attach_service_with_multi_pdns_and_bearers_multi_ue.py b/lte/gateway/python/integ_tests/s1aptests/test_attach_service_with_multi_pdns_and_bearers_multi_ue.py index 3cab237539fd..146c62eff992 100644 --- a/lte/gateway/python/integ_tests/s1aptests/test_attach_service_with_multi_pdns_and_bearers_multi_ue.py +++ b/lte/gateway/python/integ_tests/s1aptests/test_attach_service_with_multi_pdns_and_bearers_multi_ue.py @@ -277,7 +277,7 @@ def test_attach_service_with_multi_pdns_and_bearers_multi_ue(self): # 1 UL flow is created per bearer # 4 UEs * 4 bearers per UE = 16 UL flows - num_ul_flows = 16 + num_ul_flows = num_ues * 4 for i in range(num_ues): dl_flow_rules = { diff --git a/lte/protos/oai/spgw_state.proto b/lte/protos/oai/spgw_state.proto index 2296789246eb..4dad8654fa09 100644 --- a/lte/protos/oai/spgw_state.proto +++ b/lte/protos/oai/spgw_state.proto @@ -33,7 +33,7 @@ message SgwEpsBearerContextInfo { uint64 imsi64 = 6; uint32 mme_teid_s11 = 10; // teid_t - bytes mme_ip_address_s11 = 11; + bytes mme_ip_address_s11 = 11[deprecated = true]; uint32 sgw_teid_s11_s4 = 15; bytes sgw_ip_address_s11_s4 = 16; @@ -41,6 +41,7 @@ message SgwEpsBearerContextInfo { SgwPdnConnection pdn_connection = 20; CreateSessionMessage saved_message = 21; repeated PgwCbrProcedure pending_procedures = 22; + IpTupple mme_cp_ip_address_s11 = 23; } // pgw_ni_cbr_proc_t @@ -77,7 +78,7 @@ message CreateSessionMessage { uint32 rat_type = 10; uint32 pdn_type = 11; bytes apn = 12; - bytes paa = 13; + bytes paa = 13 [deprecated = true]; Ambr ambr = 14; Pco pco = 15; @@ -89,6 +90,7 @@ message CreateSessionMessage { TimeZone ue_time_zone = 22; string charging_characteristics = 23; // Taken from S6A UpdateLocationAnswer + IpTupple ue_ip_paa = 24; } // bearer_context_to_be_created_t @@ -114,15 +116,16 @@ message SgwPdnConnection { uint32 default_bearer = 10; bool ue_suspended_for_ps_handover = 11; - repeated SgwEpsBearerContext eps_bearer_list = 15; + repeated SgwEpsBearerContext eps_bearer_list = 15 [deprecated = true]; + map eps_bearer_map = 16; // ebi -> SgwEpsBearerContext } // sgw_eps_bearer_ctxt_t message SgwEpsBearerContext { uint32 eps_bearer_id = 1; - bytes paa = 2; + bytes paa = 2 [deprecated = true]; - bytes pgw_address_in_use_up = 10; + bytes pgw_address_in_use_up = 10 [deprecated = true]; uint32 pgw_teid_s5_s8_up = 11; bytes sgw_ip_address_s5_s8_up = 12; uint32 sgw_teid_s5_s8_up = 13; @@ -140,6 +143,12 @@ message SgwEpsBearerContext { string policy_rule_name = 27; bytes sgw_ipv6_address_s1u_s12_s4_up = 28; + IpTupple enb_s1u_ip_addr = 29; + IpTupple ue_ip_paa = 30; + IpTupple pgw_address_up = 31; + IpTupple sgw_s1u_s12_s4_up_ip_addr = 32; + uint32 sgw_sequence_number = 33; + bool update_teids = 34; } // traffic_flow_template @@ -207,3 +216,11 @@ message SpgwState { repeated uint64 ipv4_list_allocated = 6; GTPV1uData gtpv1u_data = 7; } + +message IpTupple { + uint32 pdn_type = 1; + bytes ipv4_addr = 2; + bytes ipv6_addr = 3; + int32 vlan = 4; + uint32 ipv6_prefix_length = 5; +}