diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rwxr-xr-x | stap-client | 74 |
2 files changed, 59 insertions, 28 deletions
@@ -1,8 +1,21 @@ +2008-06-02 <brolley@redhat.com> + + * stap-client (initialization): port is no longer hard coded. + Initialize avahi_service_tag to _stap._tcp. + (find_and_connect_to_server): Handle server/port returned by + match_server. + (match_server): Obtain server ip address and port from output + of the -r option to avahi-browse. Echo a server/port pair. + 2008-06-02 Zhaolei <zhaolei@cn.fujitsu.com> * main.cxx (main): Fix the problem that kernel module compile failure when runtime directory is set to relative path(stap -R). +2008-05-30 Dave Brolley <brolley@redhat.com> + + * stap-client, stap-server: New compile server and client scripts. + 2008-05-30 Srinivasa DS <srinivasa@in.ibm.com> PR 6562 * tapsets.cxx, translate.cxx: modified one argument for diff --git a/stap-client b/stap-client index 53f33e33..42402a27 100755 --- a/stap-client +++ b/stap-client @@ -23,7 +23,7 @@ function configuration { tmpdir_prefix_client=stap.client tmpdir_prefix_server=stap.server - port=65000 + avahi_service_tag=_stap._tcp } # function: initialization @@ -442,10 +442,13 @@ function unpack_response { # Find and establish connection with a compatibale stap server. function find_and_connect_to_server { # Find a server - server=`avahi-browse --all --terminate | match_server` + server=`avahi-browse $avahi_service_tag --terminate -r 2>/dev/null | match_server` test "X$server" != "X" || \ fatal "ERROR: cannot find a server" + port=`expr "$server" : '[^/]*/\(.*\)'` + server=`expr "$server" : '\([^/]*\)/.*'` + # Open a connection to the server if ! exec 3<> /dev/tcp/$server/$port; then fatal "ERROR: cannot connect to server at /dev/tcp/$server/$port" @@ -462,45 +465,60 @@ function match_server { while read do # Examine the next service descriptor - avahi_service=$REPLY - # Is it a stap server? - server_name=`expr "$avahi_service" : '\+.*stap.*on \([^ ]*\).*'` - if test "X$server_name" = "X"; then - continue - fi + (echo $REPLY | grep -q "^=.*_stap") || continue + + # Get the details of the service + local service_tag equal data + while read service_tag equal service_data + do + case $service_tag in + '=' ) + break ;; + hostname ) + server_name=`expr "$service_data" : '\[\([^]]*\)\]'` + ;; + address ) + # Sometimes (seems random), avahi-resolve-host-name resolves a local server to its + # hardware address rather its ip address. Keep trying until we get + # an ip address. + server_ip=`expr "$service_data" : '\[\([^]]*\)\]'` + local attempt + for ((attempt=0; $attempt < 5; ++attempt)) + do + server_ip=`expr "$server_ip" : '^\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)$'` + if test "X$server_ip" != "X"; then + break + fi + # Resolve the server.domain to an ip address. + server_ip=`avahi-resolve-host-name $hostname` + server_ip=`expr "$server_ip" : '.* \(.*\)$'` + done + ;; + port ) + port=`expr "$service_data" : '\[\([^]]*\)\]'` + ;; + txt ) + sysinfo_server=`expr "$service_data" : '\[\"\([^]]*\)\"\]'` + sysinfo_server=`expr "$sysinfo_server" : '[^/]*/\(.*\)'` + ;; + * ) + break ;; + esac + done # It is a stap server, but is it compatible? - sysinfo_server=`expr "$avahi_service" : '\+.*stap[^/]*/\(.*\) on.*'` sysinfo_server="stap $sysinfo_server" if test "$sysinfo_server" != "`client_sysinfo`"; then continue fi - # Now resolve the server's ip address. First find the domain. - domain_name=`expr "$avahi_service" : '\+.* \([^ ]*\)$'` - - # Sometimes (seems random), avahi-resolve-host-name resolves a local server to its - # hardware address rather its ip address. Keep trying until we get - # an ip address. - local attempt - for ((attempt=0; $attempt < 5; ++attempt)) - do - # Resolve the server.domain to an ip address. - server=`avahi-resolve-host-name $server_name.$domain_name` - server=`expr "$server" : '.* \(.*\)$'` - - server_ip=`expr "$server" : '^\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)$'` - if test "X$server_ip" != "X"; then - break - fi - done if test "X$server_ip" != "X"; then break fi done - echo $server_ip + echo $server_ip/$port } # function: disconnect_from_server |