DBA > Job Interview Questions > Sybase Interview Questions and Answers

How do I interpret the tli strings in the interf

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

How do I interpret the tli strings in the interface file?

The tli string contained with Solaris interface files is a hex string containing port and IP address. If you have an entry

master tli tcp /dev/tcp \x000204018196c4510000000000000000

Then it can be interpreted as follows:
x0002 no user interpretation (header info?)
0401 port number (1025 decimal)
81 first part of IP address (129 decimal)
96 second part of IP address (150 decimal)
c4 third part of IP address (196 decimal)
51 fourth part of IP address (81 decimal)

So, the above tli address is equivalent to
master tcp ether sybhost 1025

where sybhost's IP address is

The following piece of Sybperl (courtesy of Michael Peppler) takes a tli entry and returns the IP address and port number for each server in a Solaris' interfaces file.

#!/usr/local/bin/perl -w

use strict;

my $server;
my @dat;
my ($port, $ip);

while(<>) {
next if /^\s*$/;
next if /^\s*\#/;
if(/^\w/) {
$server = $_;
$server =~ s/\s*$//;

@dat = split(' ', $_);
($port, $ip) = parseAddress($dat[4]);
print "$server - $dat[0] on port $port, host $ip\n";

sub parseAddress {
my $addr = shift;

my $port;
my $ip;

my (@arr) = (hex(substr($addr, 10, 2)),

hex(substr($addr, 12, 2)),

hex(substr($addr, 14, 2)),

hex(substr($addr, 16, 2)));
$port = hex(substr($addr, 6, 4));
$ip = join('.', @arr);

($port, $ip);

(Continued on next question...)

Other Job Interview Questions