Changes between Version 17 and Version 18 of Old/Libmac


Ignore:
Timestamp:
Jun 18, 2006, 11:20:14 PM (18 years ago)
Author:
kishore
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Old/Libmac

    v17 v18  
    101101[[Image(p3.png)]] [[BR]]
    102102
    103 The rest of the report will discuss the lowest module, implemented as the shared library, \textbf{Libmac~\cite{Libmac+manual}}.
     103The rest of this page will discuss the lowest module, implemented as the shared library, Libmac.
     104
     105=== Libmac API ===
     106
     107List of features implemented
     108
     109Features provided by this library include: \begin{enumerate}
     110\item Ethernet frame injection and capture.
     111\item Manipulation of a subset of wireless interface parameters at both aggregate and
     112per-packet levels of granularity.
     113\item Communication of a subset of wireless interface parameters from the sending end of a network
     114connection to the receiving end, on a per-packet granularity level.
     115\item Reception of the entire 802.11 frame, when the receiver is in RFMON mode.
     116\item Appending parameters to all incoming frames and using the pcap filters to receive only
     117those frames that the user of the library is interested in.
     118\end{enumerate}
     119
     120Driver-level support is required for features 2, 3 and 5. This support has been provided by modifying the
     121Cisco/Aironet driver (4500/4800/340/350 series cards) and the HostAP driver (v0.0.4) for wireless LAN cards
     122based on Intersil Prism2/2.5/3 chipset. Details of these modifications can be found in the documentation
     123that comes with the library.
     124
     125\subsection{Ethernet frame injection and capture}
     126
     127The usage paradigm, for sending or receiving frames using this library, is as follows:
     128\begin{enumerate}
     129\item Obtain parameter information using the mac\_get\_ifinfo function. The argument should be the address of a {NULL} pointer.
     130\item {OPTIONAL:} Allocate memory for, and initialize, the mac\_params and the mac\_params\_flags structures in case you are going
     131to use the mac\_get\_params or mac\_set\_params function. Use the mac\_init\_params function for the same. Again, the arguments
     132{SHOULD BE} addresses of {NULL} pointers.
     133\item {OPTIONAL:} Call any one of the parameter functions, mac\_get\_params or mac\_set\_params or mac\_append\_params.
     134\item For each frame that you want to send and depending on the destination address, either call mac\_send\_broadcast or
     135mac\_send\_unicast. \\For each frame that you want to recv, call mac\_recv. The double pointers, header,
     136payload, send\_parameter\_info and recv\_parameter\_info SHOULD BE addresses of {NULL} pointers. The pointer len, should be
     137the address of an unsigned short.
     138\item {OPTIONAL:} Free memory, if allocated, for the mac\_params and the mac\_pa-
     139rams\_flags structures using the mac\_free\_params function.
     140\item Free interface information using the mac\_free\_ifinfo before exiting. 
     141\end{enumerate}
     142
     143The function, \texttt{int mac\_get\_ifinfo (struct mac\_ifinfo **mac\_ptr)}, is used to obtain information on all existing interfaces.
     144It has one argument, which is a pointer to a linked list of structures. Each structure in the list contains members
     145which can store the name of interface, hardware address, ip address, whether the interface is wireless or not and other relevant
     146information. The information stored in these structures is used by the rest of the functions in the library. \newline
     147
     148Likewise, the function, \texttt{int mac\_free\_ifinfo (struct mac\_ifinfo \\
     149**mac\_ptr)}, is used to free the memory allocated for interface information.
     150It also has one argument, which is the pointer to the linked list of structures. \newline
     151
     152The function, \texttt{int mac\_send\_broadcast (u\_char *payload, short len, \\
     153struct mac\_ifinfo\_list *q)}, is used to assemble an ethernet frame with the specified payload
     154and broadcast (MAC-level) this frame. The first argument is the pointer to the payload,
     155the second one is the length of the payload and the third one is the structure containing
     156the name of the interface on which this frame needs to be sent. \newline
     157
     158The function, \texttt{int mac\_send\_unicast (u\_char *payload, short len, \\
     159struct mac\_ifinfo\_list *q, unsigned char *ucast\_mac)}, is used to
     160assemble an ethernet frame with the specified payload and send this frame
     161to a unicast MAC address. The first argument is the pointer to the payload,
     162the second one is the length of the payload, the third one is the structure
     163containing the name of the interface on which this frame needs to be sent and
     164the fourth argument is a pointer to the MAC address of the destination. \newline
     165
     166The function, \texttt{int mac\_recv (struct ether\_header **header, \\
     167char **payload, unsigned short *len, unsigned char **send\_params, \\
     168unsigned char **recv\_params, struct mac\_ifinfo\_list *q, char *filter)}, is used to receive
     169an ethernet frame. Its arguments include pointers to store ethernet header information, payload, length of the payload,
     170sending side parameters that have been appended, receiving side parameters that have been appended and the pcap~\cite{Libpcap+doc}
     171filter that is to applied. \newline
     172
     173Note that parameters are appended to all incoming frames and the pcap filters can be used to
     174receive only those frames that the user of the library is interested in.
     175
     176\subsection{Manipulation of a subset of wireless interface parameters at both aggregate and
     177per-packet levels of granularity}
     178
     179The function, \texttt{int mac\_get\_params (struct mac\_params *h, struct mac\_if-
     180info\_list *if\_ptr, int argc, ...)}, is used to request the driver to return information
     181on interface parameters, specified by the fourth argument onwards. The first argument
     182is the pointer to the mac\_params structure, where information, on retrieved parameter
     183values, is to be stored. The second one is a pointer to the struct mac\_ifinfo\_list
     184that specifies the interface to which, a call to this function, applies. The parameter
     185settings on the specified interface will be returned. The third argument is the number
     186of arguments that follow after this one. Each argument that follows corresponds to the
     187key of a parameter. \newline
     188
     189The function, \texttt{int mac\_set\_params (struct mac\_params *h, struct mac\_
     190ifinfo\_list *if\_ptr, int argc, ...)}, is used to request the driver to operate on
     191interface parameter settings, specified by the fourth argument onwards. The first
     192argument is the pointer to the mac\_params structure, where information, on parameter
     193settings, is stored. The second one is a pointer to the struct mac\_ifinfo\_list that
     194specifies the interface to which, a call to this function, applies. The parameter values
     195on the specified interface will be set. The third argument is the number of (key,value)
     196pairs that follow after this one.
     197
     198\subsection{Communication of a subset of wireless interface parameters from the sending end of a network
     199connection to the receiving end, on a per-packet granularity level}
     200
     201The function, \texttt{int mac\_append\_params (struct mac\_ifinfo\_list *if\_ptr, \\
     202unsigned char direction, int argc, ...)}, is used to request the driver to append
     203interface parameter information, specified by the fourth argument onwards. The first
     204argument is the pointer to the struct mac\_ifinfo\_list that specifies the interface
     205to which, a call to this function, applies. All outgoing/incoming frames on the specified
     206interface will have the specified parameters appended to them. The appending of parameters
     207can also be turned off. The second argument is a variable, direction, that indicates
     208whether parameters should be appended on outgoing and/or incoming frames. The third
     209argument is the number of arguments that follow after this one. Each argument that
     210follows corresponds to the key of a parameter that needs to be appended.
     211
     212\subsection{Reception of the entire 802.11 frame, when the receiver is in RFMON mode}
     213
     214The function, \texttt{int mac\_promisc\_recv (unsigned char **frame, unsigned short
     215*frame\_len, unsigned char **send\_params, unsigned char **recv\_params, struct mac\_
     216ifinfo\_list *q)}, is used to receive an 802.11 frame, in RFMON mode, on an interface
     217specified by the user, and retrieve pointers to the frame, length and parameters.
     218Its arguments include pointers to store the entire frame, length of the frame, sending side
     219parameters that have been appended, receiving side parameters that have been appended
     220and the structure that specifies the interface to which a call to this function applies. \newline
     221
     222Note that parameters are appended to all incoming 802.11 frames and current version of the library
     223does not parse the received frame to extract send-side parameter information that is appended.
     224
     225Detailed documentation on all these functions and their implementation details are included in every
     226release, which can be downloaded from /common/Orbit/repository. The interested reader is directed
     227to these for more information.
     228
    104229
    105230The architecture diagram is shown below - Libmac uses open-source libraries [http://www.tcpdump.org/ libpcap], for frame capture and [http://www.packetfactory.net/libnet/ libnet], for frame injection.