#get MAC vendor from online source. For RouterOS (working in v 6.49) D de Castro June 2023 #checks if vendor name is already listed in the environmental variables, if not gets it by lookup #-------------- #function #uses macvendors.com for the lookup #thanks to rextended at https://forum.mikrotik.com/viewtopic.php?f=9&t=178435&p=879152#p879152 #sample call to this function: ':local newValue [ $getVendor thisMACAddress ]' :local getVendor do={ :local OUI ([:pick $1 0 2].[:pick $1 3 5].[:pick $1 6 8]); #calculate the OUI [parse ":global $OUI"]; :if ([:len [[:parse ":global $OUI; :return \$$OUI"]]] >0 ) do={ #if vendor already known :return ([[:parse ":global $OUI; :return \$$OUI"]]); } else={ :local onlineSource "https://api.macvendors.com/"; #otherwise look vendor up :do { :local vendorData ([/tool fetch url=( $onlineSource . $1 ) output=user as-value]); :delay 150ms; :local vendorOutput ( $vendorData->"data" ); [:parse "global $OUI;:set $OUI \"$vendorOutput\""]; #otherwise add to env. :return $vendorOutput; } on-error={ [:parse "global $OUI;:set $OUI \"unknown\""]; #error if no response :return "unobtainable"; } } } #-------------- #sample call to function :local MACAddress "20:c9:d0:95:d3:f9"; #The MAC address we want to find out about :local result [ $getVendor $MACAddress ]; #function call: note square brackets, function name, args $1, $2.... :local MACAnnounce ("Device vendor is " . $result . "."); #--------------