Created
July 13, 2013 05:34
-
-
Save c2h2/5989540 to your computer and use it in GitHub Desktop.
am335x_cpsw_switch fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <linux/net_switch_config.h> | |
#include <asm/sockios.h> | |
#include <net/if.h> | |
#include <string.h> | |
#include <linux/sockios.h> | |
#include <errno.h> | |
int main(void) | |
{ | |
struct net_switch_config cmd_struct; | |
struct ifreq ifr; | |
int sockfd; | |
strncpy(ifr.ifr_name, "eth0", IFNAMSIZ); | |
ifr.ifr_data = (char*)&cmd_struct; | |
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { | |
printf("Can't open the socket\n"); | |
return -1; | |
} | |
memset(&cmd_struct, 0, sizeof(struct net_switch_config)); | |
//initialise cmd_struct with switch commands | |
if (ioctl(sockfd, SIOCSWITCHCONFIG, &ifr) < 0) { | |
printf("Command failed\n"); | |
close(sockfd); | |
return -1; | |
} | |
printf("command success\n"); | |
close(sockfd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment