The below patch adds support to syslog-ng for supplying service names rather then port numbers. For example, with this you can have a config line along the lines of source foo { tcp(port(syslogng)); }; Should be fully backwards compatable, you can still use the numeric form. If anyone's interested. (I'd love to see this integrated into the main tree...) ---------------- diff -c src/afinet.c patched/afinet.c *** src/afinet.c Sun Jan 14 21:56:53 2001 --- patched/afinet.c Sun Jan 14 21:56:47 2001 *************** *** 45,53 **** } } ! void inet_address_setport(struct address_info **a, UINT32 port) { CAST(inet_address_info, addr, *a); if (!addr) { *a = &make_inet_address(NULL, port)->super; } --- 45,64 ---- } } ! void inet_address_setport(struct address_info **a, UINT32 port, ! const char *service, const char *proto) { + struct servent *srv; CAST(inet_address_info, addr, *a); + + if(!port) { + if((srv=getservbyname(service,proto))) { + port=srv->s_port; + } else { + werror("Error finding port for service %z. Falling back to default\n", service); + return; + } + } if (!addr) { *a = &make_inet_address(NULL, port)->super; } *************** *** 156,166 **** inet_address_setip(&source->bind_addr, ip); } ! void afinet_src_set_localport(struct log_source_driver *c, UINT32 port) { CAST_SUBTYPE(afsocket_source, source, c); ! inet_address_setport(&source->bind_addr, port); } void afinet_src_set_auth(struct log_source_driver *c, UINT32 v) --- 167,178 ---- inet_address_setip(&source->bind_addr, ip); } ! void afinet_src_set_localport(struct log_source_driver *c, UINT32 port, ! const char *service, const char *proto) { CAST_SUBTYPE(afsocket_source, source, c); ! inet_address_setport(&source->bind_addr, port, service, proto); } void afinet_src_set_auth(struct log_source_driver *c, UINT32 v) *************** *** 378,395 **** inet_address_setip(&dest->dest_addr, ip); } ! void afinet_dest_set_localport(struct log_dest_driver *c, UINT32 port) { CAST_SUBTYPE(afsocket_dest, dest, c); ! inet_address_setport(&dest->dest_addr, port); } ! void afinet_dest_set_destport(struct log_dest_driver *c, UINT32 port) { CAST_SUBTYPE(afsocket_dest, dest, c); ! inet_address_setport(&dest->dest_addr, port); } static int do_init_afinet_dest(struct log_handler *c, --- 390,409 ---- inet_address_setip(&dest->dest_addr, ip); } ! void afinet_dest_set_localport(struct log_dest_driver *c, UINT32 port, ! const char *service, const char *proto) { CAST_SUBTYPE(afsocket_dest, dest, c); ! inet_address_setport(&dest->dest_addr, port, service, proto); } ! void afinet_dest_set_destport(struct log_dest_driver *c, UINT32 port, ! const char *service, const char *proto) { CAST_SUBTYPE(afsocket_dest, dest, c); ! inet_address_setport(&dest->dest_addr, port, service, proto); } static int do_init_afinet_dest(struct log_handler *c, diff -c src/afsocket.h patched/afsocket.h *** src/afsocket.h Tue Nov 23 14:32:37 1999 --- patched/afsocket.h Sun Jan 14 21:54:36 2001 *************** *** 125,131 **** void afunix_set_group(struct log_source_driver *c, const char *group); void afunix_set_perm(struct log_source_driver *c, int perm); ! void afinet_src_set_localport(struct log_source_driver *c, UINT32 port); void afinet_src_set_localip(struct log_source_driver *c, const char *ip); void afinet_src_set_auth(struct log_source_driver *c, UINT32 v); void afinet_src_set_mac(struct log_source_driver *c, UINT32 v); --- 125,131 ---- void afunix_set_group(struct log_source_driver *c, const char *group); void afunix_set_perm(struct log_source_driver *c, int perm); ! void afinet_src_set_localport(struct log_source_driver *c, UINT32 port, const char *service,const char *proto); void afinet_src_set_localip(struct log_source_driver *c, const char *ip); void afinet_src_set_auth(struct log_source_driver *c, UINT32 v); void afinet_src_set_mac(struct log_source_driver *c, UINT32 v); *************** *** 132,139 **** void afinet_src_set_encrypt(struct log_source_driver *c, UINT32 v); void afinet_dest_set_localip(struct log_dest_driver *c, const char *ip); ! void afinet_dest_set_localport(struct log_dest_driver *c, UINT32 port); ! void afinet_dest_set_destport(struct log_dest_driver *c, UINT32 port); void afinet_dest_set_auth(struct log_dest_driver *c, UINT32 value); void afinet_dest_set_mac(struct log_dest_driver *c, UINT32 value); void afinet_dest_set_encrypt(struct log_dest_driver *c, UINT32 value); --- 132,139 ---- void afinet_src_set_encrypt(struct log_source_driver *c, UINT32 v); void afinet_dest_set_localip(struct log_dest_driver *c, const char *ip); ! void afinet_dest_set_localport(struct log_dest_driver *c, UINT32 port, const char *service,const char *proto); ! void afinet_dest_set_destport(struct log_dest_driver *c, UINT32 port, const char *service,const char *proto); void afinet_dest_set_auth(struct log_dest_driver *c, UINT32 value); void afinet_dest_set_mac(struct log_dest_driver *c, UINT32 value); void afinet_dest_set_encrypt(struct log_dest_driver *c, UINT32 value); diff -c src/cfg-grammar.y patched/cfg-grammar.y *** src/cfg-grammar.y Sun Jan 14 21:57:19 2001 --- patched/cfg-grammar.y Sun Jan 14 21:57:26 2001 *************** *** 72,78 **** %token KW_COMPRESS KW_MAC KW_AUTH KW_ENCRYPT /* filter items*/ ! %token KW_FACILITY KW_LEVEL KW_PROGRAM KW_HOST KW_MATCH /* yes/no switches */ %token KW_YES KW_NO --- 72,78 ---- %token KW_COMPRESS KW_MAC KW_AUTH KW_ENCRYPT /* filter items*/ ! %token KW_FACILITY KW_LEVEL KW_HOST KW_MATCH /* yes/no switches */ %token KW_YES KW_NO *************** *** 255,265 **** ; source_afinet_udp_option : KW_LOCALIP '(' string ')' { afinet_src_set_localip(last_source_driver, $3); free($3); } | KW_IP '(' string ')' { afinet_src_set_localip(last_source_driver, $3); free($3); } - | KW_LOCALPORT '(' NUMBER ')' { afinet_src_set_localport(last_source_driver, $3); } - | KW_PORT '(' NUMBER ')' { afinet_src_set_localport(last_source_driver, $3); } - ; source_afinet_tcp_params --- 255,270 ---- ; source_afinet_udp_option + : source_afinet_option + | KW_LOCALPORT '(' string ')' { afinet_src_set_localport(last_source_driver, 0, $3 ,"udp"); free($3); } + | KW_PORT '(' string ')' { afinet_src_set_localport(last_source_driver, 0, $3, "udp"); free($3); } + ; + + source_afinet_option : KW_LOCALIP '(' string ')' { afinet_src_set_localip(last_source_driver, $3); free($3); } + | KW_LOCALPORT '(' NUMBER ')' { afinet_src_set_localport(last_source_driver, $3, NULL, NULL); } + | KW_PORT '(' NUMBER ')' { afinet_src_set_localport(last_source_driver, $3, NULL, NULL); } | KW_IP '(' string ')' { afinet_src_set_localip(last_source_driver, $3); free($3); } source_afinet_tcp_params *************** *** 278,284 **** ; source_afinet_tcp_option ! : source_afinet_udp_option | KW_AUTH '(' tripleoption ')' { afinet_src_set_auth(last_source_driver, $3); } | KW_MAC '(' tripleoption ')' { afinet_src_set_mac(last_source_driver, $3); } | KW_ENCRYPT '(' tripleoption ')' { afinet_src_set_encrypt(last_source_driver, $3); } --- 283,291 ---- ; source_afinet_tcp_option ! : source_afinet_option ! | KW_LOCALPORT '(' string ')' { afinet_src_set_localport(last_source_driver, 0, $3,"tcp"); free($3); } ! | KW_PORT '(' string ')' { afinet_src_set_localport(last_source_driver, 0, $3,"tcp"); free($3); } | KW_AUTH '(' tripleoption ')' { afinet_src_set_auth(last_source_driver, $3); } | KW_MAC '(' tripleoption ')' { afinet_src_set_mac(last_source_driver, $3); } | KW_ENCRYPT '(' tripleoption ')' { afinet_src_set_encrypt(last_source_driver, $3); } *************** *** 428,440 **** | ; ! dest_afinet_udp_option : KW_LOCALIP '(' string ')' { afinet_dest_set_localip(last_dest_driver, $3); free($3); } ! | KW_LOCALPORT '(' NUMBER ')' { afinet_dest_set_localport(last_dest_driver, $3); } ! | KW_PORT '(' NUMBER ')' { afinet_dest_set_destport(last_dest_driver, $3); } ! | KW_DESTPORT '(' NUMBER ')' { afinet_dest_set_destport(last_dest_driver, $3); } ; dest_afinet_tcp_params : string { --- 435,454 ---- | ; ! dest_afinet_option : KW_LOCALIP '(' string ')' { afinet_dest_set_localip(last_dest_driver, $3); free($3); } ! | KW_LOCALPORT '(' NUMBER ')' { afinet_dest_set_localport(last_dest_driver, $3, NULL, NULL); } ! | KW_PORT '(' NUMBER ')' { afinet_dest_set_destport(last_dest_driver, $3, NULL, NULL); } ! | KW_DESTPORT '(' NUMBER ')' { afinet_dest_set_destport(last_dest_driver, $3, NULL, NULL); } ; + dest_afinet_udp_option + : dest_afinet_option + | KW_LOCALPORT '(' string ')' { afinet_dest_set_localport(last_dest_driver, 0, $3,"udp"); free($3); } + | KW_PORT '(' string ')' { afinet_dest_set_destport(last_dest_driver, 0, $3,"udp"); free($3); } + | KW_DESTPORT '(' string ')' { afinet_dest_set_destport(last_dest_driver, 0, $3,"udp"); free($3); } + ; + dest_afinet_tcp_params : string { *************** *** 452,458 **** ; dest_afinet_tcp_option ! : dest_afinet_udp_option | KW_MAC '(' yesno ')' | KW_AUTH '(' yesno ')' | KW_ENCRYPT '(' yesno ')' --- 466,475 ---- ; dest_afinet_tcp_option ! : dest_afinet_option ! | KW_LOCALPORT '(' string ')' { afinet_dest_set_localport(last_dest_driver, 0, $3,"tcp"); free($3); } ! | KW_PORT '(' string ')' { afinet_dest_set_destport(last_dest_driver, 0, $3,"tcp"); free($3); } ! | KW_DESTPORT '(' string ')' { afinet_dest_set_destport(last_dest_driver, 0, $3,"tcp"); free($3); } | KW_MAC '(' yesno ')' | KW_AUTH '(' yesno ')' | KW_ENCRYPT '(' yesno ')'