/**************************************************
-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
#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){
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);
}
/**********************************************************/
-/* 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){