OSDN Git Service

Ver.1.5.35 Modified comments
[opengate/opengate.git] / opengate / opengatesrv / get-mac.c
index a6b3c29..dd21709 100644 (file)
@@ -1,5 +1,6 @@
 /**************************************************
-opengate server main
+opengate server 
+module for getting the mac address corresponding to the given ip address
 
 Copyright (C) 1999 Opengate Project Team
 Written by Katsuhiko Eguchi, 2005 
@@ -24,9 +25,11 @@ Email: watanaby@is.saga-u.ac.jp
 
 #include       "opengatesrv.h"
 
-/********************/
-/* Get Mac Address  */
-/********************/
+/*************************************/
+/* Get Mac Address                   */
+/* if IPv4, get mac address from ARP */
+/* if IPv6, get mac address from NDP */
+/*************************************/
 void getMacAddr(char *clientAddr4, char *macAddr4, char *clientAddr6, char *macAddr6, int ipStatus)
 {
   switch(ipStatus){
@@ -53,23 +56,26 @@ void getMacAddr(char *clientAddr4, char *macAddr4, char *clientAddr6, char *macA
   return;
 }
 
-/************************************/
-/* arp form is reformed to ndp form */ 
-/* format macAddr for ndp or arp    */
-/* match the form of two program    */
-/* mac addr by arp 00:01:12:0b:..   */
-/* mac addr by ndp 0:1:12:b:..      */
-/************************************/
+/***********************************************/
+/* mac addr by ARP is 00:01:12:0b:..              */
+/* mac addr by NDP is 0:1:12:b:..                 */
+/* this function changes ARP form to NDP form  */
+/* in:  macAddr4 = ARP form                    */
+/* out: macAddr6 = NDP form                    */
+/***********************************************/
 void reFormatMacAddr(char* macAddr4, char* macAddr6)
 {
   char *strp = NULL;
   char delims[] = ":";
   char buf[ADDRMAXLN] = "";
 
+  /* initialize in-area(buf) and out-area(macAddr6) */
   strcpy(macAddr6,"");
   strcpy(buf,macAddr4);
+
+  /* following logic depends on the unclear function of [strtok] */
+  /* copy from buf to macAddr6 but preceding 0 is skipped */
   strp=strtok(buf,delims);
-  
   if(strncmp(strp,"0",1)==0){
     strp++;
     strcat(macAddr6,strp);
@@ -91,7 +97,8 @@ void reFormatMacAddr(char* macAddr4, char* macAddr6)
 }
 
 /**********************************************************/
-/* check the mac address form arp and ndp are same or not */
+/* check the mac address form ARP and NDP are same or not */
+/* in: macAddr4, macAddr6  out: TRUE=same, FALSE=not same */
 /**********************************************************/
 int isSameMacAddr(char* macAddr4, char* macAddr6){