1 #include 2 #include 3 #include "netax25/ax25.h" 4 #include "netax25/axlib.h" 5 #include "netax25/axconfig.h" 6 #include "netax25/daemon.h" 7 // *** AX25 relevante Einstellungen *** 8 struct full_sockaddr_ax25 dest; 9 struct full_sockaddr_ax25 src; 10 char *addr, *portcall; 11 int ax25_Socket, n, dlen, len; 12 char srccall[7] = "DN4GB-1"; // eigenes Rufzeichen, muss mit axport & ax25d.config übereinstimmen 13 char destcall[5] = "DN4GB"; 14 char port[1] = "0"; // AX25 Portname / siehe axports und ax25d.config 15 // *** Initialisierung des AX25 Sockets *** 16 int ax25_init() 17 { 18 printf("AX25: Initialisierung... \n"); 19 // *** Überprüfung der AX25 Konfiguration / Sender / Empfänger / Port *** 20 if (ax25_config_load_ports() == 0) { 21 fprintf(stderr, "wsaprs: no AX.25 ports defined\n"); 22 return 1; 23 } 24 if ((portcall = ax25_config_get_addr(port)) == NULL) { 25 fprintf(stderr, "wsaprs: invalid AX.25 port setting - %s\n", port); 26 return 1; 27 } 28 addr = NULL; 29 if (destcall != NULL) 30 addr = strdup(destcall); 31 if (addr == NULL) 32 return 1; 33 if ((dlen = ax25_aton(addr, &dest)) == -1) { 34 fprintf(stderr, "wsaprs: unable to convert callsign '%s'\n", addr); 35 return 1; 36 } 37 if (addr != NULL) free(addr); addr = NULL; 38 if (srccall != NULL && strcmp(srccall, portcall) != 0) { 39 if ((addr = (char *) malloc(strlen(srccall) + 1 + strlen(portcall) + 1)) == NULL) 40 return 1; 41 sprintf(addr, "%s %s", srccall, portcall); 42 } else { 43 if ((addr = strdup(portcall)) == NULL) 44 return 1; 45 } 46 if ((len = ax25_aton(addr, &src)) == -1) { 47 fprintf(stderr, "wsaprs: unable to convert callsign '%s'\n", addr); 48 return 1; 49 } 50 if (addr != NULL) free(addr); addr = NULL; 51 // *** AX25 Socket initalisieren *** 52 printf("AX25: Socket erstellen... \n"); 53 if ((ax25_Socket = socket(AF_AX25, SOCK_DGRAM, 0)) == -1) { // Socket einrichten 54 return 1; 55 } 56 if (bind(ax25_Socket, (struct sockaddr *)&src, len) == -1) { // Socket binden 57 return 1; 58 } 59 }