MCPcopy Create free account
hub / github.com/google/nftables / objDataFromMsgLegacy

Function objDataFromMsgLegacy

obj.go:285–322  ·  view source on GitHub ↗
(ad *netlink.AttributeDecoder, table *Table, name string, objectType uint32)

Source from the content-addressed store, hash-verified

283}
284
285func objDataFromMsgLegacy(ad *netlink.AttributeDecoder, table *Table, name string, objectType uint32) (Obj, error) {
286 switch objectType {
287 case unix.NFT_OBJECT_COUNTER:
288 o := CounterObj{
289 Table: table,
290 Name: name,
291 }
292
293 ad.Do(func(b []byte) error {
294 ad, err := netlink.NewAttributeDecoder(b)
295 if err != nil {
296 return err
297 }
298 ad.ByteOrder = binary.BigEndian
299 return o.unmarshal(ad)
300 })
301 return &o, ad.Err()
302 case unix.NFT_OBJECT_QUOTA:
303 o := QuotaObj{
304 Table: table,
305 Name: name,
306 }
307
308 ad.Do(func(b []byte) error {
309 ad, err := netlink.NewAttributeDecoder(b)
310 if err != nil {
311 return err
312 }
313 ad.ByteOrder = binary.BigEndian
314 return o.unmarshal(ad)
315 })
316 return &o, ad.Err()
317 }
318 if err := ad.Err(); err != nil {
319 return nil, err
320 }
321 return nil, fmt.Errorf("malformed stateful object")
322}
323
324func (cc *Conn) getObj(o Obj, t *Table, msgType uint16) ([]Obj, error) {
325 return cc.getObjWithLegacyType(o, t, msgType, cc.useLegacyObjType(o))

Callers 1

objFromMsgFunction · 0.85

Calls 1

unmarshalMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…