<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- generator="FeedCreator 1.7.2" -->
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="">
        <title>Evolution Systems - Matt's Blog</title>
        <description></description>
        <link>http://www.evolution-systems.co.uk/blogs/mat/main/</link>
        <image rdf:resource="http://www.evolution-systems.co.uk/images/keyb1.jpg" />
       <dc:date>2008-09-25T12:25:31+01:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=33/"/>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=32/"/>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=31/"/>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=30/"/>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=29/"/>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=28/"/>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=27/"/>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=26/"/>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=25/"/>
                <rdf:li rdf:resource="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=24/"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://www.evolution-systems.co.uk/images/keyb1.jpg">
        <title>Evolution Systems logo</title>
        <link>http://www.evolution-systems.co.uk</link>
        <url>http://www.evolution-systems.co.uk/images/keyb1.jpg</url>
    </image>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=33/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-09-25T10:25:31+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=33/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>Validating Url Strings In PHP</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=33/</link>
        <description>I was writing a form a little while ago that requests a url from a user. Obviously it would be nice to validate the string the user input in some way. I am not a fan of writing a regex for something like this when I know that there are bound to be many examples of doing this knocking about already so to save time I once again headed over to google to look around.&lt;br /&gt;
&lt;br /&gt;
I came across &lt;a href=&quot;http://www.phpcentral.com/208-url-validation-php.html&quot;&gt;this link&lt;/a&gt; which has a nice little example of a regex to achieve a good validation.&lt;br /&gt;
&lt;br /&gt;
Below is a copy and paste of building the regex string from that site with brief explanations of what each part achieves.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;// SCHEME&lt;br /&gt;$urlregex = &quot;^(https?|ftp)\:\/\/&quot;;&lt;br /&gt;&lt;br /&gt;// USER AND PASS (optional)&lt;br /&gt;$urlregex .= &quot;([a-z0-9+!*(),;?&amp;=\$_.-]+(\:[a-z0-9+!*(),;?&amp;=\$_.-]+)?@)?&quot;;&lt;br /&gt;// HOSTNAME OR IP&lt;br /&gt;$urlregex .= &quot;[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*&quot;;&lt;br /&gt;// PORT (optional)&lt;br /&gt;$urlregex .= &quot;(\:[0-9]{2,5})?&quot;; &lt;br /&gt;// PATH  (optional)&lt;br /&gt;$urlregex .= &quot;(\/([a-z0-9+\$_-]\.?)+)*\/?&quot;;// GET Query (optional)&lt;br /&gt;$urlregex .= &quot;(\?[a-z+&amp;\$_.-][a-z0-9;:@/&amp;%=+\$_.-]*)?&quot;;// ANCHOR (optional)&lt;br /&gt;$urlregex .= &quot;(#[a-z_.-][a-z0-9+\$_.-]*)?\$&quot;;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
This builds a nice regex string which can be used with the eregi() function to validate a url string like so:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;if (eregi($urlregex, $url))&lt;br /&gt;{&lt;br /&gt;  echo &quot;URL Valid&quot;;&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;  echo &quot;URL Invalid&quot;;&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
This regex will validate nearly all valid url's and is handy to have knocking about.&lt;br /&gt;
&lt;br /&gt;
Thanks to the original author, whoever that may be.....</description>
    </item>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=32/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-09-24T20:46:11+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=32/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>Get Next Auto Increment Value</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=32/</link>
        <description>Earlier today I had the need to try and discover the next auto increment value in a MySQL table. I haven't needed to do this before so I headed over to google to have a look for how to accomplish it.&lt;br /&gt;
&lt;br /&gt;
A lot of information I found said to use a 'SELECT MAX...'. This would work fine as long as nothing gets deleted from the end of the database. I ended up finding a nice blog entry &lt;a href=&quot;http://blog.jamiedoris.com/geek/560/&quot;&gt;here&lt;/a&gt; that explains exactly how to do it. The following code snippet taken from the site above shows how to get the next value.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;?php&lt;br /&gt;$tablename 		= &quot;tablename&quot;;&lt;br /&gt;$next_increment 	= 0;&lt;br /&gt;$qShowStatus 		= &quot;SHOW TABLE STATUS LIKE '$tablename'&quot;;&lt;br /&gt;$qShowStatusResult 	= mysql_query($qShowStatus);&lt;br /&gt;&lt;br /&gt;$row = mysql_fetch_assoc($qShowStatusResult);&lt;br /&gt;$next_increment = $row['Auto_increment'];&lt;br /&gt;&lt;br /&gt;echo &quot;next increment number: [$next_increment]&quot;;&lt;br /&gt;
?&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Quite a useful piece of info...</description>
    </item>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=31/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-06-20T12:45:46+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=31/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>SSHFS - Mounting Remote Directories Over SSH</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=31/</link>
        <description>For a while now I have been wondering how easy it is to mount a remote directory. I have always known there must be a way to do it but had never actually got around to looking it up. It was only the other day when someone showed me &lt;a href=&quot;http://www.sftpdrive.com/&quot;&gt;SftpDrive&lt;/a&gt;, an application for windows that allows you to mount remote directories over SFTP.&lt;br /&gt;
&lt;br /&gt;
This got me searching around for a similar method for Linux. I just wanted to be able to mount a directory on a remote machine and be able to access it as though it was a directory on my local machine. My searching led me to &lt;a href=&quot;http://fuse.sourceforge.net/sshfs.html&quot;&gt;SSHFS&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
SSHFS allowed me to do exactly what i want. A simple 'apt-get' in Ubuntu installed it and I was ready to go. You need to add yourself to the fuse group after it has been installed (adduser &lt;username&gt; fuse) and then restart your terminal. (You may also need to 'modprobe fuse')&lt;br /&gt;
&lt;br /&gt;
Once this is done you are ready to go, simply mount a remote directory using a command like 'sshfs username@hostnema:/remote/path/ /local/path'&lt;br /&gt;
&lt;br /&gt;
Make sure you have made a directory somewhere on your local machine to be the mount point and chown'd it using 'sudo chown your-username /local/path'.&lt;br /&gt;
&lt;br /&gt;
All being well you should now have your remote directory mounted as if it was on your own machine. I have found this extremely useful for working on a few web based projects. Another thing that it is very useful for is running backups of my remote servers. A simple cron job running a script to backup your remote servers works a treat.</description>
    </item>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=30/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-06-12T10:56:10+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=30/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>Linux and TCP Congestion Control</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=30/</link>
        <description>I saw a question on the Ubuntu forums this morning from someone who has recently started using a satellite connection and was getting poor performance loading web pages, which is to be expected really with the high Bandwidth Delay Product (BDP) of satellite links.&lt;br /&gt;
&lt;br /&gt;
The question was asking if there are any ways to tune TCP in Linux to perform better over this type of connection. There are obviously various TCP congestion control algorithms knocking about, cubic, reno, vegas, hybla etc but up until now I thought you had to recompile the kernel in order to change the algorithm being used. I was wrong.&lt;br /&gt;
&lt;br /&gt;
It appears that since Linux kernel version 2.6.13 a new feature, pluggable congestion avoidance modules, has been supported. This enables the changing of the algorithm being used by simply issuing a sysctl command.&lt;br /&gt;
&lt;br /&gt;
The available algorithms have to be configured when the kernel is compiled but once they have been set up they can be easily changed in a running kernel. In order to see what algorithms are already in your running kernel you can issue the command :&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;sysctl net.ipv4.tcp_available_congestion_control&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;
If the algorithm you wish to use is not already in your running kernel you can find a list of them and compile them in in the following place using make menuconfig/xconfig :&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;Networking ---&gt;&lt;br /&gt;Networking options ---&gt;&lt;br /&gt;TCP: advanced congestion control ---&gt;&lt;br /&gt;TCP congestion control ---&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;
Once you have all the algorithms you want in your running kernel it is a simple matter to switch between them, for example to change to using the hybla algorithm (ideal for satellite links as it tries to keep the window size as large as possible on high BDP links) you just issue the following command (as root):&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;sysctl -w net.ipv4.tcp_congestion_control=hybla&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;
This is a nifty little addition to the Linux kernel that could prove very useful, especially for people with mobile devices that constantly use networks with varying characteristics.</description>
    </item>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=29/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-06-11T15:53:07+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=29/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>Conditional Statements Explained</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=29/</link>
        <description>I have often used #if, #ifdef, #if defined() etc as conditional preprocessor directives but haven't really thought in depth about the differences between them. It was only when someone asked the question in a C channel on freenode that it made me think.&lt;br /&gt;
&lt;br /&gt;
A quick search of google brought me across a nice little explanation. Rather than recycling the information here is the link :&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://docs.hp.com/en/B3901-90003/ch07s05.html&quot;&gt;Conditional Compilation (#if, #ifdef, ..#endif)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Quite an interesting little read.</description>
    </item>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=28/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-05-01T10:56:59+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=28/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>Building A Kernel In Ubuntu</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=28/</link>
        <description>As I mentioned in a previous blog entry, I have started using Ubuntu for pretty much all of my Linux needs over the past few years. However, up until now all of my kernel development work has been done using other distros.&lt;br /&gt;
&lt;br /&gt;
Yesterday I decided to start doing some kernel development in Ubuntu for a project I am working on. The kernel compilation process is a bit different to the traditional method and this post simply lists how to compile a kernel using the Ubuntu tools. Please note that a lot of the commands listed hereafter will need to be executed as root.&lt;br /&gt;
&lt;br /&gt;
First of all you need to grab the source of the kernel version you wish to compile. For me this is the Mobile IP version of the kernel from &lt;a href=&quot;http://www.nautilus6.org&quot;&gt;The Nautilus6 working group&lt;/a&gt;. This should be done from the directory in which you want the source directory to be, usually this would be /usr/src.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;#cd /usr/src&lt;br&gt;#apt-get source linux-image-2.6.22-10-mip6&lt;/code&gt;This should grab all of the source for you and put it in the directory /usr/src/linux-source-2.6.22-2.6.22.&lt;br /&gt;
&lt;br /&gt;
Often it is a good idea to use the configuration file from the currently running kernel as a base for the kernel you are going to build. This should ease the transition from a stock kernel to one you have customised. This is done as follows :&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;#cp /boot/config-`uname -r` ./.config&lt;/code&gt;Now you are ready to start configuring your kernel.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;#make menuconfig&lt;/code&gt;This will bring up an ncurses based menu system that will allow you to configure your kernel options. If you prefer a more graphical environment in which to perform the configuration you can use the following :&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;#make xconfig&lt;/code&gt;Note that if you are using xconfig you should run it with either `gksudo` or `kdesudo` rather than just `sudo`. Although this shouldn't be an issue in this case it is a good habit to get into as described &lt;a href=&quot;http://www.psychocats.net/ubuntu/graphicalsudo&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Once you have decided what configuration options you want for your kernel you are ready to build it. This is done using the following two commands.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;#make-kpkg clean&lt;br /&gt;#fakeroot make-kpkg --initrd --append-to-version=-your_kernel_name&lt;br /&gt;kernel_image kernel_headers&lt;/code&gt;The string after `--append-to-version`can be anything you want to distinguish this kernel from the others on the system.. Note that it must begin with a `-` and must not contain any whitespace.&lt;br /&gt;
&lt;br /&gt;
Now you might want to go grab a coffee as this compilation will take quite a while, obviously the amount of time is dependent on your machine spec and your kernel configuration.&lt;br /&gt;
&lt;br /&gt;
Once the compilation has successfully completed you should find two new .deb files in /usr/src. The name of these will vary depending on which kernel source you are using and what you appended to the kernel name. On my build they are named :&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;linux-headers-2.6.22.9-custom_2.6.22.9-custom-10.00.Custom_i386.deb&lt;br /&gt;linux-image-2.6.22.9-custom_2.6.22.9-custom-10.00.Custom_i386.deb&lt;/code&gt;All that is left to do now is to install these files using dpkg :&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;#dpkg -i linux-headers-2.6.22.9-custom_2.6.22.9-custom-10.00.Custom_i386.deb&lt;br /&gt;#dpkg -i linux-image-2.6.22.9-custom_2.6.22.9-custom-10.00.Custom_i386.deb&lt;/code&gt;Your new kernel should now be installed and ready to go if all the above steps went smoothly so just restart your machine and you should be running your home built kernel. To check this is the case once the machine has restarted just do the following in a terminal.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;#uname -r&lt;/code&gt;This should display to you the name of your home built kernel and you are ready to start experimenting with different configurations or why not start hacking about with the code and see what happens :)&lt;br /&gt;
&lt;br /&gt;
This blog entry went on for a bit longer than i anticipated so for the impatient here is a quick fire list of commands for compiling the kernel in Ubuntu (change names in dpkg commands as necessary) :)&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;#cd /usr/src&lt;br&gt;#apt-get source linux-image-2.6.22-10-mip6&lt;br /&gt;#cp /boot/config-`uname -r` ./.config&lt;br /&gt;#make menuconfig&lt;br /&gt;#make-kpkg clean&lt;br /&gt;#fakeroot make-kpkg --initrd --append-to-version=-your_kernel_name&lt;br /&gt; kernel_image kernel_headers&lt;br /&gt;#dpkg -i linux-headers-2.6.22.9-custom_2.6.22.9-custom-10.00.Custom_i386.deb&lt;br /&gt;#dpkg -i linux-image-2.6.22.9-custom_2.6.22.9-custom-10.00.Custom_i386.deb&lt;/code&gt;Hope you found this useful and good luck with your new kernel.</description>
    </item>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=27/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-04-17T12:21:34+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=27/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>Linux XFRM Framework Selectors</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=27/</link>
        <description>Whilst progressing some code I have been writing I was recently introduced to Linux's XFRM (transform) framework. I had not heard of this before but it can be a very useful tool for manipulating packets.&lt;br /&gt;
&lt;br /&gt;
The one big downside to XFRM is there is virtually no documentation on it yet. This can make working with it quite tricky. I am documenting what I find out from using it here in the hope that others will find it useful.&lt;br /&gt;
&lt;br /&gt;
 The basic idea behind XFRM is that it allows you to select a packet based on a number of factors. These are all defined in /usr/include/linux/xfrm.h in a struct named xfrm_selector as defined below :&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;struct xfrm_selector&lt;br /&gt;{&lt;br /&gt;    xfrm_address_t  daddr;&lt;br /&gt;    xfrm_address_t  saddr;&lt;br /&gt;    __be16  dport;&lt;br /&gt;    __be16  dport_mask;&lt;br /&gt;    __be16  sport;&lt;br /&gt;    __be16  sport_mask;&lt;br /&gt;    __u16   family;&lt;br /&gt;    __u8    prefixlen_d;&lt;br /&gt;    __u8    prefixlen_s;&lt;br /&gt;    __u8    proto;&lt;br /&gt;    int ifindex;&lt;br /&gt;    uid_t   user;&lt;br /&gt;};&lt;/code&gt;&lt;br /&gt;
Creating a struct of this type and setting the fields such as the source/destination addresses, ports, address masks etc, allows a packet to be selected, based on this criteria, to allow it to be transformed. By passing this information into the kernel using a nlmsghdr struct and the addattr_l() function along with a template (struct xfmr_user_tmpl) describing what action to take on the packet we can alter certain packets however we wish.&lt;br /&gt;
&lt;br /&gt;
This is proving very useful to me in some of my current work and I will continue to post anything I think might be useful to others working in the same area on this blog.</description>
    </item>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=26/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-04-03T13:08:32+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=26/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>Xajax</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=26/</link>
        <description>&lt;img src=&quot;/blogs/matt/images/xajax.png&quot; alt=&quot;Xajax Image&quot; class=&quot;floatRightImage5&quot; /&gt;I have been doing some form submission for a site I am working on and was thinking it would be nice to use a bit of AJAX to check the forms and display altered content after the form had been submitted, as opposed to simply reloading the page with different parameters.&lt;br /&gt;
&lt;br /&gt;
I went on over to google and started searching to see if I could find any nice libraries that would make the job a little simpler and came across &lt;a href=&quot;http://xajaxproject.org/&quot;&gt;xajax&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
This is a really nice PHP toolkit that enables you to add ajax functionality into your web pages extremely easily. All you have to do is include the xajax libraries, create a new xajax object, register a function with the xajax object and include a call to the xajax registered function in your html form, on a button click for example.&lt;br /&gt;
&lt;br /&gt;
Once inside the xajax function you can perform any processing you wish and then return a bunch of html code to be placed inside a container (a div for example) on the calling page.&lt;br /&gt;
&lt;br /&gt;
There are some great little tutorials on the &lt;a href=&quot;http://xajaxproject.org/&quot;&gt;xajax homepage&lt;/a&gt; to get you started on your way to lovely ajax enabled web pages.&lt;br /&gt;
&lt;br /&gt;
</description>
    </item>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=25/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-03-26T16:49:01+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=25/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>Structure Packing in GCC</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=25/</link>
        <description>I have recently been doing a lot of coding using the &lt;a href=&quot;http://nautilus6.org/nemo/index.php&quot;&gt;NEPL NEMO Implementation&lt;/a&gt; as a part of a project I am working on. This has proved to be very interesting work and has brought about lots of interesting problems.&lt;br /&gt;
&lt;br /&gt;
One of the most recent problems I faced involved a packet I was sending over the network using a header I had constructed using a struct as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;struct Nino&lt;br /&gt;{&lt;br /&gt;  uint8_t type;&lt;br /&gt;  uint8_t length;&lt;br /&gt;  uint8_t prefix_len;&lt;br /&gt;  uint8_t res_l_4;&lt;br /&gt;  uint32_t nino_lifetime;&lt;br /&gt;  uint32_t reserved2;&lt;br /&gt;  uint8_t nino_depth;&lt;br /&gt;  uint8_t reserved3;&lt;br /&gt;  uint16_t nino_seq;&lt;br /&gt;  struct in6_addr _prefix_in6_addr;&lt;br /&gt;};&lt;/code&gt;&lt;br /&gt;
This was the exact packet header format that I required but when I received a packet and checked it using a version of &lt;a href=&quot;http://www.wireshark.org&quot;&gt;Wireshark&lt;/a&gt; I had modified to recognise the header format, I was getting what seemed like an erroneous 2 Bytes of data (set to 0's) at the beginning of the in6_addr. This puzzled me for a while until I started to think about how GCC would lay out the fields in the struct. Of course GCC tries to optimise the struct for passing across the hardware and pads it if it feels it is necessary.&lt;br /&gt;
&lt;br /&gt;
For my purposes this ruins the whole layout of the packet header for processing so I had a look around and found that GCC has an attribute named __packed__ that will force it not to pad the struct out. Or in the terms of the GCC Manual :&lt;br /&gt;
&lt;span class=&quot;tags&quot;&gt;&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;&quot;a variable or structure field should have the smallest possible alignment--one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute.&quot;&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;/span&gt;This was exactly what I wanted. So by changing the struct definition from that above, to :&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;struct Nino&lt;br /&gt;{&lt;br /&gt;  uint8_t type;&lt;br /&gt;  uint8_t length;&lt;br /&gt;  uint8_t prefix_len;&lt;br /&gt;  uint8_t res_l_4;&lt;br /&gt;  uint32_t nino_lifetime;&lt;br /&gt;  uint32_t reserved2;&lt;br /&gt;  uint8_t nino_depth;&lt;br /&gt;  uint8_t reserved3;&lt;br /&gt;  uint16_t nino_seq;&lt;br /&gt;  struct in6_addr _prefix_in6_addr;&lt;br /&gt;}__attribute__((__packed__));&lt;/code&gt;&lt;br /&gt;
My code behaved exactly as I required. Problem solved. This is a handy little function of GCC especially when dealing with network packets to make sure you know exactly how the compiler is behaving and hence avoiding any unwanted surprised.&lt;br /&gt;
&lt;br /&gt;
A slightly more in depth look at the packed attribute can be found &lt;a href=&quot;http://sig9.com/articles/gcc-packed-structures&quot;&gt;here&lt;/a&gt;.</description>
    </item>
    <item rdf:about="http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=24/">
        <dc:format>text/html</dc:format>
        <dc:date>2008-03-22T12:32:39+01:00</dc:date>
        <dc:source>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=24/</dc:source>
        <dc:creator>Matthew Jakeman</dc:creator>
        <title>Ubuntu 8.04 Beta Released</title>
        <link>http://www.evolution-systems.co.uk/blogs/matt/view_post&amp;id=24/</link>
        <description>&lt;img src=&quot;http://www.ubuntu.com/themes/ubuntu07/images/ubuntulogo.png&quot; alt=&quot;Ubuntu Image&quot; class=&quot;floatRightImage5&quot; /&gt;The team over at Ubuntu have released the latest beta of Ubuntu 8.04 (Hardy Heron). There are lots of upgrades to the existing software packages including the following :&lt;br /&gt;
&lt;span class=&quot;tags&quot;&gt;&lt;ul&gt;&lt;li&gt;Xorg 7.3&lt;/li&gt;&lt;li&gt;Linux kernel 2.6.24&lt;/li&gt;&lt;li&gt;GNOME 2.22&lt;/li&gt;&lt;li&gt;PolicyKit&lt;/li&gt;&lt;li&gt;PulseAudio&lt;/li&gt;&lt;li&gt;Firefox 3 Beta 4&lt;/li&gt;&lt;li&gt;Transmission BitTorrent Client&lt;/li&gt;&lt;li&gt;Wubi&lt;/li&gt;&lt;/ul&gt;&lt;/span&gt;&lt;br /&gt;
This is the best release yet for 'converting' windows users to the world of open source software using Wubi to enable it to be easily installed and used as a dual boot system without any complicated partitioning needed. This is a great way to try Linux without having to compromise the integrity of your windows partition in any way.&lt;br /&gt;
&lt;br /&gt;
I will be upgrading to 8.04 on all of my machines as soon as it goes to stable. I have been totally converted to Ubuntu for my desktop OS over the past year. As an avid Linux user for the past 6 or 7 years using a myriad of different distributions. College Linux whilst I was on the development team there before it was dissolved, Debian for years, a bit of Gentoo mixed in as well but none have come close to Ubuntu for ease of usability and I will continue using it as my primary desktop OS for the foreseeable future.&lt;/p&gt;</description>
    </item>
</rdf:RDF>
