[fidl][go] Match events against one, or two ordinals

In preparation for the soft transition to generated ordinals, making it
possible for the Recv method of proxies to match against one, or
multiple ordinals. Using this odd varargs style to make it possible for
this code to be merged into garnet prior to any fidlgen changes, hence
needing the signature to be backward and forward compatible.

FIDL-425 #comment

Test: builds
Change-Id: I6c7b2c060b165fa64d4fab0ffd6f9d4c84e1306f
diff --git a/src/syscall/zx/fidl/interface.go b/src/syscall/zx/fidl/interface.go
index a3d5814..e1b2588 100644
--- a/src/syscall/zx/fidl/interface.go
+++ b/src/syscall/zx/fidl/interface.go
@@ -43,7 +43,7 @@
 type Proxy interface {
 	IsValid() bool
 	Send(ordinal uint32, req Payload) error
-	Recv(ordinal uint32, resp Payload) error
+	Recv(ordinal uint32, resp Payload, gen_ordinal ...uint32) error
 	Call(ordinal uint32, req Payload, resp Payload) error
 }
 
@@ -101,7 +101,7 @@
 }
 
 // Recv waits for an event and writes the response into the response payload.
-func (p *ChannelProxy) Recv(ordinal uint32, resp Payload) error {
+func (p *ChannelProxy) Recv(ordinal uint32, resp Payload, gen_ordinal ...uint32) error {
 	respb := messageBytesPool.Get().([]byte)
 	resph := messageHandlesPool.Get().([]zx.Handle)
 
@@ -132,7 +132,14 @@
 	if err := UnmarshalMessage(respb[:nb], resph[:nh], &header, resp); err != nil {
 		return err
 	}
-	if header.Ordinal != ordinal {
+	// TODO(FIDL-425): Remove temporary handling of two ordinals.
+	var expectedOrdinal bool
+	if len(gen_ordinal) == 0 {
+		expectedOrdinal = header.Ordinal == ordinal
+	} else {
+		expectedOrdinal = header.Ordinal == ordinal || header.Ordinal == gen_ordinal[0]
+	}
+	if !expectedOrdinal {
 		return newExpectError(ErrUnexpectedOrdinal, ordinal, header.Ordinal)
 	}
 	return nil
@@ -211,7 +218,7 @@
 }
 
 // Recv waits for an event and writes the response into the response payload.
-func (p *SocketControlProxy) Recv(ordinal uint32, resp Payload) error {
+func (p *SocketControlProxy) Recv(ordinal uint32, resp Payload, gen_ordinal ...uint32) error {
 	respb := messageBytesPool.Get().([]byte)
 
 	defer messageBytesPool.Put(respb)
@@ -240,7 +247,14 @@
 	if err := UnmarshalMessage(respb[:nb], nil, &header, resp); err != nil {
 		return err
 	}
-	if header.Ordinal != ordinal {
+	// TODO(FIDL-425): Remove temporary handling of two ordinals.
+	var expectedOrdinal bool
+	if len(gen_ordinal) == 0 {
+		expectedOrdinal = header.Ordinal == ordinal
+	} else {
+		expectedOrdinal = header.Ordinal == ordinal || header.Ordinal == gen_ordinal[0]
+	}
+	if !expectedOrdinal {
 		return newExpectError(ErrUnexpectedOrdinal, ordinal, header.Ordinal)
 	}
 	return nil