William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 1 | SUMMARY = "Configures the gbmc bridge and filter rules" |
| 2 | PR = "r1" |
| 3 | LICENSE = "Apache-2.0" |
| 4 | LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" |
| 5 | |
| 6 | inherit systemd |
| 7 | |
| 8 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 9 | SRC_URI += " \ |
| 10 | file://-bmc-gbmcbr.netdev.in \ |
| 11 | file://-bmc-gbmcbr.network \ |
| 12 | file://-bmc-gbmcbrdummy.netdev \ |
| 13 | file://-bmc-gbmcbrdummy.network \ |
| 14 | file://+-bmc-gbmcbrusb.network \ |
| 15 | file://ipmi.service.in \ |
| 16 | file://50-gbmc-br.rules \ |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame^] | 17 | file://gbmc-br-ula.sh \ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 18 | " |
| 19 | |
| 20 | FILES_${PN}_append = " \ |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame^] | 21 | ${datadir}/gbmc-ip-monitor \ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 22 | ${systemd_unitdir}/network \ |
| 23 | ${sysconfdir}/nftables \ |
| 24 | ${sysconfdir}/avahi/services \ |
| 25 | " |
| 26 | |
| 27 | RDEPENDS_${PN}_append = " \ |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame^] | 28 | gbmc-ip-monitor \ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 29 | mstpd-mstpd \ |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame^] | 30 | network-sh \ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 31 | " |
| 32 | |
| 33 | GBMC_BR_MAC_ADDR ?= "" |
| 34 | |
| 35 | # Generated via https://cd34.com/rfc4193/ based on a MAC from a machine I own |
| 36 | # and we allocated it downstream. Intended to only be used within a complete |
| 37 | # system of multiple network endpoints. |
| 38 | GBMC_ULA_PREFIX = "fdb5:0481:10ce:0" |
| 39 | |
| 40 | def mac_to_eui64(mac): |
| 41 | if not mac: |
| 42 | return '' |
| 43 | b = [int(c, 16) for c in mac.split(':')] |
| 44 | b[0] ^= 2 |
| 45 | b.insert(3, 0xfe) |
| 46 | b.insert(3, 0xff) |
| 47 | idx = range(0, len(b)-1, 2) |
| 48 | return ':'.join([format((b[i] << 8) + b[i+1], '04x') for i in idx]) |
| 49 | |
| 50 | do_install() { |
| 51 | netdir=${D}${systemd_unitdir}/network |
| 52 | install -d -m0755 $netdir |
| 53 | |
| 54 | if [ ! -z "${GBMC_BR_MAC_ADDR}" ]; then |
| 55 | sed -i 's,@MAC@,MACAddress=${GBMC_BR_MAC_ADDR},' ${WORKDIR}/-bmc-gbmcbr.netdev.in |
| 56 | addr=${GBMC_ULA_PREFIX}:${@mac_to_eui64(GBMC_BR_MAC_ADDR)}/64 |
| 57 | sed -i "s,@ADDR@,Address=$addr," ${WORKDIR}/-bmc-gbmcbr.netdev.in |
| 58 | else |
| 59 | sed -i '/@MAC@/d' ${WORKDIR}/-bmc-gbmcbr.netdev.in |
| 60 | sed -i '/@ADDR@/d' ${WORKDIR}/-bmc-gbmcbr.netdev.in |
| 61 | fi |
| 62 | |
| 63 | install -m0644 ${WORKDIR}/-bmc-gbmcbr.netdev.in $netdir/-bmc-gbmcbr.netdev |
| 64 | install -m0644 ${WORKDIR}/-bmc-gbmcbr.network $netdir/ |
| 65 | install -m0644 ${WORKDIR}/-bmc-gbmcbrdummy.netdev $netdir/ |
| 66 | install -m0644 ${WORKDIR}/-bmc-gbmcbrdummy.network $netdir/ |
| 67 | install -m0644 ${WORKDIR}/+-bmc-gbmcbrusb.network $netdir/ |
| 68 | |
| 69 | nftables_dir=${D}${sysconfdir}/nftables |
| 70 | install -d -m0755 "$nftables_dir" |
| 71 | install -m0644 ${WORKDIR}/50-gbmc-br.rules $nftables_dir/ |
| 72 | |
| 73 | avahi_dir=${D}${sysconfdir}/avahi/services |
| 74 | install -d -m 0755 "$avahi_dir" |
| 75 | sed -i 's,@MACHINE@,${MACHINE},g' ${WORKDIR}/ipmi.service.in |
| 76 | sed -i 's,@EXTRA_ATTRS@,,g' ${WORKDIR}/ipmi.service.in |
| 77 | sed 's,@NAME@,bmc,g' ${WORKDIR}/ipmi.service.in >${avahi_dir}/bmc.ipmi.service |
| 78 | sed 's,@NAME@,${MACHINE}-bmc,g' ${WORKDIR}/ipmi.service.in >${avahi_dir}/${MACHINE}-bmc.ipmi.service |
William A. Kennington III | b08a9e6 | 2021-04-26 12:43:43 -0700 | [diff] [blame^] | 79 | |
| 80 | mondir=${D}${datadir}/gbmc-ip-monitor |
| 81 | install -d -m0755 "$mondir" |
| 82 | install -m0644 ${WORKDIR}/gbmc-br-ula.sh "$mondir"/ |
William A. Kennington III | 832f02b | 2021-04-23 12:53:36 -0700 | [diff] [blame] | 83 | } |