--- embedaddon/mpd/src/udp.c 2012/02/21 23:32:47 1.1 +++ embedaddon/mpd/src/udp.c 2023/09/27 11:08:01 1.1.1.3.2.1 @@ -31,7 +31,11 @@ #define UDP_MTU 2048 #define UDP_MRU 2048 - #define UDP_MAXPARENTIFS 256 +#ifndef SMALL_SYSTEM +#define UDP_MAXPARENTIFS 256 +#else +#define UDP_MAXPARENTIFS 64 +#endif struct udpinfo { struct { @@ -85,7 +89,7 @@ static void UdpDoClose(Link l); static void UdpShutdown(Link l); - static int UdpSetCommand(Context ctx, int ac, char *av[], void *arg); + static int UdpSetCommand(Context ctx, int ac, const char *const av[], const void *arg); static void UdpNodeUpdate(Link l); static int UdpListen(Link l); static int UdpUnListen(Link l); @@ -125,7 +129,7 @@ UdpSetCommand, NULL, 2, (void *) SET_ENABLE }, { "disable [opt ...]", "Disable option", UdpSetCommand, NULL, 2, (void *) SET_DISABLE }, - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; struct UdpIf { @@ -135,16 +139,13 @@ struct UdpIf { int csock; /* netgraph Control socket */ EventRef ctrlEvent; /* listen for ctrl messages */ }; -struct UdpIf UdpIfs[UDP_MAXPARENTIFS]; +static struct UdpIf UdpIfs[UDP_MAXPARENTIFS]; -int UdpListenUpdateSheduled=0; -struct pppTimer UdpListenUpdateTimer; - /* * INTERNAL VARIABLES */ - static struct confinfo gConfList[] = { + static const struct confinfo gConfList[] = { { 0, UDP_CONF_RESOLVE_ONCE, "resolve-once" }, { 0, 0, NULL }, }; @@ -268,7 +269,7 @@ UdpOpen(Link l) /* Setsockopt socket. */ ksso->level=SOL_SOCKET; ksso->name=SO_REUSEPORT; - ((int *)(ksso->value))[0]=1; + ((int *)(void *)(ksso->value))[0]=1; if (NgSendMsg(csock, path, NGM_KSOCKET_COOKIE, NGM_KSOCKET_SETOPT, &u, sizeof(u)) < 0) { Perror("[%s] can't setsockopt() %s node", @@ -354,10 +355,10 @@ UdpClose(Link l) static void UdpShutdown(Link l) { - UdpInfo const pi = (UdpInfo) l->info; + UdpInfo const pi = (UdpInfo) l->info; - if (pi->conf.fqdn_peer_addr) - Freee(pi->conf.fqdn_peer_addr); + if (pi->conf.fqdn_peer_addr) + Freee(pi->conf.fqdn_peer_addr); UdpDoClose(l); UdpUnListen(l); @@ -412,6 +413,7 @@ UdpOrigination(Link l) static int UdpIsSync(Link l) { + (void)l; return (1); } @@ -650,9 +652,9 @@ UdpListen(Link l) /* Make listening UDP socket. */ if (pi->If->self_addr.family==AF_INET6) { - pi->If->csock = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP); + pi->If->csock = socket(PF_INET6, socktype(SOCK_DGRAM), IPPROTO_UDP); } else { - pi->If->csock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); + pi->If->csock = socket(PF_INET, socktype(SOCK_DGRAM), IPPROTO_UDP); } (void)fcntl(pi->If->csock, F_SETFD, 1); @@ -730,7 +732,7 @@ UdpNodeUpdate(Link l) */ static int -UdpSetCommand(Context ctx, int ac, char *av[], void *arg) +UdpSetCommand(Context ctx, int ac, const char *const av[], const void *arg) { UdpInfo const pi = (UdpInfo) ctx->lnk->info; char **fqdn_peer_addr = &pi->conf.fqdn_peer_addr;