Wednesday, July 17, 2019

HyperV Network Configuration


11)      how to create network adapter for hyper-v
a.      select virtual switch manager for creating a network adapter.

b.      create new virtual switch: select the option external for selecting network adapter and select create virtual switch.


c.       select the adapter


22)      adding network adaptor to virtual machine:
a.      select setting under virtual machine(imported ubuntu): select add hardware-> network adapter->add



b.      add will open network adapter: enable virtual LAN identification, enter number of port required. Press apply and ok  


33)      switch on VM , you can see two adapter. From your ubuntu we can specify different ip address for that.

Tuesday, August 3, 2010

C Replace String Example

#include
#include

char *replace(char *st, char *orig, char *repl) {
static char buffer[4096];
char *ch;
if (!(ch = strstr(st, orig)))
return st;
strncpy(buffer, st, ch-st);
buffer[ch-st] = 0;
sprintf(buffer+(ch-st), "%s%s", repl, ch+strlen(orig));
return buffer;
}
void main() {
puts(replace("Hello world!", "world", "India"));
}

Detecting MAC Address using C application

#include 
#include
#include
#include
#include

#ifdef Linux
#include
#include
#include
#include
#include
#endif

#ifdef HPUX
#include
#endif

#ifdef AIX
#include
#include
#endif

long mac_addr_sys ( u_char *addr)
{
/* implementation for Linux */
#ifdef Linux
struct ifreq ifr;
struct ifreq *IFR;
struct ifconf ifc;
char buf[1024];
int s, i;
int ok = 0;

s = socket(AF_INET, SOCK_DGRAM, 0);
if (s==-1) {
return -1;
}

ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
ioctl(s, SIOCGIFCONF, &ifc);

IFR = ifc.ifc_req;
for (i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; IFR++) {

strcpy(ifr.ifr_name, IFR->ifr_name);
if (ioctl(s, SIOCGIFFLAGS, &ifr) == 0) {
if (! (ifr.ifr_flags & IFF_LOOPBACK)) {
if (ioctl(s, SIOCGIFHWADDR, &ifr) == 0) {
ok = 1;
break;
}
}
}
}

close(s);
if (ok) {
bcopy( ifr.ifr_hwaddr.sa_data, addr, 6);
}
else {
return -1;
}
return 0;
#endif

/* implementation for HP-UX */
#ifdef HPUX

#define LAN_DEV0 "/dev/lan0"

intfd;
struct fisiocnt_block;
inti;
charnet_buf[sizeof(LAN_DEV0)+1];
char*p;

(void)sprintf(net_buf, "%s", LAN_DEV0);
p = net_buf + strlen(net_buf) - 1;

/*
* Get 802.3 address from card by opening the driver and interrogating it.
*/
for (i = 0; i < 10; i++, (*p)++) {
if ((fd = open (net_buf, O_RDONLY)) != -1) {
iocnt_block.reqtype = LOCAL_ADDRESS;
ioctl (fd, NETSTAT, &iocnt_block);
close (fd);

if (iocnt_block.vtype == 6)
break;
}
}

if (fd == -1 || iocnt_block.vtype != 6) {
return -1;
}

bcopy( &iocnt_block.value.s[0], addr, 6);
return 0;

#endif /* HPUX */

/* implementation for AIX */
#ifdef AIX

int size;
struct kinfo_ndd *nddp;

size = getkerninfo(KINFO_NDD, 0, 0, 0);
if (size <= 0) {
return -1;
}
nddp = (struct kinfo_ndd *)malloc(size);

if (!nddp) {
return -1;
}
if (getkerninfo(KINFO_NDD, nddp, &size, 0) < 0) {
free(nddp);
return -1;
}
bcopy(nddp->ndd_addr, addr, 6);
free(nddp);
return 0;
#endif

/* Not implemented platforms */
return -1;
}

/***********************************************************************/
/*
* Main (only for testing)
*/
#ifdef MAIN
int main( int argc, char **argv)
{
long stat;
int i;
u_char addr[6];

stat = mac_addr_sys( addr);
if (0 == stat) {
printf( "MAC address = ");
for (i=0; i<6; ++i) {
printf("%2.2x", addr[i]);
}
printf( "\n");
}
else {
fprintf( stderr, "can't get MAC address\n");
exit( 1);
}
return 0;
}
#endif

E.g you want to use on Linux, save it as file.c simply compile like this:

   gcc -O2 -DMAIN -DLinux file.c -o file

And run it

./file
MAC address = 0008c7e9e386

Compare with /sbin/ifconfig result:

/sbin/ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:08:C7:E9:E3:86
inet addr:***.***.***.*** Bcast:***.***.***.*** Mask:255.255.255.0
inet6 addr: ********************* Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:265555947 errors:0 dropped:0 overruns:0 frame:0
TX packets:50507373 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4090310752 (3.8 GiB) TX bytes:1085018636 (1.0 GiB)

It’s the same :)

Tuesday, July 13, 2010

advanced programming in the Unix environment

Advanced Programming in the UNIX Environment, Addison-Wesley, 1992, ISBN 0-201-56317-7.
Here i added the example code please click here

Monday, June 7, 2010

RFID Card READER

we designed and built (and exhaustively tested) an RFID-based proximity security system for use with Cornell Identification cards, which have been RFID-embedded since fall of 2003. The idea for this project was sort of spawned from our general interest in RFID technologies and the near-simultaneous occurance of Lab 2 (Keypad Security System) and the antiquated lock system at our fraternity house breaking.

MORE DETAILS

Thursday, June 3, 2010

list of access control system manufacturer

I have a good list of access control system manufacturer. Below list will help you to select good device.

  1. SOLUS
  2. SYRIS
  3. ELECTRON INDIA
  4. BOSCH
  5. HONEYWELL

List of Online Shopping Electronic Product website

The below Website will help you to buy Electronic product.
  1. CHIPSILICON
  2. DIGIKEY
  3. ALIBABA
  4. TENET TECHNOLOGIES