manuf.c

Go to the documentation of this file.
00001 /*
00002  * File : manuf.c
00003  * Project : WifiScanner (c) 2002 Hervé Schauer Consultants
00004  * Usage : This utility is written for use with IEEE 802.11 adapters based
00005  * on Intersil's PRISM II chipset (PCMCIA).
00006  * 
00007  * Base code was from prismstumbler Jan Fernquist <Jan.B.Fernquist@telia.com>
00008  * and wlanctl from www.linux-wlan.org
00009  *
00010  * This program is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU General Public License
00012  * as published by the Free Software Foundation; either version 2
00013  * of the License, or (at your option) any later version.
00014  * 
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023  *
00024  * $Id: manuf.c 168 2007-07-16 08:37:47Z poggij $
00025  */
00026 
00027 
00028 #include <include.h>
00029 #include <src/manuf.h>
00030 #include <src/manuf_table.h>
00031 
00032 /*
00033 */
00034 
00035 char *AddMacToManufName(char AddMac[WLAN_ADDR_LEN])
00036 {
00037 // TODO : Optimize ME !
00038   UINT16 i;
00039   UINT32 MAC;
00040 
00041 #ifdef WORDS_BIGENDIAN
00042   // Not Intel code
00043   MAC = (UINT32) AddMac;
00044 #else
00045   // Intel code dependant
00046   MAC =
00047       (UINT32) (((AddMac[3])) + ((AddMac[2]) << 8) +
00048                 ((AddMac[1]) << 16) + ((AddMac[0]) << 24));
00049 #endif
00050   for (i = 0; i < SIZE_OF_MANUF_TABLE; i++) {
00051     if (MAC == manuf_mac_table[i]) {
00052       break;
00053     }
00054   }
00055   // If we didn't find manuf, we search with a little mask
00056   if (i == SIZE_OF_MANUF_TABLE) {
00057 #ifdef WORDS_BIGENDIAN
00058     // Not Intel code
00059     MAC = (UINT32) (AddMac && 0xFFFFFF00);
00060 #else
00061     // Intel code dependant
00062     MAC =
00063         (UINT32) (((AddMac[2]) << 8) + ((AddMac[1]) << 16) +
00064                   ((AddMac[0]) << 24));
00065 #endif
00066     for (i = 0; i < SIZE_OF_MANUF_TABLE; i++) {
00067       if (MAC == manuf_mac_table[i]) {
00068         break;
00069       }
00070     }
00071 
00072   }
00073   return ((char *) manuf_name_table[i]);
00074 }
00075 
00076 char *AddMacToManufModel(char *AddMac)
00077 {
00078 // TODO : Optimize ME !
00079   UINT16 i;
00080   UINT32 MAC;
00081 
00082 #ifdef WORDS_BIGENDIAN
00083   // Not Intel code
00084   MAC = (UINT32) AddMac;
00085 #else
00086   // Intel code dependant
00087   MAC =
00088       (UINT32) (((AddMac[3])) + ((AddMac[2]) << 8) +
00089                 ((AddMac[1]) << 16) + ((AddMac[0]) << 24));
00090 #endif
00091   for (i = 0; i < SIZE_OF_MANUF_TABLE; i++) {
00092     if (MAC == manuf_mac_table[i]) {
00093       break;
00094     }
00095   }
00096   // If we didn't find manuf, we search with a more little mask
00097   if (i == SIZE_OF_MANUF_TABLE) {
00098 #ifdef WORDS_BIGENDIAN
00099     // Not Intel code
00100     MAC = (UINT32) (AddMac && 0xFFFFFF00);
00101 #else
00102     // Intel code dependant
00103     MAC =
00104         (UINT32) (((AddMac[2]) << 8) + ((AddMac[1]) << 16) +
00105                   ((AddMac[0]) << 24));
00106 #endif
00107     for (i = 0; i < SIZE_OF_MANUF_TABLE; i++) {
00108       if (MAC == manuf_mac_table[i]) {
00109         break;
00110       }
00111     }
00112 
00113   }
00114   return ((char *) manuf_model_table[i]);
00115 }

Generated on Fri Jul 25 17:10:34 2008 for WifiScanner by  doxygen 1.5.5