MCPcopy Create free account
hub / github.com/brimdata/super / Call

Method Call

runtime/sam/expr/function/ip.go:84–102  ·  view source on GitHub ↗
(args []super.Value)

Source from the content-addressed store, hash-verified

82var errMatch = errors.New("match")
83
84func (c *CIDRMatch) Call(args []super.Value) super.Value {
85 maskVal := args[0].Under()
86 if maskVal.IsNull() || args[1].IsNull() {
87 return super.Null
88 }
89 if maskVal.Type() != super.TypeNet {
90 return c.sctx.WrapError("cidr_match: not a net", maskVal)
91 }
92 prefix := super.DecodeNet(maskVal.Bytes())
93 err := args[1].Walk(func(typ super.Type, body scode.Bytes) error {
94 if typ.ID() == super.IDIP {
95 if prefix.Contains(super.DecodeIP(body)) {
96 return errMatch
97 }
98 }
99 return nil
100 })
101 return super.NewBool(err == errMatch)
102}

Callers

nothing calls this directly

Calls 11

DecodeNetFunction · 0.92
DecodeIPFunction · 0.92
NewBoolFunction · 0.92
UnderMethod · 0.80
IsNullMethod · 0.80
WrapErrorMethod · 0.80
WalkMethod · 0.80
ContainsMethod · 0.80
TypeMethod · 0.65
IDMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected