A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C++ program to set network settings for IPv6 Network in Linux Devices
Q:

C++ program to set network settings for IPv6 Network in Linux Devices

0

C++ program to set network settings for IPv6 Network in Linux Devices

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Consider the program:

#include <iostream>
using namespace std;

#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>

//function to set IPv6 and Gateway
void setIPv6(char * ip,unsigned int prefix,char * gateway)
{
	char cmd[128]={0};
	char nwkInf[5]="eth0";
	
	sprintf(cmd,"ip addr flush dev %s",nwkInf);
	system(cmd); 
	
	memset(cmd,0x00,128);
	sprintf(cmd,"ip link set %s down",nwkInf);
	system(cmd); 
	
	memset(cmd,0x00,128);
	sprintf(cmd,"/sbin/ip -6 addr add %s/%d dev %s",ip,prefix,nwkInf);
	system(cmd); 

	memset(cmd,0x00,128);
	sprintf(cmd,"/sbin/route -A inet6 add default gw %s",gateway);
	system(cmd); 

	memset(cmd,0x00,128);
	sprintf(cmd,"ip link set %s up",nwkInf);
	system(cmd); 	
}

//main program
int main()
{
	//passing IPv6,prefix and Gateway
	setIPv6("fd18:6dc5:3dbc:ce24::5",64,"fd18:6dc5:3dbc:ce24::1");

	return 0;
}

Here, "fd18:6dc5:3dbc:ce24::5" is IP Address, 64 is prefix value and "fd18:6dc5:3dbc:ce24::1" Gateway.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now