(hdr *Header, data []byte, software Software)
| 3737 | } |
| 3738 | |
| 3739 | func parseMessage(hdr *Header, data []byte, software Software) (m *Message, err error) { |
| 3740 | m = &Message{Header: *hdr} |
| 3741 | /* TODO: |
| 3742 | InterfaceNBRAddressAdd, InterfaceNBRAddressDelete, |
| 3743 | InterfaceBFDDestUpdate, ImportCheckUpdate, BFDDestReplay, |
| 3744 | InterfaceVRFUpdate, InterfaceLinkParams, PWStatusUpdate |
| 3745 | */ |
| 3746 | command := m.Header.Command.ToCommon(m.Header.Version, software) |
| 3747 | switch command { |
| 3748 | case interfaceAdd, interfaceDelete, interfaceUp, interfaceDown: |
| 3749 | m.Body = &interfaceUpdateBody{} |
| 3750 | case interfaceAddressAdd, interfaceAddressDelete: |
| 3751 | m.Body = &interfaceAddressUpdateBody{} |
| 3752 | case routerIDUpdate: |
| 3753 | m.Body = &routerIDUpdateBody{} |
| 3754 | case nexthopUpdate: |
| 3755 | m.Body = &NexthopUpdateBody{} |
| 3756 | case RedistributeRouteAdd, RedistributeRouteDel: // for frr |
| 3757 | m.Body = &IPRouteBody{API: m.Header.Command} |
| 3758 | case labelManagerConnect: // Note: Synchronous message |
| 3759 | m.Body = &labelManagerConnectBody{} |
| 3760 | case getLabelChunk: // Note: Synchronous message |
| 3761 | m.Body = &GetLabelChunkBody{} |
| 3762 | case releaseLabelChunk: // Note: Synchronous message |
| 3763 | m.Body = &releaseLabelChunkBody{} |
| 3764 | case vrfLabel: |
| 3765 | m.Body = &vrfLabelBody{} |
| 3766 | case RouteAdd, RouteDelete, BackwardIPv6RouteAdd, BackwardIPv6RouteDelete: // for quagga |
| 3767 | m.Body = &IPRouteBody{API: m.Header.Command} |
| 3768 | case ipv4NexthopLookupMRIB: |
| 3769 | m.Body = &lookupBody{api: m.Header.Command} |
| 3770 | default: |
| 3771 | m.Body = &unknownBody{} |
| 3772 | if m.Header.Version == 4 { |
| 3773 | switch m.Header.Command { |
| 3774 | case zapi4RedistributeIPv6Add, zapi4RedistributeIPv6Del: // for frr3 |
| 3775 | m.Body = &IPRouteBody{API: m.Header.Command} |
| 3776 | } |
| 3777 | } else if m.Header.Version < 4 { |
| 3778 | switch m.Header.Command { |
| 3779 | case zapi3IPv4NexthopLookup, zapi3IPv6NexthopLookup, zapi3IPv4ImportLookup: |
| 3780 | m.Body = &lookupBody{api: m.Header.Command} |
| 3781 | } |
| 3782 | } |
| 3783 | } |
| 3784 | return m, m.Body.decodeFromBytes(data, m.Header.Version, software) |
| 3785 | } |
searching dependent graphs…