How to resolve the algorithm MAC vendor lookup step by step in the REXX programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm MAC vendor lookup step by step in the REXX programming language

Table of Contents

Problem Statement

Every connected device around the world comes with a unique Media Access Control address, or a   MAC address. A common task a network administrator may come across is being able to identify a network device's manufacturer when given only a MAC address.

Interface with one (or numerous) APIs that exist on the internet and retrieve the device manufacturer based on a supplied MAC address. A MAC address that does not return a valid result should return the String "N/A".   An error related to the network connectivity or the API should return a null result. Many implementations on this page use http://api.macvendors.com/ which, as of 19th September 2021, is throttling requests. After only 2 calls, the following response is returned for all subsequent requests. If you are planning to use the same provider or going to run the examples on this page, consider building in a delay between two calls. {"errors":{"detail":"Too Many Requests","message":"Please slow down your requests or upgrade your plan at https://macvendors.com"}}

Let's start with the solution:

Step by Step solution about How to resolve the algorithm MAC vendor lookup step by step in the REXX programming language

Source code in the rexx programming language

/*REXX pgm shows a network device's manufacturer based on the Media Access Control addr.*/
win_command         = 'getmac'                   /*name of the Microsoft Windows command*/
win_command_options = '/v /fo list'              /*options  of     "        "       "   */
?3= 'Network Adapter:'                           /*search keywords for Network Adapter. */
?4= 'Physical Address:'                          /*   "       "     "  Physical Address.*/
upper ?3 ?4                                      /*uppercase in case for capitol letters*/
@.=;            @.0= 0                           /*just─in─case values for the keywords.*/
rc= 0                                            /*  "   "   "  value for the returnCode*/
address system win_command win_command_options   with   output stem @.  /*issue command.*/
if rc\==0  then do                               /*display an error if not successful.  */
                say
                say '***error*** from command: '     win_command     win_command_options
                say 'Return code was: '    rc
                say
                exit rc
                end
MACaddr=.                                        /*just─in─case value for the keyword.  */
maker=.                                          /*  "   "   "    "    "   "     "      */
           do j=1  for @.0;  $= @.j;  upper $    /*parse each of the possible responses.*/
           if left($, length(?3))=?3  then maker=   subword(@.j, 3)   /*is this the one?*/
           if left($, length(?4))=?4  then MACaddr= word(@.j, 3)      /* "   "   "   "  */
           end   /*k*/
                                                 /* [↑]  Now, display good or bad stuff.*/
if maker=. | MACaddr==.  then say 'MAC address manufacturer not found.'
                         else say 'manufacturer for MAC address  '  MACaddr "  is  " maker
exit 0                                           /*stick a fork in it,  we're all done. */


  

You may also check:How to resolve the algorithm Collections step by step in the Forth programming language
You may also check:How to resolve the algorithm Numerical integration/Gauss-Legendre Quadrature step by step in the Tcl programming language
You may also check:How to resolve the algorithm Cramer's rule step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Tau number step by step in the CLU programming language
You may also check:How to resolve the algorithm Send email step by step in the Fortran programming language