示例#1
0
        public static BgpMessage Create(byte[] data, int offset)
        {
            var bgpHeaderLength = 19;

            var        msgHeader = new BgpHeader(data, offset);
            BgpMessage msg;

            switch (msgHeader.Type)
            {
            case BgpMessageType.Open:
                msg = new BgpOpenMessage();
                break;

            case BgpMessageType.Update:
                msg = new BgpUpdateMessage();
                break;

            case BgpMessageType.Notification:
                msg = new BgpNotificationMessage();
                break;

            case BgpMessageType.Keepalive:
                msg = new BgpKeepAliveMessage();
                break;

            case BgpMessageType.RouteRefresh:
                msg = new BgpRouteRefreshMessage();
                break;

            default:
                return(null);
            }

            msg.Header = msgHeader;
            offset    += bgpHeaderLength;

            msg.Decode(data, offset);
            return(msg);
        }
示例#2
0
 public override void Decode(byte[] data, int offset)
 {
     BgpUpdate = BgpMessage.Create(data, offset) as BgpUpdateMessage;
 }