Просмотр исходного кода

correct feedbag extended info field

Feedbag SNACs had a TLV header rather than the required TLVLBLock.
Mike 1 месяц назад
Родитель
Сommit
6ba08661fc
4 измененных файлов с 140 добавлено и 47 удалено
  1. 42 13
      foodgroup/feedbag.go
  2. 64 22
      foodgroup/feedbag_test.go
  3. 15 9
      wire/frames.go
  4. 19 3
      wire/snacs.go

+ 42 - 13
foodgroup/feedbag.go

@@ -333,10 +333,14 @@ func (s *FeedbagService) UpsertItem(ctx context.Context, instance *state.Session
 						Frame: wire.SNACFrame{
 							FoodGroup: wire.Feedbag,
 							SubGroup:  wire.FeedbagBuddyAdded,
-							Flags:     0x8000,
+							Flags:     wire.SNACFlagsExtendedInfo,
 						},
 						Body: wire.SNAC_0x13_0x1C_FeedbagBuddyAdded{
-							TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+							TLVLBlock: wire.TLVLBlock{
+								TLVList: wire.TLVList{
+									wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(4)),
+								},
+							},
 							ScreenName: instance.DisplayScreenName().String(),
 						},
 					})
@@ -574,8 +578,14 @@ func (s *FeedbagService) RequestAuthorizeToHost(ctx context.Context, instance *s
 			Frame: wire.SNACFrame{
 				FoodGroup: wire.Feedbag,
 				SubGroup:  wire.FeedbagRequestAuthorizeToClient,
+				Flags:     wire.SNACFlagsExtendedInfo,
 			},
 			Body: wire.SNAC_0x13_0x19_FeedbagRequestAuthorizeToClient{
+				TLVLBlock: wire.TLVLBlock{
+					TLVList: wire.TLVList{
+						wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+					},
+				},
 				ScreenName: instance.IdentScreenName().String(),
 				Reason:     inBody.Reason,
 			},
@@ -828,10 +838,14 @@ func (s *FeedbagService) clearPendingAuth(ctx context.Context, from state.IdentS
 			Frame: wire.SNACFrame{
 				FoodGroup: wire.Feedbag,
 				SubGroup:  wire.FeedbagBuddyAdded,
-				Flags:     0x8000,
+				Flags:     wire.SNACFlagsExtendedInfo,
 			},
 			Body: wire.SNAC_0x13_0x1C_FeedbagBuddyAdded{
-				TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+				TLVLBlock: wire.TLVLBlock{
+					TLVList: wire.TLVList{
+						wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(4)),
+					},
+				},
 				ScreenName: to.String(),
 			},
 		})
@@ -849,7 +863,6 @@ func (s *FeedbagService) clearPendingAuth(ctx context.Context, from state.IdentS
 		Frame: wire.SNACFrame{
 			FoodGroup: wire.Feedbag,
 			SubGroup:  wire.FeedbagUpdateItem,
-			Flags:     0x8000,
 		},
 		Body: wire.SNAC_0x13_0x09_FeedbagUpdateItem{
 			Items: updates,
@@ -861,10 +874,14 @@ func (s *FeedbagService) clearPendingAuth(ctx context.Context, from state.IdentS
 		Frame: wire.SNACFrame{
 			FoodGroup: wire.Feedbag,
 			SubGroup:  wire.FeedbagRespondAuthorizeToClient,
-			Flags:     0x8000,
+			Flags:     wire.SNACFlagsExtendedInfo,
 		},
 		Body: wire.SNAC_0x13_0x1B_FeedbagRespondAuthorizeToClient{
-			TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+			TLVLBlock: wire.TLVLBlock{
+				TLVList: wire.TLVList{
+					wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+				},
+			},
 			ScreenName: from.String(),
 			Accepted:   1,
 		},
@@ -913,10 +930,14 @@ func (s *FeedbagService) rejectContact(ctx context.Context, from state.IdentScre
 			Frame: wire.SNACFrame{
 				FoodGroup: wire.Feedbag,
 				SubGroup:  wire.FeedbagRespondAuthorizeToClient,
-				Flags:     0x8000,
+				Flags:     wire.SNACFlagsExtendedInfo,
 			},
 			Body: wire.SNAC_0x13_0x1B_FeedbagRespondAuthorizeToClient{
-				TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+				TLVLBlock: wire.TLVLBlock{
+					TLVList: wire.TLVList{
+						wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+					},
+				},
 				ScreenName: from.String(),
 				Accepted:   0,
 				Reason:     reason,
@@ -1106,10 +1127,14 @@ func (s *FeedbagService) ForwardICQAuthEvents(ctx context.Context, sender state.
 			Frame: wire.SNACFrame{
 				FoodGroup: wire.Feedbag,
 				SubGroup:  wire.FeedbagBuddyAdded,
-				Flags:     0x8000,
+				Flags:     wire.SNACFlagsExtendedInfo,
 			},
 			Body: wire.SNAC_0x13_0x1C_FeedbagBuddyAdded{
-				TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+				TLVLBlock: wire.TLVLBlock{
+					TLVList: wire.TLVList{
+						wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(4)),
+					},
+				},
 				ScreenName: sender.String(),
 			},
 		})
@@ -1123,10 +1148,14 @@ func (s *FeedbagService) ForwardICQAuthEvents(ctx context.Context, sender state.
 			Frame: wire.SNACFrame{
 				FoodGroup: wire.Feedbag,
 				SubGroup:  wire.FeedbagRequestAuthorizeToClient,
-				Flags:     0x8000,
+				Flags:     wire.SNACFlagsExtendedInfo,
 			},
 			Body: wire.SNAC_0x13_0x19_FeedbagRequestAuthorizeToClient{
-				TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+				TLVLBlock: wire.TLVLBlock{
+					TLVList: wire.TLVList{
+						wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+					},
+				},
 				ScreenName: sender.String(),
 				Reason:     reasonText,
 			},

+ 64 - 22
foodgroup/feedbag_test.go

@@ -804,7 +804,7 @@ func TestFeedbagService_UpsertItem(t *testing.T) {
 							ClassID: wire.FeedbagClassIdBuddyPrefs,
 							TLVLBlock: wire.TLVLBlock{
 								TLVList: wire.TLVList{
-									wire.NewTLVBE(wire.FeedbagAttributesBuddyPrefs, uint32(0x8000)),
+									wire.NewTLVBE(wire.FeedbagAttributesBuddyPrefs, uint32(wire.SNACFlagsExtendedInfo)),
 								},
 							},
 						},
@@ -821,7 +821,7 @@ func TestFeedbagService_UpsertItem(t *testing.T) {
 									ClassID: wire.FeedbagClassIdBuddyPrefs,
 									TLVLBlock: wire.TLVLBlock{
 										TLVList: wire.TLVList{
-											wire.NewTLVBE(wire.FeedbagAttributesBuddyPrefs, uint32(0x8000)),
+											wire.NewTLVBE(wire.FeedbagAttributesBuddyPrefs, uint32(wire.SNACFlagsExtendedInfo)),
 										},
 									},
 								},
@@ -845,7 +845,7 @@ func TestFeedbagService_UpsertItem(t *testing.T) {
 											ClassID: wire.FeedbagClassIdBuddyPrefs,
 											TLVLBlock: wire.TLVLBlock{
 												TLVList: wire.TLVList{
-													wire.NewTLVBE(wire.FeedbagAttributesBuddyPrefs, uint32(0x8000)),
+													wire.NewTLVBE(wire.FeedbagAttributesBuddyPrefs, uint32(wire.SNACFlagsExtendedInfo)),
 												},
 											},
 										},
@@ -1906,10 +1906,14 @@ func TestFeedbagService_UpsertItem(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagBuddyAdded,
-									Flags:     0x8000,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x1C_FeedbagBuddyAdded{
-									TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(4)),
+										},
+									},
 									ScreenName: "me",
 								},
 							},
@@ -2795,7 +2799,7 @@ func TestFeedbagService_Use(t *testing.T) {
 									ClassID: wire.FeedbagClassIdBuddyPrefs,
 									TLVLBlock: wire.TLVLBlock{
 										TLVList: wire.TLVList{
-											wire.NewTLVBE(wire.FeedbagAttributesBuddyPrefs, uint32(0x8000)),
+											wire.NewTLVBE(wire.FeedbagAttributesBuddyPrefs, uint32(wire.SNACFlagsExtendedInfo)),
 										},
 									},
 								},
@@ -3006,8 +3010,14 @@ func TestFeedbagService_RequestAuthorizeToHost(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagRequestAuthorizeToClient,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x19_FeedbagRequestAuthorizeToClient{
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+										},
+									},
 									ScreenName: "100001",
 									Reason:     "please add me.",
 								},
@@ -3052,8 +3062,14 @@ func TestFeedbagService_RequestAuthorizeToHost(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagRequestAuthorizeToClient,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x19_FeedbagRequestAuthorizeToClient{
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+										},
+									},
 									ScreenName: "100001",
 									Reason:     "Please authorize my request and add me to your Contact List. yukitanaka ICQ#: 123405",
 								},
@@ -3559,10 +3575,14 @@ func TestFeedbagService_RespondAuthorizeToHost(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagBuddyAdded,
-									Flags:     0x8000,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x1C_FeedbagBuddyAdded{
-									TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(4)),
+										},
+									},
 									ScreenName: "100003",
 								},
 							},
@@ -3573,7 +3593,6 @@ func TestFeedbagService_RespondAuthorizeToHost(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagUpdateItem,
-									Flags:     0x8000,
 								},
 								Body: wire.SNAC_0x13_0x09_FeedbagUpdateItem{
 									Items: []wire.FeedbagItem{
@@ -3588,10 +3607,14 @@ func TestFeedbagService_RespondAuthorizeToHost(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagRespondAuthorizeToClient,
-									Flags:     0x8000,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x1B_FeedbagRespondAuthorizeToClient{
-									TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+										},
+									},
 									ScreenName: "100001",
 									Accepted:   1,
 								},
@@ -3668,7 +3691,6 @@ func TestFeedbagService_RespondAuthorizeToHost(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagUpdateItem,
-									Flags:     0x8000,
 								},
 								Body: wire.SNAC_0x13_0x09_FeedbagUpdateItem{
 									Items: []wire.FeedbagItem{
@@ -3683,10 +3705,14 @@ func TestFeedbagService_RespondAuthorizeToHost(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagRespondAuthorizeToClient,
-									Flags:     0x8000,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x1B_FeedbagRespondAuthorizeToClient{
-									TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+										},
+									},
 									ScreenName: "100001",
 									Accepted:   1,
 								},
@@ -3733,10 +3759,14 @@ func TestFeedbagService_RespondAuthorizeToHost(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagRespondAuthorizeToClient,
-									Flags:     0x8000,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x1B_FeedbagRespondAuthorizeToClient{
-									TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+										},
+									},
 									ScreenName: "100001",
 									Accepted:   0,
 									Reason:     "I don't know you!",
@@ -4715,10 +4745,14 @@ func TestFeedbagService_ForwardICQAuthEvents(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagRespondAuthorizeToClient,
-									Flags:     0x8000,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x1B_FeedbagRespondAuthorizeToClient{
-									TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+										},
+									},
 									ScreenName: sender.DisplayScreenName().String(),
 									Accepted:   0,
 									Reason:     "no thanks",
@@ -4772,10 +4806,14 @@ func TestFeedbagService_ForwardICQAuthEvents(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagBuddyAdded,
-									Flags:     0x8000,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x1C_FeedbagBuddyAdded{
-									TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(4)),
+										},
+									},
 									ScreenName: sender.IdentScreenName().String(),
 								},
 							},
@@ -4799,10 +4837,14 @@ func TestFeedbagService_ForwardICQAuthEvents(t *testing.T) {
 								Frame: wire.SNACFrame{
 									FoodGroup: wire.Feedbag,
 									SubGroup:  wire.FeedbagRequestAuthorizeToClient,
-									Flags:     0x8000,
+									Flags:     wire.SNACFlagsExtendedInfo,
 								},
 								Body: wire.SNAC_0x13_0x19_FeedbagRequestAuthorizeToClient{
-									TLV:        wire.NewTLVBE(6, uint32(0x00020004)),
+									TLVLBlock: wire.TLVLBlock{
+										TLVList: wire.TLVList{
+											wire.NewTLVBE(wire.FeedbagTLVVersion, uint16(2)),
+										},
+									},
 									ScreenName: sender.IdentScreenName().String(),
 									Reason:     "please add me",
 								},

+ 15 - 9
wire/frames.go

@@ -50,15 +50,21 @@ type SNACFrame struct {
 	RequestID uint32
 }
 
-// SNACFlagsMoreToCome is set on SNAC frames that are part of a multi-packet
-// response (bit 0). Use it on every fragment except the last.
-const SNACFlagsMoreToCome uint16 = 0x0001
-
-// ReqIDFromServer is the SNAC frame Request ID value that indicates the SNAC
-// is initiated by the server. Some clients, such as the Java AIM 1.1.19,
-// completely fail to process some server SNACs if the high bit is not set on
-// request ID.
-const ReqIDFromServer = 1 << 31
+const (
+	// SNACFlagsMoreToCome is set on SNAC frames that are part of a multi-packet
+	// response (bit 0). Use it on every fragment except the last.
+	SNACFlagsMoreToCome uint16 = 0x0001
+
+	// ReqIDFromServer is the SNAC frame Request ID value that indicates the SNAC
+	// is initiated by the server. Some clients, such as the Java AIM 1.1.19,
+	// completely fail to process some server SNACs if the high bit is not set on
+	// request ID.
+	ReqIDFromServer = 1 << 31
+
+	// SNACFlagsExtendedInfo indicates that a TLVLBlock follows the SNAC header
+	// before the rest of the fields.
+	SNACFlagsExtendedInfo uint16 = 0x8000
+)
 
 type FLAPSignonFrame struct {
 	FLAPVersion uint32

+ 19 - 3
wire/snacs.go

@@ -1637,6 +1637,8 @@ type SNAC_0x10_0x07_BARTDownload2Reply struct {
 //
 
 const (
+	FeedbagTLVVersion uint16 = 1 // indicates SSI/Feedbag version in SNAC TLVLBlock
+
 	FeedbagClassIdBuddy            uint16 = 0x0000
 	FeedbagClassIdGroup            uint16 = 0x0001
 	FeedbagClassIDPermit           uint16 = 0x0002
@@ -1858,8 +1860,18 @@ type SNAC_0x13_0x18_FeedbagRequestAuthorizationToHost struct {
 	Unknown    uint16
 }
 
+type FeedbagExtendedInfo struct {
+	//	    arpack << (unsigned short)0x0006 /* extinfo size */
+	//	           << (unsigned short)0x0001 /* TLV(1)   */
+	//		   << (unsigned short)0x0002 /* tlv size */
+	//		   << (unsigned short)user->ssi_version;
+
+}
+
 type SNAC_0x13_0x19_FeedbagRequestAuthorizeToClient struct {
-	TLV
+	// TLVLBlock contains the feedbag extended info for compatibility with
+	// clients that require extended info
+	TLVLBlock
 	ScreenName string `oscar:"len_prefix=uint8"`
 	Reason     string `oscar:"len_prefix=uint16"`
 	Unknown    uint16
@@ -1872,7 +1884,9 @@ type SNAC_0x13_0x1A_FeedbagRespondAuthorizeToHost struct {
 }
 
 type SNAC_0x13_0x1B_FeedbagRespondAuthorizeToClient struct {
-	TLV
+	// TLVLBlock contains the feedbag extended info for compatibility with
+	// clients that require extended info
+	TLVLBlock
 	ScreenName string `oscar:"len_prefix=uint8"`
 	Accepted   uint8
 	Reason     string `oscar:"len_prefix=uint16"`
@@ -1880,7 +1894,9 @@ type SNAC_0x13_0x1B_FeedbagRespondAuthorizeToClient struct {
 }
 
 type SNAC_0x13_0x1C_FeedbagBuddyAdded struct {
-	TLV
+	// TLVLBlock contains the feedbag extended info for compatibility with
+	// clients that require extended info
+	TLVLBlock
 	ScreenName string `oscar:"len_prefix=uint8"`
 	Nullterm   uint16
 }