Skip to content

Instantly share code, notes, and snippets.

@c2h2
Created July 13, 2013 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c2h2/5989540 to your computer and use it in GitHub Desktop.
Save c2h2/5989540 to your computer and use it in GitHub Desktop.
am335x_cpsw_switch fail
#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