main.c
Aller à la documentation de ce fichier.00001 #include "global.h"
00002 #include "config.h"
00003 #include "xcache_l.h"
00004
00005 int main(void)
00006 {
00007 const unsigned char mac[6] = LOCAL_MAC;
00008 const unsigned char ip[4] = LOCAL_IP;
00009 const unsigned char subnet[4] = LOCAL_SUBNET;
00010 const unsigned char gateway[4] = LOCAL_GATEWAY;
00011
00012 #ifdef SERVER
00013 const short int port = LOCAL_PORT;
00014 #endif
00015 #ifdef CLIENT
00016 const unsigned char remote_ip[4] = REMOTE_IP;
00017 const short int remote_port = REMOTE_PORT;
00018 #endif //CLIENT
00019
00020 struct netif *netif = NULL;
00021 int ret_code = 0;
00022
00023
00024 print("\033[H\033[J");
00025
00026 lwip_init();
00027 print("Initialisation de lwIP : OK\n\r");
00028
00029 netif = lwip_config(mac, ip, subnet, gateway);
00030 if(NULL == netif)
00031 return -1;
00032 else
00033 print("Configuration de lwIP : OK\n\r");
00034
00035 xil_printf("\t@ MAC : %x:%x:%x:%x:%x:%x\n\r", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
00036 xil_printf("\t@ IP : %d.%d.%d.%d\n\r", ip[0], ip[1], ip[2], ip[3]);
00037 xil_printf("\tNetmask : %d.%d.%d.%d\n\r", subnet[0], subnet[1], subnet[2], subnet[3]);
00038 xil_printf("\tGateway : %d.%d.%d.%d\n\r", gateway[0], gateway[1], gateway[2], gateway[3]);
00039
00040 #ifdef SERVER
00041 ret_code = server_init(port);
00042 if(0 != ret_code)
00043 return -1;
00044 else
00045 print("Initialisation du serveur : OK\n\r");
00046
00047 xil_printf("\tPort : %d\n\r", port);
00048 #endif //SERVER
00049
00050 #ifdef CLIENT
00051 ret_code = client_init(remote_ip, remote_port);
00052 if(0 != ret_code)
00053 return -1;
00054 else
00055 print("Initialisation du client : OK\n\r");
00056
00057 xil_printf("\t@ IP distante : %d.%d.%d.%d\n\r", remote_ip[0], remote_ip[1], remote_ip[2], remote_ip[3]);
00058 xil_printf("\tPort distant : %d\n\r", remote_port);
00059 #endif //CLIENT
00060
00061 run(netif);
00062
00063
00064 return 0;
00065 }