Hex to C String

In case, you do not have sprintf or atoi and etc. Not efficient but works.
char hexDigit(unsigned char n)
{
    if (n < 10) {
        return n + '0';
    } else {
        return (n - 10) + 'A';
    }
}

void hexify_ascii(char c, char * buf)
{
 char high = (c >> 4) & 0xF;
 char low = c & 0xF;

 *buf       = hexDigit(high);
 *(buf + 1) = hexDigit(low);
}


void printHex(char* input, int len)
{
  char buf[200];
  char* p = buf;
  int i;
  for (i = 0; i < len; ++i)
  {
    hexify_ascii(input[i], p);
    p+=2;
  }

  *p = 0;

  uart_print(buf);
  // printf("%s\n", buf);

}

Creating Bootable Fedora 18 USB Stick

livecd-tools

First make 1 partition with bootable flag with fdisk
$ sudo mkfs.vat /dev/sdc1
$ sudo yum install livecd-tools
livecd-iso-to-disk path-to/Fedora-18-x86_64-DVD.iso /dev/sdc1

CISCO Router Commands

Basic

# write = copy running-config startup-config
# write erase
Ctrl-R = refresh line Ctrl-Z = end Ctrl-A = beginning of a line Ctrl-E = end of the line Ctrl-D = Delete previous char Ctrl-W = delete previous word

IP Address, subnetting

Class A: starts with 0x0xxxxxxx (0-127), 127=128-1 Class B: starts with 0x10xxxxxx (128-191), 191 = 128+64-1 Class C: starts with 0x110xxxxx(192-223), 223 = 128+64+32-1 Class D: starts with 0x1110xxxx(224-239), 239= 128+64+32+16-1 Class E: starts with 0x11110xxx(240-255) not used.

List DHCP lease and clients

show dhcp server
show dhcp lease
show ip dhcp binding

NAT

config t
interface gigabitethernet 0/1
ip nat inside
end

# forward ssh
ip nat inside source static tcp 192.168.10.1 22 interface BVI3 22
# turn it off
no ip nat inside source static tcp 192.168.10.1 22 interface BVI3 22

SVI - Switch Virtual Interface

There is no physical interface for the VLAN and the SVI provides the Layer 3 processing for packets from all switch ports associated with the VLAN. - There is one-to-one mapping between a VLAN and SVI
# int vlan 1
# ip address 192.168.0.254 255.255.255.0
# int vlan 2
# ip address 192.168.1.254 255.255.255.0
# ip default gateway 192.168.1.254

IP Routing

# ip routing 
# no ip routing

Static Routing

# ip route 0.0.0.0 0.0.0.0 192.168.1.5
# ip route 192.168.0.0 255.255.255.0 192.168.2.5
# show ip route 192.168.0.1

RIPv2

# conf t
# router rip
# version 2
# no auto-summary
# network 192.168.1.0
# network 192.168.3.0

Router on a Stick, sub-interfaces

On the switch, configure the link to router as trunk
# switchport trunk encapsulation dot1q
# switch mode trunk
# show interfaces trunk
On the router interface, remove IP on the main interface
# int fa0/0
# no ip address
# int fa0/0.2
# encapsulation dot1Q 2
# ip address 192.168.1.1 255.255.255.0
# int fa0/0.4
# encapsulation dot1Q 4
# ip address 192.168.3.1 255.255.255.0
# show ip route

udevinfo

udevinfo -q env -n /dev/sdc
udevinfo -a -p /sys/class/net/eth2 
udevinfo -a -p $(udevinfo -q path -n /dev/sdc)
Test udev rules
# udevtest /block/sdc
udevadm test /block/sdc
# udevcontrol reload_rules

i/o scheduler for block devices

SSD: NOOP NON-SSD: deadline