aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2016-11-28 16:11:15 +0100
committerAndrey Konovalov <andreyknvl@google.com>2016-11-29 16:39:02 +0100
commit86917cc3a79ef74eb06748dc964988f48e6b66a1 (patch)
tree8a693c0b1098299c5d67af9634f4ea340dfd3c7e
parent4278c63e64234425ea1655e3207d85b627fc17f2 (diff)
sys: move in_addr description to templates
-rw-r--r--prog/prio.go2
-rw-r--r--prog/rand.go33
-rw-r--r--sys/decl.go1
-rw-r--r--sys/sys.txt46
-rw-r--r--sysgen/sysgen.go5
5 files changed, 29 insertions, 58 deletions
diff --git a/prog/prio.go b/prog/prio.go
index f503257ad..8c05bda1e 100644
--- a/prog/prio.go
+++ b/prog/prio.go
@@ -99,8 +99,6 @@ func calcStaticPriorities() [][]float32 {
case sys.IntPlain, sys.IntFileoff, sys.IntRange:
case sys.IntSignalno:
noteUsage(1.0, "signalno")
- case sys.IntInaddr:
- noteUsage(1.0, "inaddr")
default:
panic("unknown int kind")
}
diff --git a/prog/rand.go b/prog/rand.go
index 3d25711e5..bdcc89152 100644
--- a/prog/rand.go
+++ b/prog/rand.go
@@ -193,29 +193,6 @@ func (r *randGen) inport(s *state) uint16 {
return uint16(r.Intn(20))<<8 + 0xab
}
-func (r *randGen) in6addr(s *state, typ sys.Type) (arg *Arg, calls []*Call) {
- // addr: loopback (big endian)
- return groupArg(typ, []*Arg{
- constArg(nil, 0),
- constArg(nil, 0),
- constArg(nil, 0),
- constArg(nil, 1<<24),
- }), nil
-}
-
-func (r *randGen) inaddrany(s *state, typ sys.Type) (arg *Arg, calls []*Call) {
- if r.bin() {
- return r.in6addr(s, typ)
- } else {
- return groupArg(typ, []*Arg{
- constArg(nil, uintptr(r.inaddr(s))),
- constArg(nil, 0),
- constArg(nil, 0),
- constArg(nil, 0),
- }), nil
- }
-}
-
func (r *randGen) sockaddr(s *state) []byte {
fa := sockFamilies[r.Intn(len(sockFamilies))]
buf := new(bytes.Buffer)
@@ -315,14 +292,6 @@ func isSpecialStruct(typ sys.Type) func(r *randGen, s *state) (*Arg, []*Call) {
return func(r *randGen, s *state) (*Arg, []*Call) {
return r.timespec(s, a, true)
}
- case "in6_addr":
- return func(r *randGen, s *state) (*Arg, []*Call) {
- return r.in6addr(s, a)
- }
- case "in_addr_any":
- return func(r *randGen, s *state) (*Arg, []*Call) {
- return r.inaddrany(s, a)
- }
}
return nil
}
@@ -718,8 +687,6 @@ func (r *randGen) generateArg(s *state, typ sys.Type) (arg *Arg, calls []*Call)
switch a.Kind {
case sys.IntSignalno:
v %= 130
- case sys.IntInaddr:
- v = uintptr(r.inaddr(s))
case sys.IntFileoff:
r.choose(
90, func() { v = 0 },
diff --git a/sys/decl.go b/sys/decl.go
index 0533c3770..65dcf4fb5 100644
--- a/sys/decl.go
+++ b/sys/decl.go
@@ -206,7 +206,6 @@ type IntKind int
const (
IntPlain IntKind = iota
IntSignalno
- IntInaddr
IntFileoff // offset within a file
IntRange
)
diff --git a/sys/sys.txt b/sys/sys.txt
index 76920b37e..6e0edada6 100644
--- a/sys/sys.txt
+++ b/sys/sys.txt
@@ -962,7 +962,7 @@ xfrm_userpolicy_info {
xfrm_user_tmpl {
id xfrm_id
fam int16
- saddr in_addr_any
+ saddr xfrm_in_addr
reqid int32
mode int8
share int8
@@ -973,8 +973,8 @@ xfrm_user_tmpl {
}
xfrm_selector {
- daddr in_addr_any
- saddr in_addr_any
+ daddr xfrm_in_addr
+ saddr xfrm_in_addr
dport proc[int16be, 20000, 4]
dmask int16
sport proc[int16be, 20000, 4]
@@ -1006,28 +1006,40 @@ xfrm_lifetime_cur {
}
xfrm_id {
- daddr in_addr_any
+ daddr xfrm_in_addr
spi int32
proto int8
}
-# in_addr or in6_addr
-# prog knows about this struct
-in_addr_any {
- a0 in_addr
- a1 int32
- a2 int32
- a3 int32
+xfrm_in_addr [
+ in in_addr
+ in6 in6_addr
+]
+
+in_addr [
+# 0.0.0.0
+ empty const[0x00000000, int32be]
+# 127.0.0.1
+ loopback const[0x7f000001, int32be]
+# 255.255.255.255
+ broadcast const[0xffffffff, int32be]
+}
+
+in6_addr_empty {
+ a0 const[0, int64be]
+ a1 const[0, int64be]
}
-# prog knows about this struct
-in6_addr {
- a0 int32
- a1 int32
- a2 int32
- a3 int32
+in6_addr_loopback {
+ a0 const[0, int64be]
+ a1 const[1, int64be]
}
+in6_addr [
+ empty in6_addr_empty
+ loopback in6_addr_loopback
+]
+
ipv6_mreq {
multi in6_addr
ifindex int32
diff --git a/sysgen/sysgen.go b/sysgen/sysgen.go
index 3e7c39949..59ab4e749 100644
--- a/sysgen/sysgen.go
+++ b/sysgen/sysgen.go
@@ -588,11 +588,6 @@ func generateArg(
failf("wrong number of arguments for %v arg %v, want %v, got %v", typ, name, want, len(a))
}
fmt.Fprintf(out, "&IntType{%v, TypeSize: 4, Kind: IntSignalno}", common())
- case "in_addr":
- if want := 0; len(a) != want {
- failf("wrong number of arguments for %v arg %v, want %v, got %v", typ, name, want, len(a))
- }
- fmt.Fprintf(out, "&IntType{%v, TypeSize: 4, Kind: IntInaddr}", common())
case "filename":
canBeArg = true
if want := 0; len(a) != want {