Example #1
0
 public static unsafe void Write32(byte[] arr, uint offset, bit32 value)
 {
     fixed(byte *p = &arr[offset])
     {
         *((uint *)p) = value.Value;
     }
 }
Example #2
0
 //action Set_nhop(out IPv4Address nextHop, // NOTE directioned parameters must be bound in the actions list specification (so not by api?)
 //                IPv4Address ipv4_dest, // NOTE directionless parameters bound by control plane
 //                PortId port)
 //{
 //  nextHop = ipv4_dest;
 //  headers.ip.ttl = headers.ip.ttl - 1;
 //  outCtrl.outputPort = port;
 //}
 private static void Set_nhop(TopPipe_Args args,
                              ref IPv4Address nextHop,
                              IPv4Address ipv4_dest,
                              PortId port)
 {
     nextHop                 = ipv4_dest;
     args.headers.ip.ttl     = new bit8((byte)(args.headers.ip.ttl.Value - 1));
     args.outCtrl.outputPort = port;
 }
Example #3
0
 public override void Extract(byte[] arr, uint offset)
 {
     version        = (bit4)BitHelper.ExtractBits(arr, offset * 8, 4);
     ihl            = (bit4)BitHelper.ExtractBits(arr, offset * 8 + 4, 4);
     diffserv       = BitHelper.Extract8(arr, offset + 1);
     totalLen       = BitHelper.Extract16(arr, offset + 2);
     identification = BitHelper.Extract16(arr, offset + 4);
     flags          = (bit3)BitHelper.ExtractBits(arr, offset + 48, 3);
     fragOffset     = BitHelper.ExtractBits(arr, offset + 51, 13);
     ttl            = BitHelper.Extract8(arr, offset + 8);
     protocol       = BitHelper.Extract8(arr, offset + 9);
     hdrChecksum    = BitHelper.Extract16(arr, offset + 10);
     srcAddr        = BitHelper.Extract32(arr, offset + 12);
     dstAddr        = BitHelper.Extract32(arr, offset + 16);
 }
Example #4
0
                public apply_result apply(TopPipe_Args args, IPv4Address nextHop)
                {
                    apply_result result;

                    ActionBase RA = table.Lookup(nextHop);

                    if (RA == null)
                    {
                        result = new apply_result(false, default_action.Action);
                    }
                    else
                    {
                        result = new apply_result(true, RA.Action);
                    }
                    //evaluate_and_copy_in_RA_args(RA);
                    //execute(RA);
                    //copy_out_RA_args(RA);
                    //copy_out_table_args(args);
                    RA.OnApply(args);
                    return(result);
                }
Example #5
0
            public void apply(ref Parsed_packet headers,
                              core.error parseError, // parser error
                              InControl inCtrl,      // input port
                              out OutControl outCtrl)
            {
                outCtrl = new OutControl(); // NOTE instantiate all out params to satisfy csc
                TopPipe_Args args = new TopPipe_Args(headers, parseError, inCtrl, outCtrl);

                IPv4Address nextHop = new IPv4Address(); // Have to instantiate ref params, more compact than using out params and instantiating at bottom

                if (parseError != error.NoError)
                {
                    Drop_action(args);
                    return;
                }

                ipv4_match.apply(args, ref nextHop);
                if (args.outCtrl.outputPort == DROP_PORT)
                {
                    return;
                }

                check_ttl.apply(args);
                if (args.outCtrl.outputPort == CPU_OUT_PORT)
                {
                    return;
                }

                dmac.apply(args, nextHop);
                if (args.outCtrl.outputPort == DROP_PORT)
                {
                    return;
                }

                smac.apply(args);

                // Copy params back out
                headers = args.headers;
                outCtrl = args.outCtrl;
            }
Example #6
0
                public apply_result apply(TopPipe_Args args, ref IPv4Address nextHop)
                {
                    // FIXME sort out copy-semantics for args

                    apply_result result;

                    // Would chain lookups here if multiple fields
                    ActionBase RA = table.Lookup(args.headers.ip.dstAddr);

                    if (RA == null)
                    {
                        result = new apply_result(false, default_action.Action);
                    }
                    else
                    {
                        result = new apply_result(true, RA.Action);
                    }
                    //evaluate_and_copy_in_RA_args(RA);
                    //execute(RA);
                    //copy_out_RA_args(RA);
                    //copy_out_table_args(args);
                    RA.OnApply(args, ref nextHop);
                    return(result);
                }
Example #7
0
 public override void OnApply(TopPipe_Args args, ref IPv4Address nextHop) // FIXME need to bind parameters from control plane...
 {
     Set_nhop(args, ref nextHop, ipv4_dest, port);
 }
Example #8
0
 public Set_nhop_Action(IPv4Address ipv4_dest, PortId port) : base(action_list.Set_nhop)
 {
     this.ipv4_dest = ipv4_dest;
     this.port      = port;
 }
Example #9
0
 public override void OnApply(TopPipe_Args args, ref IPv4Address nextHop)
 {
     // FIXME this action doesn't actually set the out param - how do we handle that?
     Drop_action(args);
 }
Example #10
0
 public abstract void OnApply(TopPipe_Args args, ref IPv4Address nextHop);