public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Birahim Larou Fall <BLFall@scmmicro.fr>
To: 蔡述宪 <caishuxian@water.pku.edu.cn>
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] How to change MTU?
Date: Wed, 17 May 2006 08:25:00 -0000	[thread overview]
Message-ID: <OF0A301020.DAE40228-ONC1257171.002D64CB-C1257171.002E4D52@scmmicro.fr> (raw)
In-Reply-To: <199acfa199d194.199d194199acfa@pku.edu.cn>

Why you don't use ioctl  command  with SIOCSIFMTU(arg2)  as command to 
change  MTU. See " if_ethersubr.c" in freebsd sources.
You have to fill the ifreq struct (for the interface you want to change 
the MTU)

Fall Birahim
Digital TV Firmware Engineer
Elsys Design for SCM Microsystems
La Ciotat - France
+33 (0)4 42 83 87 31
Mobile :  +33 (0)6 61 40 94 81
bfall@scmmicro.com



蔡述宪 <caishuxian@water.pku.edu.cn> 
Sent by: ecos-discuss-owner@ecos.sourceware.org
15/05/2006 08:17

To
ecos-discuss@sources.redhat.com
cc

Subject
[ECOS] How to change MTU?






Hello, everyone!

  I am now implementing a router using eCos. I want to change the MTU 
of one of my two network interfaces. I tried to do that using the 
socket to kernel routing table, here is my code:

    //for route add and delete 
    u_int32_t g,m,d;

    int routes;
    struct {
                struct rt_msghdr                 hdr;
                                 struct sockaddr_in              dst;
                                 struct sockaddr_in              gway;
                                 struct sockaddr_in              mask;
                                 } rtmsg; 

                 if ((routes = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
                                 diag_printf("Error: route socket\n");
                 }

  //change route for MTU of eth1

                 g = 0x64300100;
                 m = 0xFFFFFF00;
                 d = 0x64300100;
                 g = htonl(g);
                 m = htonl(m);
                 d = htonl(d);
 
                 memset(&rtmsg, 0, sizeof(rtmsg));
 
                 rtmsg.hdr.rtm_type = RTM_CHANGE;
                 rtmsg.hdr.rtm_flags = RTF_UP | RTF_HOST |RTF_STATIC;
                 rtmsg.hdr.rtm_version = RTM_VERSION;
                 rtmsg.hdr.rtm_seq = ++rtm_seq;
                 rtmsg.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | 
RTA_NETMASK;
                 rtmsg.hdr.rtm_rmx.rmx_locks = 0;
                 rtmsg.hdr.rtm_rmx.rmx_mtu = 1000; 
                 rtmsg.dst.sin_len = sizeof(rtmsg.dst);
                 rtmsg.dst.sin_family = AF_INET;
                 rtmsg.dst.sin_addr.s_addr = d;
                 rtmsg.gway.sin_len = sizeof(rtmsg.gway);
                 rtmsg.gway.sin_family = AF_INET;
                 rtmsg.gway.sin_addr.s_addr = g;
                 rtmsg.mask.sin_len = sizeof(rtmsg.dst);
                 rtmsg.mask.sin_family = AF_INET;
                 rtmsg.mask.sin_addr.s_addr = m;
                 rtmsg.hdr.rtm_msglen = sizeof(rtmsg);


                 if (write(routes, &rtmsg, sizeof(rtmsg)) < 0) {
                                 diag_printf("Error:route change 
failed\n");
                 }
 
                 close(routes);


  It seems that the write operation is successful, because I got no 
error message. But the MTU of my interface didn't change after that.
  Following is the output from show_network_tables():


Routing tables
Destination     Gateway         Mask            Flags    Interface
100.48.1.0      100.48.1.0      255.255.255.0   U        eth1
100.48.1.2      100.48.1.2                      UH       eth0
127.0.0.0       127.0.0.1       255.0.0.0       UG       lo0
127.0.0.1       127.0.0.1                       UH       lo0
162.105.75.0    162.105.75.0    255.255.255.0   U        eth0
162.105.78.0    100.48.1.2      255.255.255.0   UGS      eth1
Interface statistics
eth0    IP: 162.105.75.1, Broadcast: 162.105.75.255, Netmask: 
255.255.255.0
        UP BROADCAST RUNNING MULTICAST MTU: 1500, Metric: 0
        Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
eth1    IP: 100.48.1.1, Broadcast: 100.48.1.255, Netmask: 255.255.255.0
        UP BROADCAST RUNNING MULTICAST MTU: 1500, Metric: 0
        Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0
lo0     IP: 127.0.0.1, Broadcast: 127.0.0.1, Netmask: 255.0.0.0
        UP LOOPBACK RUNNING MULTICAST MTU: 16384, Metric: 0
        Rx - Packets: 0, Bytes: 0, Tx - Packets: 0, Bytes: 0


Why the MTU change didn't take effect? The MTU of eth1 is still 1500 
but not 1000. Is there something wrong with my code? 

Anybody done similar operation before? Thank you very much for your 
suggestion!


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss




      reply	other threads:[~2006-05-17  8:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-15  6:17 蔡述宪
2006-05-17  8:25 ` Birahim Larou Fall [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OF0A301020.DAE40228-ONC1257171.002D64CB-C1257171.002E4D52@scmmicro.fr \
    --to=blfall@scmmicro.fr \
    --cc=caishuxian@water.pku.edu.cn \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).