Merge lp:~martin-lp/hipl/hipfwconf into lp:hipl

Proposed by David Martin
Status: Merged
Merged at revision: 6121
Proposed branch: lp:~martin-lp/hipl/hipfwconf
Merge into: lp:hipl
Diff against target: 1465 lines (+419/-198)
19 files modified
doc/HOWTO.xml.in (+50/-50)
firewall/cache.c (+1/-1)
firewall/conntrack.c (+54/-1)
firewall/conntrack.h (+2/-0)
firewall/firewall.c (+32/-17)
firewall/firewall.h (+3/-1)
firewall/firewall_control.c (+30/-3)
firewall/firewall_control.h (+2/-2)
hipd/init.c (+2/-2)
hipd/nat.c (+1/-1)
hipd/registration.c (+1/-1)
lib/core/conf.c (+161/-81)
lib/core/conf.h (+4/-0)
lib/core/hostid.c (+1/-1)
lib/core/message.c (+69/-32)
lib/core/message.h (+1/-0)
lib/tool/nlink.c (+1/-1)
tools/hipconf.c (+1/-1)
tools/hipdnsproxy/hipdnsproxy.in (+3/-3)
To merge this branch: bzr merge lp:~martin-lp/hipl/hipfwconf
Reviewer Review Type Date Requested Status
Diego Biurrun Approve
Miika Komu Pending
René Hummen Pending
Review via email: mp+81612@code.launchpad.net

This proposal supersedes a proposal from 2011-11-08.

Description of the change

This branch introduces changes to get the currently active connection from the firewall.

This is a resubmitted merge proposal:
instead of using a separate binary option 1 of the previous discussion is implemented:
> 1) add an extra keyword to the hipconf command line: hipconf (daemon | firewall) COMMAND

Changes since last proposal:
Addressed Diegos 'needs fixing' comments.
-> move enum daemon_name into conf.c and make conf_get_process() const-correct.

Summed up changes since the last proposal (revision 6116ff.):
Keywords to address hipd / hipfw are daemon and firewall and defined in lib/core/conf.h.
The hipconf help print has been updated.
Config file syntax does not have to be changed as only hipd parses configs via hipconf and the daemon
keyword is hardcoded.

From what I've tested everything works as before.

To post a comment you must log in.
Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

Why separate binary just for configuring hipfw? Why this can't be embedded into hipconf?

review: Needs Information
Revision history for this message
Diego Biurrun (diego-biurrun) wrote : Posted in a previous version of this proposal

On Mon, Oct 24, 2011 at 03:49:25PM +0000, Miika Komu wrote:
> Review: Needs Information
>
> Why separate binary just for configuring hipfw? Why this can't be embedded into hipconf?

Seconded. I'm terribly suspicious of this whole hipconf thing and
whether or not it is a good idea. IIUC authentication is nonexistent
and it's not clear to me what the advantage to rereading a config
file is.

Diego

Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

Another benefit of merged functionality is to allow reading of static information from /etc/hip/hipd_config

Revision history for this message
René Hummen (rene-hummen) wrote : Posted in a previous version of this proposal

On 24.10.2011, at 17:49, Miika Komu wrote:
> Why separate binary just for configuring hipfw? Why this can't be embedded into hipconf?

There are three ways to implement this functionality:
1) add an extra keyword to the hipconf command line: hipconf (daemon | firewall) COMMAND
2) add firewall queries as command parameter: hipconf get firewall-ha
3) implement as separate binary using libcore.

(1) would require some changes to hipconf command line parsing and would render the old user API broken. Furthermore, it would require an even longer parameter list for getting specific information. For these reasons, I would not want to implement this option.
(2) is somewhat inconsistent with the current syntax, but I would be fine with that. Only minor changes to the current proposal would be required.
(3) doesn't break the user API and clearly separates hipd configuration from hipfw status querying. This is my preferred option.

Opinions and other proposals are welcome.

Ciao,
René

--
Dipl.-Inform. Rene Hummen, Ph.D. Student
Chair of Communication and Distributed Systems
RWTH Aachen University, Germany
tel: +49 241 80 20772
web: http://www.comsys.rwth-aachen.de/team/rene-hummen/

Revision history for this message
René Hummen (rene-hummen) wrote : Posted in a previous version of this proposal

Forgot to include launchpad.

Begin forwarded message:
> From: René Hummen <email address hidden>
> Date: 27. Oktober 2011 15:41:06 MESZ
> To: <email address hidden>
> Subject: Re: [hipl-dev] Re: [Merge] lp:~martin-lp/hipl/hipfwconf into lp:hipl
>
> On 24.10.2011, at 19:27, Diego Biurrun wrote:
>> On Mon, Oct 24, 2011 at 03:49:25PM +0000, Miika Komu wrote:
>>> Review: Needs Information
>>>
>>> Why separate binary just for configuring hipfw? Why this can't be embedded into hipconf?
>>
>> Seconded. I'm terribly suspicious of this whole hipconf thing and
>> whether or not it is a good idea. IIUC authentication is nonexistent
>> and it's not clear to me what the advantage to rereading a config
>> file is.
>
> The issue of having one or multiple binaries aside, I think hipconf should rather be a hipstatus tool. I.e., hipd and hipfw should be configured via config files (with reload functionality) and the the current run-time status should be requestable via hipstatus. However, this is not as it's done in HIPL at the moment. Instead, reading the config file mimics calls to hipconf in order to set up the hipd. hipfwconf, on the other hand, only provides status information.
>
> Do I see volunteers who are willing to fix this hipconf-based configuration issue? :)
>
> Ciao,
> René

--
Dipl.-Inform. Rene Hummen, Ph.D. Student
Chair of Communication and Distributed Systems
RWTH Aachen University, Germany
tel: +49 241 80 20772
web: http://www.comsys.rwth-aachen.de/team/rene-hummen/

Revision history for this message
René Hummen (rene-hummen) wrote : Posted in a previous version of this proposal

On 25.10.2011, at 09:42, Miika Komu wrote:
> Another benefit of merged functionality is to allow reading of static information from /etc/hip/hipd_config

I don't see your point here. Can you please explain. By the way, hipfwconf wraps around libcore the same way hipconf does.

--
Dipl.-Inform. Rene Hummen, Ph.D. Student
Chair of Communication and Distributed Systems
RWTH Aachen University, Germany
tel: +49 241 80 20772
web: http://www.comsys.rwth-aachen.de/team/rene-hummen/

Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

> IIUC authentication is nonexistent

This a fallacy, it does have authentication. Critical functions are allowed only for root.

> and it's not clear to me what the advantage to rereading a config
> file is.

Obviously, changing of parameters during run time.

Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

> On 25.10.2011, at 09:42, Miika Komu wrote:
> > Another benefit of merged functionality is to allow reading of static
> information from /etc/hip/hipd_config
>
> I don't see your point here. Can you please explain. By the way, hipfwconf
> wraps around libcore the same way hipconf does.

You mean that you can set hipfwconf parameters from /etc/hip/hipd_config ? Did you test this?

Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

> On 24.10.2011, at 17:49, Miika Komu wrote:
> > Why separate binary just for configuring hipfw? Why this can't be embedded
> into hipconf?
>
> There are three ways to implement this functionality:
> 1) add an extra keyword to the hipconf command line: hipconf (daemon |
> firewall) COMMAND
> 2) add firewall queries as command parameter: hipconf get firewall-ha

Either of these would work for me. Probably 1 is a bit cleaner.

> 3) implement as separate binary using libcore.

I'll counterargument against this below.

> (1) would require some changes to hipconf command line parsing and would
> render the old user API broken. Furthermore, it would require an even longer
> parameter list for getting specific information. For these reasons, I would
> not want to implement this option.

Who cares if the API is changes, really? By breaking, you mean /etc/hip/hipd_config? The file could be prefixed with a "daemon" with a simple regexp when you start hipd (if we would choose #1).

> (2) is somewhat inconsistent with the current syntax, but I would be fine with
> that. Only minor changes to the current proposal would be required.

I would be fine with this.

> (3) doesn't break the user API and clearly separates hipd configuration from
> hipfw status querying. This is my preferred option.

Proposal 3 also fragments the HIP administrative interface into two. You suggest that we'll have one read-only interface and another writeable. I believe in a more unified interface and I fail see why we should disperse. It doesn't sound very responsible to say something is bad, but leave it as it is and switch to new tool?

What do you mean by "hipconf-based configuration issue"?

review: Disapprove
Revision history for this message
Diego Biurrun (diego-biurrun) wrote : Posted in a previous version of this proposal

On Thu, Oct 27, 2011 at 01:31:29PM +0000, René Hummen wrote:
> On 24.10.2011, at 17:49, Miika Komu wrote:
> > Why separate binary just for configuring hipfw? Why this can't be embedded into hipconf?
>
> There are three ways to implement this functionality:
> 1) add an extra keyword to the hipconf command line: hipconf (daemon | firewall) COMMAND
> 2) add firewall queries as command parameter: hipconf get firewall-ha
> 3) implement as separate binary using libcore.
>
> (1) would require some changes to hipconf command line parsing and
> would render the old user API broken. Furthermore, it would require an
> even longer parameter list for getting specific information. For these
> reasons, I would not want to implement this option.

alias hipdconf="hipconf daemon"
alias hipfwconf="hipconf firewall"

Diego

Revision history for this message
Diego Biurrun (diego-biurrun) wrote : Posted in a previous version of this proposal

 review needs-fixing

On Mon, Oct 31, 2011 at 06:22:27PM +0000, David Martin wrote:
>
> --- Makefile.am 2011-10-17 18:14:10 +0000
> +++ Makefile.am 2011-10-31 18:21:26 +0000
> @@ -90,8 +90,8 @@
>
> -tools_hipconf_SOURCES = tools/hipconf.c
> -tools_pisacert_SOURCES = tools/pisacert.c
> +tools_hipconf_SOURCES = tools/hipconf.c
> +tools_pisacert_SOURCES = tools/pisacert.c

unrelated

Diego

review: Needs Fixing
Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

hip_send_recv_firewall_info() has been copy-pasted from hip_send_recv_daemon_info(). The same goes for
hip_send_recv_firewall_info() and hip_handle_user_msg(). Code reuse?

lib/core/conf.c:hipconf_usage is not updated accordingly. Same goes for hipd/init.c:HIPL_CONFIG_FILE_EX. Otherwise, nobody will know about your extensions.

Also, I would like to hear a test report with some existing hipconf options to understand that legacy support still works. For example, try the following:

* hipconf add map HIT IP
* hipconf get ha all
* hipconf rst all

<wait few secs>

* hipconf nat none
* hipconf add map HIT IP
* hipconf get ha all
* hipconf rst all

<wait few secs>

* hipconf nat plain-udp
* hipconf add map HIT IP
* hipconf get ha all
* hipconf rst all

<wait few secs>

* hipconf nat port 1111
* hipconf add map HIT IP
* hipconf get ha all
* hipconf rst all

Does it do what expected?

Other than this, I am satisfied with this commit.

review: Needs Fixing
Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal

Hi,

On Mon, Oct 31, 2011 at 9:58 PM, Diego Biurrun <email address hidden> wrote:
> On Mon, Oct 31, 2011 at 06:22:27PM +0000, David Martin wrote:
>> --- Makefile.am 2011-10-17 18:14:10 +0000
>> +++ Makefile.am 2011-10-31 18:21:26 +0000
>> @@ -90,8 +90,8 @@
>>
>> -tools_hipconf_SOURCES = tools/hipconf.c
>> -tools_pisacert_SOURCES = tools/pisacert.c
>> +tools_hipconf_SOURCES = tools/hipconf.c
>> +tools_pisacert_SOURCES = tools/pisacert.c
>
> unrelated

That's not really unrelated but unintended. Forgot to reindent after removing the hipfwconf line. Fixed now.

Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal

Hi,

On Wed, Nov 2, 2011 at 8:32 AM, Miika Komu <email address hidden> wrote:
> Review: Needs Fixing
>
> hip_send_recv_firewall_info() has been copy-pasted from hip_send_recv_daemon_info().

You are right, that has been some pretty evil piece of copy-paste. Fixed this in revision 6121.

> The same goes for hip_send_recv_firewall_info() and hip_handle_user_msg(). Code reuse?

What exactly do you mean?

> lib/core/conf.c:hipconf_usage is not updated accordingly. Same goes for hipd/init.c:HIPL_CONFIG_FILE_EX. Otherwise, nobody will know about your extensions.

I changed it where hipconf_usage was used but this may have not been clear enough.
I've fixed it in revision 6122. Should be better now.

> Also, I would like to hear a test report with some existing hipconf options to understand that legacy support still works. For example, try the following:
>
> * hipconf add map HIT IP
> * hipconf get ha all
> * hipconf rst all
>
> <wait few secs>
>
> * hipconf nat none
> * hipconf add map HIT IP
> * hipconf get ha all
> * hipconf rst all
>
> <wait few secs>
>
> * hipconf nat plain-udp
> * hipconf add map HIT IP
> * hipconf get ha all
> * hipconf rst all
>
> <wait few secs>
>
> * hipconf nat port 1111
> * hipconf add map HIT IP
> * hipconf get ha all
> * hipconf rst all
>
> Does it do what expected?

Did not test that yet but I'll have a look into it and report back.

Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

Hi,

On 11/02/2011 01:04 PM, David Martin wrote:
>> The same goes for hip_send_recv_firewall_info() and hip_handle_user_msg(). Code reuse?
> What exactly do you mean?

the functions offer very similar functionality (copy paste).

Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal

Hi again,

On Wed, Nov 2, 2011 at 12:25 PM, Miika Komu <email address hidden> wrote:
> On 11/02/2011 01:04 PM, David Martin wrote:
>>>
>>> The same goes for hip_send_recv_firewall_info() and
>>> hip_handle_user_msg(). Code reuse?
>>
>> What exactly do you mean?
>
> the functions offer very similar functionality (copy paste).

Sorry for being a bit dense but I'm still not sure what you mean.
hip_handle_user_msg() is an enormous beast of a function dealing with all incoming
hipconf messages. hip_send_recv_firewall_info() sends messages to hipfw and
since the last commit is nothing more than a wrapper for send_recv_info_internal().

Maybe you mean hip_handle_msg() in firewall_control.c which basically does the same
as hip_handle_user_msg() only for the firewall. It has not really been touched in this
branch and I see no reason to merge them together. It would result in an even bigger
and even more unwieldy function. The firewall does receive user messages of the same
message type, but it acts differently on them than hipd. I think it's reasonable to keep them
apart. We should think about renaming them to make their purpose more obvious but this
is out of scope of this branch.

Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

Sorry, I mean fw_handle_hipd_message() and hip_handle_user_msg(). It seems that the beginning of the functions is copy paste. You could extract the beginning into another function and call it in the other two.

Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal
Download full text (3.7 KiB)

Hi,

On Wed, Nov 2, 2011 at 3:26 PM, Miika Komu <email address hidden> wrote:
> Sorry, I mean fw_handle_hipd_message() and hip_handle_user_msg(). It seems that the beginning of the functions is copy paste. You could extract the beginning into another function and call it in the other two.

You are right. But if I see it correctly those two weren't really touched by this branch so I would
say it's not related. Feel free to change it in trunk. :)))

PS: Fixed non-compiling make doxygen and added error-handling for wrong process keywords in the last two revisions.

PPS: Had a look at your proposed commands as well. They seem to work alright as far as I can judge. Here's a log:

martin@pisa1:~/src/hipl/hipl_hipfwconf$ sudo tools/hipconf daemon add map 2001:17:e5ab:56b2:3b45:419f:f784:af6a 10.0.3.1
Mapped v4 to v6.
mapped v6: 10.0.3.1
Sending user message 2 to HIPD on socket 3
Sent 88 bytes
Waiting to receive daemon info.
88 bytes received from HIP daemon.
User message was sent successfully to the HIP daemon.

martin@pisa1:~/src/hipl/hipl_hipfwconf$ sudo tools/hipconf daemon get ha all
Sending user message 22 to HIPD on socket 3
Sent 40 bytes
Waiting to receive daemon info.
248 bytes received from HIP daemon.
HA is UNASSOCIATED
 Shotgun mode is off.
 Broadcast mode is off.
 Local HIT: 2001:0017:e5ab:56b2:3b45:419f:f784:af6a
 Peer HIT: 2001:0017:e5ab:56b2:3b45:419f:f784:af6a
 Local LSI: 1.0.0.1
 Peer LSI: 1.0.0.1
 Local IP: 10.0.3.1
 Local NAT traversal UDP port: 10500
 Peer IP: 10.0.3.1
 Peer NAT traversal UDP port: 10500
 Peer hostname:

martin@pisa1:~/src/hipl/hipl_hipfwconf$ sudo tools/hipconf daemon rst all
Sending user message 68 to HIPD on socket 3
Sent 64 bytes
Waiting to receive daemon info.
64 bytes received from HIP daemon.
User message was sent successfully to the HIP daemon.

martin@pisa1:~/src/hipl/hipl_hipfwconf$ sudo tools/hipconf daemon get ha all
Sending user message 22 to HIPD on socket 3
Sent 40 bytes
Waiting to receive daemon info.
40 bytes received from HIP daemon.

martin@pisa1:~/src/hipl/hipl_hipfwconf$ sudo tools/hipconf daemon nat none
<snip>

martin@pisa1:~/src/hipl/hipl_hipfwconf$ sudo tools/hipconf daemon add map 2001:17:e5ab:56b2:3b45:419f:f784:af6a 10.0.3.1
<snip>

martin@pisa1:~/src/hipl/hipl_hipfwconf$ sudo tools/hipconf daemon get ha all
<snip>
HA is UNASSOCIATED
 Shotgun mode is off.
 Broadcast mode is off.
 Local HIT: 2001:0017:e5ab:56b2:3b45:419f:f784:af6a
 Peer HIT: 2001:0017:e5ab:56b2:3b45:419f:f784:af6a
 Local LSI: 1.0.0.1
 Peer LSI: 1.0.0.1
 Local IP: 10.0.3.1
 Local NAT traversal UDP port: 0
 Peer IP: 10.0.3.1
 Peer NAT traversal UDP port: 0
 Peer hostname:

martin@pisa1:~/src/hipl/hipl_hipfwconf$ sudo tools/hipconf daemon nat plain-udp
<snip>

martin@pisa1:~/src/hipl/hipl_hipfwconf$ sudo tools/hipconf daemon get ha all
<snip>
HA is UNASSOCIATED
 Shotgun mode is off.
 Broadcast mode is off.
 Local HIT: 2001:0017:e5ab:56b2:3b45:419f:f784:af6a
 Peer HIT: 2001:0017:e5ab:56b2:3b45:419f:f784:af6a
 Local LSI: 1.0.0.1
 Peer LSI: 1.0.0.1
 Local IP: 10.0.3.1
 Local NAT traversal UDP port: 10500
 Peer IP: 10.0.3.1
 Peer NAT traversal UDP port: 10500
 Peer hostname:

martin@pisa1:~/src/hipl/hipl_hi...

Read more...

Revision history for this message
René Hummen (rene-hummen) wrote : Posted in a previous version of this proposal

On 27.10.2011, at 16:37, Miika Komu wrote:
>> On 25.10.2011, at 09:42, Miika Komu wrote:
>>> Another benefit of merged functionality is to allow reading of static
>> information from /etc/hip/hipd_config
>>
>> I don't see your point here. Can you please explain. By the way, hipfwconf
>> wraps around libcore the same way hipconf does.
>
> You mean that you can set hipfwconf parameters from /etc/hip/hipd_config ? Did you test this?

Hmmm, I'm not sure what this discussion was about exactly. Maybe some clarification as to what kind of functionality this branch is supposed to introduce: it allows to request status information from hipfw at run-time. However, it does not allow for run-time configuration right now. Of course, it would be easy to extend hipfw with this functionality, but I don't see that this desirable.

--
Dipl.-Inform. Rene Hummen, Ph.D. Student
Chair of Communication and Distributed Systems
RWTH Aachen University, Germany
tel: +49 241 80 20772
web: http://www.comsys.rwth-aachen.de/team/rene-hummen/

Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

> Hmmm, I'm not sure what this discussion was about exactly. Maybe some clarification as to what kind of functionality
> this branch is supposed to introduce: it allows to request status information from hipfw at run-time. However, it
> does not allow for run-time configuration right now. Of course, it would be easy to extend hipfw with this
> functionality, but I don't see that this desirable.

Never mind (now hipd_config can be used to trigger hipfw actions as well).

review: Approve
Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal

Diego, your opinion? :)

Revision history for this message
Diego Biurrun (diego-biurrun) wrote : Posted in a previous version of this proposal

 review needs-fixing

On Mon, Oct 31, 2011 at 06:22:27PM +0000, David Martin wrote:
>
> --- lib/core/conf.h 2011-08-15 14:11:56 +0000
> +++ lib/core/conf.h 2011-10-31 18:21:26 +0000
> @@ -54,6 +54,11 @@
>
> +enum daemon_name { HIP_DAEMON, HIP_FIREWALL };
> +/* keywords used to identify hipd / hipfw as target of hipconf command */
> +#define HIPCONF_HIPD_KEYWORD "daemon"
> +#define HIPCONF_HIPFW_KEYWORD "firewall"

These appear unused outside of conf.c.

Diego

review: Needs Fixing
Revision history for this message
Diego Biurrun (diego-biurrun) wrote : Posted in a previous version of this proposal

On Fri, Nov 04, 2011 at 12:07:34PM +0000, David Martin wrote:
> Diego, your opinion? :)

I said enough to reject it already, just added some more ;)

Diego

Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal

Hi,

On Fri, Nov 4, 2011 at 1:25 PM, Diego Biurrun <email address hidden> wrote:
> On Mon, Oct 31, 2011 at 06:22:27PM +0000, David Martin wrote:
>>
>> --- lib/core/conf.h 2011-08-15 14:11:56 +0000
>> +++ lib/core/conf.h 2011-10-31 18:21:26 +0000
>> @@ -54,6 +54,11 @@
>>
>> +enum daemon_name { HIP_DAEMON, HIP_FIREWALL };
>> +/* keywords used to identify hipd / hipfw as target of hipconf command */
>> +#define HIPCONF_HIPD_KEYWORD "daemon"
>> +#define HIPCONF_HIPFW_KEYWORD "firewall"
>
> These appear unused outside of conf.c.

Nope, using them in lib/core/message.c as well. Did you pull the latest revisions?

On Fri, Nov 4, 2011 at 1:29 PM, Diego Biurrun <email address hidden> wrote:
> I said enough to reject it already, just added some more ;)

Well, other than you being terribly suspicious of hipconf in general you did not say
aynthing. And that's not very constructive. :p

Revision history for this message
Diego Biurrun (diego-biurrun) wrote : Posted in a previous version of this proposal

On Fri, Nov 04, 2011 at 12:53:25PM +0000, David Martin wrote:
> On Fri, Nov 4, 2011 at 1:25 PM, Diego Biurrun <email address hidden> wrote:
> > On Mon, Oct 31, 2011 at 06:22:27PM +0000, David Martin wrote:
> >>
> >> --- lib/core/conf.h 2011-08-15 14:11:56 +0000
> >> +++ lib/core/conf.h 2011-10-31 18:21:26 +0000
> >> @@ -54,6 +54,11 @@
> >>
> >> +enum daemon_name { HIP_DAEMON, HIP_FIREWALL };
> >> +/* keywords used to identify hipd / hipfw as target of hipconf command */
> >> +#define HIPCONF_HIPD_KEYWORD "daemon"
> >> +#define HIPCONF_HIPFW_KEYWORD "firewall"
> >
> > These appear unused outside of conf.c.
>
> Nope, using them in lib/core/message.c as well. Did you pull the latest revisions?

Of course not! I don't pull anything to review your work, why would I?
I just sit here and read emails. I should not have to care about you
committing new revisions somewhere I'm not looking.

> On Fri, Nov 4, 2011 at 1:29 PM, Diego Biurrun <email address hidden> wrote:
> > I said enough to reject it already, just added some more ;)
>
> Well, other than you being terribly suspicious of hipconf in general you did not say
> aynthing. And that's not very constructive. :p

I said there were unrelated stray changes - that's ground enough not to
commit it so I did not bother to look in detail at a version that will
not be pushed anyway ;)

Diego

Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

Good work!

review: Approve
Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

Sorry, I stumbled on a problem after hitting the Approve button. "hipconf daemon" is needed now for all existing commands, right? If yes, then this need to be properly adjusted in:

* doc/HOWTO.xml.in
* lib/core/conf.c
* lib/core/hostid.c
* lib/core/message.c
* lib/tool/nlink.c
* hipd/nat.c
* tools/hipdnsproxy/hipdnsproxy.in
* firewall/conntrack.c
* firewall/cache.c

Scan for "hipconf" in the files and adjust where appropiate.

review: Needs Fixing
Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal

Hi,

On Mon, Nov 7, 2011 at 3:33 PM, Miika Komu <email address hidden> wrote:
> Review: Needs Fixing
>
> Sorry, I stumbled on a problem after hitting the Approve button. "hipconf daemon" is needed now for all existing commands, right? If yes, then this need to be properly adjusted in:
>
> * doc/HOWTO.xml.in
> * lib/core/conf.c
> * lib/core/hostid.c
> * lib/core/message.c
> * lib/tool/nlink.c
> * hipd/nat.c
> * tools/hipdnsproxy/hipdnsproxy.in
> * firewall/conntrack.c
> * firewall/cache.c
>
> Scan for "hipconf" in the files and adjust where appropiate.

Good catch! Should've thought about grepping through the other files to find hipconf occurances. I would have missed the *.in for sure though.

Fixed this and will resubmit the proposal.

Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal

Sorry, seems like I oversaw a merge conflict. Will fix this and retransmit.

Revision history for this message
Miika Komu (miika-iki) wrote : Posted in a previous version of this proposal

Let's make it final this time :)

review: Approve
Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal

Hey,

On Mon, Nov 7, 2011 at 6:08 PM, Miika Komu <email address hidden> wrote:

> Let's make it final this time :)

sorry, one more time at least. Maybe wait with your approval for Diego. I fear this is not yet over. ;)

Revision history for this message
Diego Biurrun (diego-biurrun) wrote : Posted in a previous version of this proposal

 review needs-fixing

On Mon, Nov 07, 2011 at 05:15:33PM +0000, David Martin wrote:
> David Martin has proposed merging lp:~martin-lp/hipl/hipfwconf into lp:hipl.
>
> --- firewall/firewall_control.c 2011-10-25 21:14:16 +0000
> +++ firewall/firewall_control.c 2011-11-07 17:14:40 +0000
> @@ -38,10 +38,12 @@
>
> +#include "conntrack.h"
> #include "lib/core/builder.h"
> #include "lib/core/debug.h"
> #include "lib/core/ife.h"
> #include "lib/core/message.h"
> +#include "lib/core/prefix.h"
> #include "lib/core/protodefs.h"
> #include "cache.h"
> #include "firewall.h"

conntrack.h should come after cache.h.

> --- lib/core/conf.c 2011-11-03 09:21:12 +0000
> +++ lib/core/conf.c 2011-11-07 17:14:40 +0000
> @@ -226,6 +234,51 @@
>
> +const char *hipfwconf_usage =
> + HIPCONF_HIPFW_KEYWORD
> + " <command>\n\n"
> + "HIP firewall commands:\n"
> + "get ha <hit> | all\n";

I think this can be static.

> @@ -510,6 +563,25 @@
>
> /**
> + * Map daemon / firewall keyboard to its respective enum.

You are mapping a keyBOARD? Is that maybe a typo? :)

> @@ -2525,7 +2604,8 @@
>
> if (err) {
> - HIP_ERROR("(Check syntax for hipconf. Is hipd running or root privilege needed?)\n");
> + HIP_ERROR("(Check syntax for hipconf. Is hipd or hipfw running or root"
> + " privilege needed?)\n");

Maybe just say "daemon" instead of enumerating the 12345 programs that
will become part of HIPL over the next decade.

> --- lib/core/conf.h 2011-08-15 14:11:56 +0000
> +++ lib/core/conf.h 2011-11-07 17:14:40 +0000
> @@ -54,6 +54,11 @@
> #define ACTION_ADD 1
> #define ACTION_NEW 3
>
> +enum daemon_name { HIP_DAEMON, HIP_FIREWALL, UNKNOWN_KEYWORD };

This is still unused outside of conf.c.

Diego

review: Needs Fixing
Revision history for this message
David Martin (martin-lp) wrote : Posted in a previous version of this proposal

Hi,

On Tue, Nov 8, 2011 at 9:47 AM, Diego Biurrun <email address hidden> wrote:
> review needs-fixing
>
> On Mon, Nov 07, 2011 at 05:15:33PM +0000, David Martin wrote:
>> David Martin has proposed merging lp:~martin-lp/hipl/hipfwconf into lp:hipl.
>>
>> --- firewall/firewall_control.c 2011-10-25 21:14:16 +0000
>> +++ firewall/firewall_control.c 2011-11-07 17:14:40 +0000
>> @@ -38,10 +38,12 @@
>>
>> +#include "conntrack.h"
>> #include "lib/core/builder.h"
>> #include "lib/core/debug.h"
>> #include "lib/core/ife.h"
>> #include "lib/core/message.h"
>> +#include "lib/core/prefix.h"
>> #include "lib/core/protodefs.h"
>> #include "cache.h"
>> #include "firewall.h"
>
> conntrack.h should come after cache.h.

fixed.

>> --- lib/core/conf.c 2011-11-03 09:21:12 +0000
>> +++ lib/core/conf.c 2011-11-07 17:14:40 +0000
>> @@ -226,6 +234,51 @@
>>
>> +const char *hipfwconf_usage =
>> + HIPCONF_HIPFW_KEYWORD
>> + " <command>\n\n"
>> + "HIP firewall commands:\n"
>> + "get ha <hit> | all\n";
>
> I think this can be static.

yup, fixed.

>> @@ -510,6 +563,25 @@
>>
>> /**
>> + * Map daemon / firewall keyboard to its respective enum.
>
> You are mapping a keyBOARD? Is that maybe a typo? :)

Heaven forbid! That does indeed seem to be a typo. ^^ Fixed.

>> @@ -2525,7 +2604,8 @@
>>
>> if (err) {
>> - HIP_ERROR("(Check syntax for hipconf. Is hipd running or root privilege needed?)\n");
>> + HIP_ERROR("(Check syntax for hipconf. Is hipd or hipfw running or root"
>> + " privilege needed?)\n");
>
> Maybe just say "daemon" instead of enumerating the 12345 programs that
> will become part of HIPL over the next decade.

You are right. Personally I find it a bit strange to call hipd the HIP daemon when they are all daemons. Whatever, fixed this as well.

>
>> --- lib/core/conf.h 2011-08-15 14:11:56 +0000
>> +++ lib/core/conf.h 2011-11-07 17:14:40 +0000
>> @@ -54,6 +54,11 @@
>> #define ACTION_ADD 1
>> #define ACTION_NEW 3
>>
>> +enum daemon_name { HIP_DAEMON, HIP_FIREWALL, UNKNOWN_KEYWORD };
>
> This is still unused outside of conf.c.

You are right. I made it static.

Revision history for this message
René Hummen (rene-hummen) wrote : Posted in a previous version of this proposal

LGTM. You also obviously fixed Diego's comments and Miika was satisfied already with the last request. So go ahead and merge it.

review: Approve
Revision history for this message
Diego Biurrun (diego-biurrun) wrote : Posted in a previous version of this proposal

 review needs-fixing

On Tue, Nov 08, 2011 at 03:41:03PM +0000, David Martin wrote:
>
> --- lib/core/conf.h 2011-08-15 14:11:56 +0000
> +++ lib/core/conf.h 2011-11-08 15:39:04 +0000
> @@ -54,6 +54,11 @@
>
> +enum daemon_name { HIP_DAEMON, HIP_FIREWALL, UNKNOWN_KEYWORD };

This is only used in conf.c, so it has no business in a header file.
Header files are for interface definitions *only*.
Should be in HACKING, if not we need to update it.

Diego

review: Needs Fixing
Revision history for this message
Diego Biurrun (diego-biurrun) wrote :

 review approve

On Tue, Nov 08, 2011 at 05:12:08PM +0000, David Martin wrote:
> David Martin has proposed merging lp:~martin-lp/hipl/hipfwconf into lp:hipl.
>
> --- lib/core/message.c 2011-10-25 21:44:47 +0000
> +++ lib/core/message.c 2011-11-08 17:09:18 +0000
> @@ -319,23 +330,30 @@
>
> -static int send_recv_daemon_info_internal(struct hip_common *msg,
> - int opt_socket)
> +static int send_recv_info_internal(struct hip_common *msg, int opt_socket, int port)

nit: This is now a long line.

Anyway, this looks good to me now, so go ahead and push :)

Diego

review: Approve
Revision history for this message
David Martin (martin-lp) wrote :

Hi,

On Tue, Nov 8, 2011 at 8:55 PM, Diego Biurrun <email address hidden> wrote:
> Review: Approve

> On Tue, Nov 08, 2011 at 05:12:08PM +0000, David Martin wrote:
>> David Martin has proposed merging lp:~martin-lp/hipl/hipfwconf into lp:hipl.
>>
>> --- lib/core/message.c 2011-10-25 21:44:47 +0000
>> +++ lib/core/message.c 2011-11-08 17:09:18 +0000
>> @@ -319,23 +330,30 @@
>>
>> -static int send_recv_daemon_info_internal(struct hip_common *msg,
>> - int opt_socket)
>> +g
>
> nit: This is now a long line.

I wonder whether if I had broken that line and it would have shown in the diff
you may have said it would have been ok to keep it in a single line.
Come on, it's 85 characters. That is not yet a long line. :p

> Anyway, this looks good to me now, so go ahead and push :)

Kk, merge is pushed in trunk revision 6121.

Revision history for this message
Diego Biurrun (diego-biurrun) wrote :

On Wed, Nov 09, 2011 at 04:01:33PM +0000, David Martin wrote:
> On Tue, Nov 8, 2011 at 8:55 PM, Diego Biurrun <email address hidden> wrote:
> > On Tue, Nov 08, 2011 at 05:12:08PM +0000, David Martin wrote:
> >> David Martin has proposed merging lp:~martin-lp/hipl/hipfwconf into lp:hipl.
> >>
> >> --- lib/core/message.c 2011-10-25 21:44:47 +0000
> >> +++ lib/core/message.c 2011-11-08 17:09:18 +0000
> >> @@ -319,23 +330,30 @@
> >>
> >> -static int send_recv_daemon_info_internal(struct hip_common *msg,
> >> - int opt_socket)
> >> +g
> >
> > nit: This is now a long line.
>
> I wonder whether if I had broken that line and it would have shown in the diff
> you may have said it would have been ok to keep it in a single line.
> Come on, it's 85 characters. That is not yet a long line. :p

Long lines are those that go over the 80 character mark.

Diego

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'doc/HOWTO.xml.in'
--- doc/HOWTO.xml.in 2011-11-03 09:21:12 +0000
+++ doc/HOWTO.xml.in 2011-11-08 17:09:18 +0000
@@ -594,7 +594,7 @@
594594
595 <itemizedlist>595 <itemizedlist>
596 <listitem><programlisting>Version of HIPL software. Ubuntu: dpkg -l 'hipl*'. Red Hat-based distros: rpm -qa | grep hipl</programlisting></listitem>596 <listitem><programlisting>Version of HIPL software. Ubuntu: dpkg -l 'hipl*'. Red Hat-based distros: rpm -qa | grep hipl</programlisting></listitem>
597 <listitem><programlisting>hipconf get ha all</programlisting></listitem>597 <listitem><programlisting>hipconf daemon get ha all</programlisting></listitem>
598 <listitem><programlisting>ip xfrm state</programlisting></listitem>598 <listitem><programlisting>ip xfrm state</programlisting></listitem>
599 <listitem><programlisting>uname -a</programlisting></listitem>599 <listitem><programlisting>uname -a</programlisting></listitem>
600 <listitem><programlisting>lsb_release -a</programlisting></listitem>600 <listitem><programlisting>lsb_release -a</programlisting></listitem>
@@ -658,7 +658,7 @@
658658
659 <para>To use access the servers using HIP behind a NAT box, you659 <para>To use access the servers using HIP behind a NAT box, you
660 have two alternatives. Firstly, you enable the UDP660 have two alternatives. Firstly, you enable the UDP
661 encapsulation using "hipconf nat plain-udp". See <xref661 encapsulation using "hipconf daemon nat plain-udp". See <xref
662 linkend="ch_hip_nat" /> for more information. Secondly,662 linkend="ch_hip_nat" /> for more information. Secondly,
663 you can install miredo on your machine and make sure that HIP663 you can install miredo on your machine and make sure that HIP
664 uses the IPv6 address of the server.</para>664 uses the IPv6 address of the server.</para>
@@ -674,7 +674,7 @@
674 <title>Closing HIP Security Associations Manually</title>674 <title>Closing HIP Security Associations Manually</title>
675 <para>675 <para>
676 You can use the hipconf tool to reset HIP SAs manually. Type676 You can use the hipconf tool to reset HIP SAs manually. Type
677 "hipconf rst all" to close all SAs.677 "hipconf daemon rst all" to close all SAs.
678 </para>678 </para>
679 </section>679 </section>
680680
@@ -761,10 +761,10 @@
761 HIT_OF_XXX with the HIT of the host XXX. The hip daemon loads (and761 HIT_OF_XXX with the HIT of the host XXX. The hip daemon loads (and
762 creates if necessary) the host identities from @sysconfdir@ automatically.762 creates if necessary) the host identities from @sysconfdir@ automatically.
763 If you want to know the default HIT of the localhost, run763 If you want to know the default HIT of the localhost, run
764 "hipconf get hi default".764 "hipconf daemon get hi default".
765 You can list all HITs of the machine with "hipconf get hi all". By765 You can list all HITs of the machine with "hipconf daemon get hi all". By
766 default, you'll see only one. If you want to use all four HITs of the766 default, you'll see only one. If you want to use all four HITs of the
767 host, you have to invoke "hipconf add hi default". The use of multiple767 host, you have to invoke "hipconf daemon add hi default". The use of multiple
768 local HITs is not currently recommended!768 local HITs is not currently recommended!
769 </para>769 </para>
770 <para>770 <para>
@@ -773,7 +773,7 @@
773 possible but not necessary:773 possible but not necessary:
774 </para>774 </para>
775 <para>775 <para>
776 hipconf add map PEER_HIT PEER_IP776 hipconf daemon add map PEER_HIT PEER_IP
777 </para>777 </para>
778 <para>778 <para>
779 You can also add the mapping to "@sysconfdir@/hipd_config" and restart hipd.779 You can also add the mapping to "@sysconfdir@/hipd_config" and restart hipd.
@@ -830,18 +830,18 @@
830 more information messages with the daemons or capturing the network packets.</para>830 more information messages with the daemons or capturing the network packets.</para>
831 <para>The log messages displayed by the hip daemon can be changed dynamically:</para>831 <para>The log messages displayed by the hip daemon can be changed dynamically:</para>
832 <para>832 <para>
833 hipconf debug none # &lt;only HIP_DIE and HIP_ASSERT messages are shown&gt;833 hipconf daemon debug none # &lt;only HIP_DIE and HIP_ASSERT messages are shown&gt;
834 </para>834 </para>
835 <para>835 <para>
836 hipconf debug low # &lt;shows HIP_DIE, HIP_ASSERT and HIP_ERROR836 hipconf daemon debug low # &lt;shows HIP_DIE, HIP_ASSERT and HIP_ERROR
837 messages&gt;837 messages&gt;
838 </para>838 </para>
839 <para>839 <para>
840 hipconf debug medium # &lt;shows HIP_DIE, HIP_ASSERT, HIP_ERROR and840 hipconf daemon debug medium # &lt;shows HIP_DIE, HIP_ASSERT, HIP_ERROR and
841 HIP_INFO messages&gt;841 HIP_INFO messages&gt;
842 </para>842 </para>
843 <para>843 <para>
844 hipconf debug all # &lt;shows all messages, including844 hipconf daemon debug all # &lt;shows all messages, including
845 HIP_DEBUG&gt;845 HIP_DEBUG&gt;
846 </para>846 </para>
847 <para>847 <para>
@@ -882,14 +882,14 @@
882 </para>882 </para>
883 </listitem>883 </listitem>
884 <listitem>884 <listitem>
885 <para>Add the information with hipconf add map885 <para>Add the information with hipconf daemon add map
886 <itemizedlist>886 <itemizedlist>
887 <listitem><para>hipconf add map OOPS_HIT OOPS_IP [OOPS_LSI] </para></listitem>887 <listitem><para>hipconf daemon add map OOPS_HIT OOPS_IP [OOPS_LSI] </para></listitem>
888 </itemizedlist>888 </itemizedlist>
889 </para>889 </para>
890 </listitem>890 </listitem>
891 </itemizedlist>891 </itemizedlist>
892 <para>If the command hipconf add map is not executed, we must add the peer IP in892 <para>If the command hipconf daemon add map is not executed, we must add the peer IP in
893 the file /etc/hosts</para>893 the file /etc/hosts</para>
894 <itemizedlist>894 <itemizedlist>
895 <listitem><para>OOPS_IP oops</para></listitem>895 <listitem><para>OOPS_IP oops</para></listitem>
@@ -929,7 +929,7 @@
929 <formalpara><title>Running the application</title><para></para></formalpara>929 <formalpara><title>Running the application</title><para></para></formalpara>
930 <para>Once we have finished the step before and started running hipd and hipfw, we can930 <para>Once we have finished the step before and started running hipd and hipfw, we can
931 run the application. If the LSI has been generated automatically, we can check its931 run the application. If the LSI has been generated automatically, we can check its
932 value with hipconf get ha OOPS_HIT or hipconf get ha all.932 value with hipconf daemon get ha OOPS_HIT or hipconf daemon get ha all.
933 Afterwards, we start running the application, e.g.:933 Afterwards, we start running the application, e.g.:
934 </para>934 </para>
935 <itemizedlist>935 <itemizedlist>
@@ -989,7 +989,7 @@
989 </itemizedlist>989 </itemizedlist>
990 <para>990 <para>
991 You can also trigger the handover message exchange without991 You can also trigger the handover message exchange without
992 changing IP addresses by running "hipconf manual-update". Note that this992 changing IP addresses by running "hipconf daemon manual-update". Note that this
993 only simulates the message exchange that would normally occur on IP993 only simulates the message exchange that would normally occur on IP
994 address changes and does not test handover detection.994 address changes and does not test handover detection.
995 </para>995 </para>
@@ -1056,9 +1056,9 @@
1056 /etc/hosts.1056 /etc/hosts.
1057 </para>1057 </para>
1058 <para>1058 <para>
1059 3b. Execute "hipconf add map PEER_HIT PEER_IP" and use the HIT directly1059 3b. Execute "hipconf daemon add map PEER_HIT PEER_IP" and use the HIT directly
1060 in the application. You can insert the1060 in the application. You can insert the
1061 hipconf command also to @sysconfdir@/hipd_config and restart hipd.1061 hipconf command without daemon keyword also to @sysconfdir@/hipd_config and restart hipd.
1062 </para>1062 </para>
1063 </section>1063 </section>
10641064
@@ -1107,7 +1107,7 @@
1107 run at that time):1107 run at that time):
1108 </para>1108 </para>
1109 <para>1109 <para>
1110 hipconf run normal|opp firefox1110 hipconf daemon run normal|opp firefox
1111 </para>1111 </para>
1112 </section>1112 </section>
1113 <section id="sec_sendmail">1113 <section id="sec_sendmail">
@@ -1167,7 +1167,7 @@
1167 </programlisting>1167 </programlisting>
1168 <para>1168 <para>
1169 The "HIT_OF_THE_CLIENT" should not be taken as literal. Replace it with the1169 The "HIT_OF_THE_CLIENT" should not be taken as literal. Replace it with the
1170 actual HIT of the client (run "hipconf get ha default" at the client host).1170 actual HIT of the client (run "hipconf daemon get ha default" at the client host).
1171 </para>1171 </para>
1172 <para>1172 <para>
1173 It should be noticed that you can also specify the HIT_OF_CLIENT at the1173 It should be noticed that you can also specify the HIT_OF_CLIENT at the
@@ -1412,7 +1412,7 @@
1412 </programlisting>1412 </programlisting>
1413 <para>1413 <para>
1414 Notice that &lt;hit-of-the-server&gt; should not be taken literally. Replace1414 Notice that &lt;hit-of-the-server&gt; should not be taken literally. Replace
1415 it with the HIT of the server (run "hipconf get hi default" at the server).1415 it with the HIT of the server (run "hipconf daemon get hi default" at the server).
1416 If you want to use LSIs instead of HITs, you shouldn't use the -V option1416 If you want to use LSIs instead of HITs, you shouldn't use the -V option
1417 and use LSIs as instructed in <xref linkend="interop_ip_v4_v6" />.1417 and use LSIs as instructed in <xref linkend="interop_ip_v4_v6" />.
1418 </para>1418 </para>
@@ -1624,15 +1624,15 @@
1624 </para>1624 </para>
16251625
1626 <para>1626 <para>
1627 With "hipconf hit-to-ip on", the HIP daemon uses IP addresses of1627 With "hipconf daemon hit-to-ip on", the HIP daemon uses IP addresses of
1628 5.7.d.1.c.c.8.d.0.6.3.b.a.4.6.2.5.0.5.2.e.4.7.5.e.1.0.0.1.0.0.2.hit-to-ip.infrahip.net.1628 5.7.d.1.c.c.8.d.0.6.3.b.a.4.6.2.5.0.5.2.e.4.7.5.e.1.0.0.1.0.0.2.hit-to-ip.infrahip.net.
1629 to contact peer host with HIT 2001:1e:574e:2505:264a:b360:d8cc:1d751629 to contact peer host with HIT 2001:1e:574e:2505:264a:b360:d8cc:1d75
1630 </para>1630 </para>
1631 <para>Default hit-to-ip.infrahip.net. suffix can be changed with1631 <para>Default hit-to-ip.infrahip.net. suffix can be changed with
1632 "hipconf hit-to-ip-set &lt;new.hit-to-ip.zone.&gt;. Please note it is independent from HIT_TO_IP_ZONE in @sysconfdir@/nsupdate.conf"1632 "hipconf daemon hit-to-ip-set &lt;new.hit-to-ip.zone.&gt;. Please note it is independent from HIT_TO_IP_ZONE in @sysconfdir@/nsupdate.conf"
1633 </para>1633 </para>
1634 <para>1634 <para>
1635 With "hipconf nsupdate on", the HIP daemon also maintains1635 With "hipconf daemon nsupdate on", the HIP daemon also maintains
1636 records in hit-to-ip.infrahip.net. Once you start hipd, it will1636 records in hit-to-ip.infrahip.net. Once you start hipd, it will
1637 call nsupdate.pl with HIT and IP address for every HIT of your1637 call nsupdate.pl with HIT and IP address for every HIT of your
1638 host. It is executed upon mobility events (i.e. address changes)1638 host. It is executed upon mobility events (i.e. address changes)
@@ -1799,7 +1799,7 @@
1799 the HIP daemon at the responder and use the "<emphasis>hipconf</emphasis>" tool from another1799 the HIP daemon at the responder and use the "<emphasis>hipconf</emphasis>" tool from another
1800 shell at the responder to get the default hi:1800 shell at the responder to get the default hi:
1801 <programlisting>1801 <programlisting>
1802 hipconf get hi default1802 hipconf daemon get hi default
1803 </programlisting>1803 </programlisting>
1804 Now, add this HIT in between the white list quotation marks in the1804 Now, add this HIT in between the white list quotation marks in the
1805 configuration file of the RVS / HIP relay server:1805 configuration file of the RVS / HIP relay server:
@@ -1849,10 +1849,10 @@
1849 otherwise modify the configuration file, you can reinitialize the server1849 otherwise modify the configuration file, you can reinitialize the server
1850 without restarting the daemon itself using the "<emphasis>hipconf</emphasis>" tool:1850 without restarting the daemon itself using the "<emphasis>hipconf</emphasis>" tool:
1851 <programlisting>1851 <programlisting>
1852 hipconf reinit service rvs</programlisting>1852 hipconf daemon reinit service rvs</programlisting>
1853 or1853 or
1854 <programlisting>1854 <programlisting>
1855 hipconf reinit service relay</programlisting>1855 hipconf daemon reinit service relay</programlisting>
1856 The reinitialization does not have any effect on the existing1856 The reinitialization does not have any effect on the existing
1857 RVS / HIP relay server clients, but only affects clients registering1857 RVS / HIP relay server clients, but only affects clients registering
1858 after the reinitialization.1858 after the reinitialization.
@@ -1963,7 +1963,7 @@
1963 that you would have in a normal base exchange execution not1963 that you would have in a normal base exchange execution not
1964 involving an RVS. Please make sure that you use the same HIT1964 involving an RVS. Please make sure that you use the same HIT
1965 here as &lt;RESPONDER HIT&gt; as what the1965 here as &lt;RESPONDER HIT&gt; as what the
1966 "<emphasis>hipconf get hi default</emphasis>"1966 "<emphasis>hipconf daemon get hi default</emphasis>"
1967 outputs at the responder.1967 outputs at the responder.
1968 </para>1968 </para>
1969 </listitem>1969 </listitem>
@@ -2012,14 +2012,14 @@
2012 </para></listitem>2012 </para></listitem>
2013 <listitem><para>2013 <listitem><para>
2014 At the rendezvous server, we have to indicate that we are willing to offer2014 At the rendezvous server, we have to indicate that we are willing to offer
2015 rendezvous service:<programlisting>hipconf add service rvs</programlisting>2015 rendezvous service:<programlisting>hipconf daemon add service rvs</programlisting>
2016 </para></listitem>2016 </para></listitem>
2017 <listitem id="listitem_rvs"><para>2017 <listitem id="listitem_rvs"><para>
2018 At the responder, we have to register to the rendezvous server:2018 At the responder, we have to register to the rendezvous server:
2019 <programlisting>hipconf add server rvs [RVS-HIT] &lt;RVS-IP or hostname&gt; &lt;LIFETIME-IN-SECONDS&gt;</programlisting>2019 <programlisting>hipconf daemon add server rvs [RVS-HIT] &lt;RVS-IP or hostname&gt; &lt;LIFETIME-IN-SECONDS&gt;</programlisting>
2020 This will launch a base exchange i.e. establish a HIP SA between the2020 This will launch a base exchange i.e. establish a HIP SA between the
2021 rendezvous server and the responder. Please use the default HIT of2021 rendezvous server and the responder. Please use the default HIT of
2022 the rendezvous server ("<emphasis>hipconf get hi default</emphasis>" at the RVS).2022 the rendezvous server ("<emphasis>hipconf daemon get hi default</emphasis>" at the RVS).
2023 The &lt;LIFETIME-IN-SECONDS&gt; value represents the number of seconds2023 The &lt;LIFETIME-IN-SECONDS&gt; value represents the number of seconds
2024 we would like our service registration to last, but it is not2024 we would like our service registration to last, but it is not
2025 necessarily the number of seconds we are granted the service.2025 necessarily the number of seconds we are granted the service.
@@ -2053,7 +2053,7 @@
2053 To cancel the rendezvous service (without killing the HIP2053 To cancel the rendezvous service (without killing the HIP
2054 daemon) type:2054 daemon) type:
2055 <programlisting>2055 <programlisting>
2056 hipconf del service rvs2056 hipconf daemon del service rvs
2057 </programlisting>2057 </programlisting>
2058 This will delete all existing rendezvous server registrations2058 This will delete all existing rendezvous server registrations
2059 and remove the rendezvous service from the offered services.2059 and remove the rendezvous service from the offered services.
@@ -2064,7 +2064,7 @@
2064 To reinitialize the rendezvous service after modifications to2064 To reinitialize the rendezvous service after modifications to
2065 the configuration file (without killing the HIP daemon) type:2065 the configuration file (without killing the HIP daemon) type:
2066 <programlisting>2066 <programlisting>
2067 hipconf reinit service rvs2067 hipconf daemon reinit service rvs
2068 </programlisting>2068 </programlisting>
2069 The changes that you have made to the configuration file affect the2069 The changes that you have made to the configuration file affect the
2070 clients registering after the reinitialization.2070 clients registering after the reinitialization.
@@ -2082,7 +2082,7 @@
2082 <para>2082 <para>
2083 To cancel the registration to the rendezvous service type:2083 To cancel the registration to the rendezvous service type:
2084 <programlisting>2084 <programlisting>
2085 hipconf del server rvs &lt;RVS-HIT&gt; &lt;RVS-IP&gt;2085 hipconf daemon del server rvs &lt;RVS-HIT&gt; &lt;RVS-IP&gt;
2086 </programlisting>2086 </programlisting>
2087 This will send a HIP message asking for rendezvous service2087 This will send a HIP message asking for rendezvous service
2088 cancellation to the rendezvous server.2088 cancellation to the rendezvous server.
@@ -2237,17 +2237,17 @@
2237 At the relay server, we have to indicate that we are willing to offer2237 At the relay server, we have to indicate that we are willing to offer
2238 relay service:2238 relay service:
2239 <programlisting>2239 <programlisting>
2240 hipconf add service relay2240 hipconf daemon add service relay
2241 </programlisting>2241 </programlisting>
2242 </para></listitem>2242 </para></listitem>
2243 <listitem><para>2243 <listitem><para>
2244 At the responder, we have to register to the relay server:2244 At the responder, we have to register to the relay server:
2245 <programlisting>2245 <programlisting>
2246 hipconf add server relay &lt;RELAY-HIT&gt; &lt;RELAY-IP&gt; &lt;LIFETIME-IN-SECONDS&gt;2246 hipconf daemon add server relay &lt;RELAY-HIT&gt; &lt;RELAY-IP&gt; &lt;LIFETIME-IN-SECONDS&gt;
2247 </programlisting>2247 </programlisting>
2248 This will launch a base exchange i.e. establish a HIP SA between the2248 This will launch a base exchange i.e. establish a HIP SA between the
2249 relay server and the responder. Please use the default HIT of the2249 relay server and the responder. Please use the default HIT of the
2250 relay server ("<emphasis>hipconf get hi default</emphasis>" at2250 relay server ("<emphasis>hipconf daemon get hi default</emphasis>" at
2251 the relay server). The &lt;LIFETIME-IN-SECONDS&gt; value represents2251 the relay server). The &lt;LIFETIME-IN-SECONDS&gt; value represents
2252 the number of seconds we would like our service registration to2252 the number of seconds we would like our service registration to
2253 last, but it is not necessarily the number of seconds we are granted2253 last, but it is not necessarily the number of seconds we are granted
@@ -2285,7 +2285,7 @@
2285 To cancel the relay service (without killing the HIP daemon)2285 To cancel the relay service (without killing the HIP daemon)
2286 type:2286 type:
2287 <programlisting>2287 <programlisting>
2288 hipconf del service relay2288 hipconf daemon del service relay
2289 </programlisting>2289 </programlisting>
2290 This will delete all existing relay server registrations2290 This will delete all existing relay server registrations
2291 and remove the relay service from the offered services.2291 and remove the relay service from the offered services.
@@ -2296,7 +2296,7 @@
2296 To reinitialize the relay service after modifications to2296 To reinitialize the relay service after modifications to
2297 the configuration file (without killing the HIP daemon) type:2297 the configuration file (without killing the HIP daemon) type:
2298 <programlisting>2298 <programlisting>
2299 hipconf reinit service relay2299 hipconf daemon reinit service relay
2300 </programlisting>2300 </programlisting>
2301 The changes that you have made to the configuration file affect the2301 The changes that you have made to the configuration file affect the
2302 clients registering after the reinitialization.2302 clients registering after the reinitialization.
@@ -2314,7 +2314,7 @@
2314 <para>2314 <para>
2315 To cancel the registration to the relay service type:2315 To cancel the registration to the relay service type:
2316 <programlisting>2316 <programlisting>
2317 hipconf del server relay &lt;RELAY-HIT&gt; &lt;RELAY-IP&gt;2317 hipconf daemon del server relay &lt;RELAY-HIT&gt; &lt;RELAY-IP&gt;
2318 </programlisting>2318 </programlisting>
2319 This will send a HIP message asking for relay service2319 This will send a HIP message asking for relay service
2320 cancellation to the relay server.2320 cancellation to the relay server.
@@ -2494,7 +2494,7 @@
2494 example, to request a service identified by number 1 (the2494 example, to request a service identified by number 1 (the
2495 rendezvous service), you can type2495 rendezvous service), you can type
2496 <programlisting>2496 <programlisting>
2497 hipconf add server 1 &lt;SERVER-HIT&gt; &lt;SERVER-IP&gt; &lt;LIFETIME-IN-SECONDS&gt;2497 hipconf daemon add server 1 &lt;SERVER-HIT&gt; &lt;SERVER-IP&gt; &lt;LIFETIME-IN-SECONDS&gt;
2498 </programlisting>2498 </programlisting>
2499 Notice, however, that if the server does not support the2499 Notice, however, that if the server does not support the
2500 service you have requested, a request is never sent.2500 service you have requested, a request is never sent.
@@ -2506,7 +2506,7 @@
2506 can chain the service types. For example, to request services2506 can chain the service types. For example, to request services
2507 identified by registration types 3, 10 and 245 you can type:2507 identified by registration types 3, 10 and 245 you can type:
2508 <programlisting>2508 <programlisting>
2509 hipconf add server 3 10 245 &lt;SERVER-HIT&gt; &lt;SERVER-IP&gt; &lt;LIFETIME-IN-SECONDS&gt;2509 hipconf daemon add server 3 10 245 &lt;SERVER-HIT&gt; &lt;SERVER-IP&gt; &lt;LIFETIME-IN-SECONDS&gt;
2510 </programlisting>2510 </programlisting>
2511 Using this chaining method one can request up to ten2511 Using this chaining method one can request up to ten
2512 services with one REG_REQUEST parameter.2512 services with one REG_REQUEST parameter.
@@ -2518,7 +2518,7 @@
2518 request you can chain the service types as with2518 request you can chain the service types as with
2519 registration.2519 registration.
2520 <programlisting>2520 <programlisting>
2521 hipconf del server 3 10 245 &lt;SERVER-HIT&gt; &lt;SERVER-IP&gt;2521 hipconf daemon del server 3 10 245 &lt;SERVER-HIT&gt; &lt;SERVER-IP&gt;
2522 </programlisting>2522 </programlisting>
2523 Using this chaining method one can request up to ten2523 Using this chaining method one can request up to ten
2524 service cancellations with one REG_REQUEST parameter.2524 service cancellations with one REG_REQUEST parameter.
@@ -2696,7 +2696,7 @@
2696 </para>2696 </para>
2697 <para>The NAT traversal can be experimented in a similar way as depicted2697 <para>The NAT traversal can be experimented in a similar way as depicted
2698 in earlier sections. The only difference is that you have to tell the2698 in earlier sections. The only difference is that you have to tell the
2699 initiator manually that it is behind a NAT using "hipconf nat on".2699 initiator manually that it is behind a NAT using "hipconf daemon nat on".
2700 After this, you can initiate the base exchange2700 After this, you can initiate the base exchange
2701 according to the previous instructions. The manual configuration is2701 according to the previous instructions. The manual configuration is
2702 currently required because support for automatic NAT detection (STUN)2702 currently required because support for automatic NAT detection (STUN)
@@ -2709,10 +2709,10 @@
2709 </para>2709 </para>
2710 <itemizedlist>2710 <itemizedlist>
2711 <listitem><para>2711 <listitem><para>
2712 hipconf nat plain-udp2712 hipconf daemon nat plain-udp
2713 </para> </listitem>2713 </para> </listitem>
2714 <listitem><para>2714 <listitem><para>
2715 hipconf add map peer_hit peer_ipv4_addr2715 hipconf daemon add map peer_hit peer_ipv4_addr
2716 </para> </listitem>2716 </para> </listitem>
2717 <listitem><para>2717 <listitem><para>
2718 ping6 -I source_hit dst_hit2718 ping6 -I source_hit dst_hit
@@ -2735,7 +2735,7 @@
2735 by installing the Miredo client software. Then, establish HIP connections2735 by installing the Miredo client software. Then, establish HIP connections
2736 to Teredo addresses (check ifconfig teredo) at the client side as2736 to Teredo addresses (check ifconfig teredo) at the client side as
2737 instructed in <xref linkend="ch_basictest" />. As Teredo is a NAT traversal2737 instructed in <xref linkend="ch_basictest" />. As Teredo is a NAT traversal
2738 solution by itself, you don't have use UDP encapsulation for HIP (hipconf nat none).2738 solution by itself, you don't have use UDP encapsulation for HIP (hipconf daemon nat none).
2739 </para>2739 </para>
2740 <para>2740 <para>
2741 See2741 See
@@ -2770,7 +2770,7 @@
2770 relays HIP control and ESP data traffic. You can use one the InfraHIP servers2770 relays HIP control and ESP data traffic. You can use one the InfraHIP servers
2771 or set up your own as instructed in <xref linkend="ch_rvs_relay"2771 or set up your own as instructed in <xref linkend="ch_rvs_relay"
2772 />. Both Initiator and Responder must be configured with2772 />. Both Initiator and Responder must be configured with
2773 "hipconf nat ice-udp". Then Initiator must run the base exchange through the2773 "hipconf daemon nat ice-udp". Then Initiator must run the base exchange through the
2774 relay server.2774 relay server.
2775 </para>2775 </para>
27762776
@@ -2816,12 +2816,12 @@
28162816
2817<para>2817<para>
2818<programlisting>2818<programlisting>
2819hipconf shotgun on2819hipconf daemon shotgun on
2820</programlisting>2820</programlisting>
2821</para>2821</para>
28222822
2823 <para>The same line can be also included in @sysconfdir@/hipd_config2823 <para>The same line can be also included in @sysconfdir@/hipd_config
2824 without the "hipconf" prefix.2824 without the "hipconf daemon" prefix.
2825 </para>2825 </para>
28262826
2827 <para>At the time of writing this, the shotgun extension did not yet2827 <para>At the time of writing this, the shotgun extension did not yet
28282828
=== modified file 'firewall/cache.c'
--- firewall/cache.c 2011-10-25 21:14:16 +0000
+++ firewall/cache.c 2011-11-08 17:09:18 +0000
@@ -281,7 +281,7 @@
281 }281 }
282 }282 }
283283
284 /* Note: this function is also reached by "hipconf rst all"284 /* Note: this function is also reached by "hipconf daemon rst all"
285 * so we don't want to uninitialize hash table here. Instead,285 * so we don't want to uninitialize hash table here. Instead,
286 * we handle it in firewall_exit(). */286 * we handle it in firewall_exit(). */
287287
288288
=== modified file 'firewall/conntrack.c'
--- firewall/conntrack.c 2011-10-25 21:14:16 +0000
+++ firewall/conntrack.c 2011-11-08 17:09:18 +0000
@@ -910,7 +910,7 @@
910 * Relay to pass e.g. p2p-unfriendly NAT boxes. The ESP relay mode910 * Relay to pass e.g. p2p-unfriendly NAT boxes. The ESP relay mode
911 * assumes that the HIP relay (in hipd) and ESP relay (in hipfw) are911 * assumes that the HIP relay (in hipd) and ESP relay (in hipfw) are
912 * running on the same middlehost in a public network. The responder912 * running on the same middlehost in a public network. The responder
913 * has to register to the relay with "hipconf add server full-relay"913 * has to register to the relay with "hipconf daemon add server full-relay"
914 * which operates as defined in <a914 * which operates as defined in <a
915 * href="http://tools.ietf.org/html/draft-ietf-hip-nat-traversal"> NAT915 * href="http://tools.ietf.org/html/draft-ietf-hip-nat-traversal"> NAT
916 * traversal for HIP</a>. Then the initiator can contact the responder916 * traversal for HIP</a>. Then the initiator can contact the responder
@@ -2244,3 +2244,56 @@
2244 remove_connection(conn_list->data);2244 remove_connection(conn_list->data);
2245 }2245 }
2246}2246}
2247
2248/**
2249 * Prepare given message with host association info from the tracked connections.
2250 *
2251 * @param msg The message where the info is written.
2252 * @return 0 on success
2253 * -1 on error
2254 */
2255int hip_fw_handle_get_ha_info(struct hip_common *msg)
2256{
2257 struct hip_hadb_user_info_state hid = { { { { 0 } } } };
2258 struct slist *iter_conn;
2259 struct connection *conn;
2260 struct hip_data *data;
2261
2262 if (!msg) {
2263 HIP_ERROR("Missing message parameter.\n");
2264 return -1;
2265 }
2266
2267 if (conn_list == NULL) {
2268 HIP_DEBUG("No tracked connections to return.\n");
2269 return 0;
2270 }
2271
2272 hip_msg_init(msg);
2273 if (hip_build_user_hdr(msg, HIP_MSG_GET_HA_INFO, 0) < 0) {
2274 HIP_ERROR("Failed to build GET_HA_INFO message header.\n");
2275 return -1;
2276 }
2277
2278 iter_conn = conn_list;
2279 while (iter_conn) {
2280 conn = iter_conn->data;
2281 data = conn->original.hip_tuple->data;
2282
2283 // build HA_INFO with info from connection initiator
2284 hid.state = conn->state;
2285 ipv6_addr_copy(&hid.hit_our, &data->src_hit);
2286 ipv6_addr_copy(&hid.hit_peer, &data->dst_hit);
2287 hid.nat_udp_port_local = conn->original.src_port;
2288 hid.nat_udp_port_peer = conn->original.dst_port;
2289
2290 if (hip_build_param_contents(msg, &hid, HIP_PARAM_HA_INFO, sizeof(hid)) < 0) {
2291 HIP_ERROR("Failed to build initiator HA_INFO parameter.\n");
2292 return -1;
2293 }
2294
2295 iter_conn = iter_conn->next;
2296 }
2297
2298 return 0;
2299}
22472300
=== modified file 'firewall/conntrack.h'
--- firewall/conntrack.h 2011-07-18 16:31:37 +0000
+++ firewall/conntrack.h 2011-11-08 17:09:18 +0000
@@ -63,4 +63,6 @@
63void hip_fw_conntrack_periodic_cleanup(void);63void hip_fw_conntrack_periodic_cleanup(void);
64void hip_fw_uninit_conntrack(void);64void hip_fw_uninit_conntrack(void);
6565
66int hip_fw_handle_get_ha_info(struct hip_common *msg);
67
66#endif /* HIP_FIREWALL_CONNTRACK_H */68#endif /* HIP_FIREWALL_CONNTRACK_H */
6769
=== modified file 'firewall/firewall.c'
--- firewall/firewall.c 2011-10-30 11:41:51 +0000
+++ firewall/firewall.c 2011-11-08 17:09:18 +0000
@@ -1672,7 +1672,7 @@
1672 n = recvfrom(hip_fw_async_sock, msg, sizeof(struct hip_common),1672 n = recvfrom(hip_fw_async_sock, msg, sizeof(struct hip_common),
1673 MSG_PEEK, (struct sockaddr *) &sock_addr, &alen);1673 MSG_PEEK, (struct sockaddr *) &sock_addr, &alen);
1674 if (n < 0) {1674 if (n < 0) {
1675 HIP_ERROR("Error receiving message header from daemon.\n");1675 HIP_ERROR("Error receiving message header.\n");
1676 return -1;1676 return -1;
1677 }1677 }
16781678
@@ -1701,24 +1701,13 @@
1701 (struct sockaddr *) &sock_addr, &alen);1701 (struct sockaddr *) &sock_addr, &alen);
17021702
1703 if (n < 0) {1703 if (n < 0) {
1704 HIP_ERROR("Error receiving message parameters from daemon.\n");1704 HIP_ERROR("Error receiving message parameters.\n");
1705 return -1;1705 return -1;
1706 }1706 }
17071707
1708 HIP_ASSERT(n == len);1708 HIP_ASSERT(n == len);
17091709
1710 if (ntohs(sock_addr.sin6_port) != HIP_DAEMON_LOCAL_PORT) {1710 if (hip_handle_msg(msg, (struct sockaddr *) &sock_addr) < 0) {
1711 int type = hip_get_msg_type(msg);
1712 if (type == HIP_MSG_FW_BEX_DONE) {
1713 HIP_DEBUG("HIP_MSG_FW_BEX_DONE\n");
1714 HIP_DEBUG("%d == %d\n", ntohs(sock_addr.sin6_port),
1715 HIP_DAEMON_LOCAL_PORT);
1716 }
1717 HIP_DEBUG("Drop, message not from hipd\n");
1718 return -1;
1719 }
1720
1721 if (hip_handle_msg(msg) < 0) {
1722 HIP_ERROR("Error handling message\n");1711 HIP_ERROR("Error handling message\n");
1723 return -1;1712 return -1;
1724 }1713 }
@@ -1847,8 +1836,6 @@
1847 sock_addr.sin6_addr = in6addr_loopback;1836 sock_addr.sin6_addr = in6addr_loopback;
1848 HIP_IFEL(bind(hip_fw_async_sock, (struct sockaddr *) &sock_addr, sizeof(sock_addr)), -1,1837 HIP_IFEL(bind(hip_fw_async_sock, (struct sockaddr *) &sock_addr, sizeof(sock_addr)), -1,
1849 "Bind on firewall socket addr failed. Give -k option to kill old hipfw\n");1838 "Bind on firewall socket addr failed. Give -k option to kill old hipfw\n");
1850 HIP_IFEL(hip_daemon_connect(hip_fw_async_sock), -1,
1851 "connecting socket failed\n");
18521839
1853 /* Starting hipfw does not always work when hipfw starts first -miika */1840 /* Starting hipfw does not always work when hipfw starts first -miika */
1854 if (hip_userspace_ipsec || hip_lsi_support) {1841 if (hip_userspace_ipsec || hip_lsi_support) {
@@ -1944,7 +1931,7 @@
1944 }1931 }
19451932
1946 if (FD_ISSET(hip_fw_async_sock, &read_fdset)) {1933 if (FD_ISSET(hip_fw_async_sock, &read_fdset)) {
1947 HIP_DEBUG("****** Received HIPD message ******\n");1934 HIP_DEBUG("****** Received user message ******\n");
1948 err = fw_handle_hipd_message(msg);1935 err = fw_handle_hipd_message(msg);
1949 }1936 }
19501937
@@ -2009,3 +1996,31 @@
20091996
2010 return &default_lsi;1997 return &default_lsi;
2011}1998}
1999
2000/**
2001 * Send a message via the firewall socket for asynchronous messages.
2002 * Caller is responsible for setting up the message.
2003 *
2004 * @param msg The message to be sent.
2005 * @param addr The destination address.
2006 *
2007 * @return 0 on success
2008 * -1 on error
2009 */
2010int hip_fw_send_message(const struct hip_common *const msg,
2011 const struct sockaddr *const addr)
2012{
2013 uint16_t len;
2014
2015 if (msg == NULL || addr == NULL) {
2016 HIP_ERROR("Empty message or address.\n");
2017 return -1;
2018 }
2019
2020 len = hip_get_msg_total_len(msg);
2021 if (sendto(hip_fw_async_sock, msg, len, 0, addr, hip_sockaddr_len(addr)) != len) {
2022 return -1;
2023 }
2024
2025 return 0;
2026}
20122027
=== modified file 'firewall/firewall.h'
--- firewall/firewall.h 2011-04-05 16:44:22 +0000
+++ firewall/firewall.h 2011-11-08 17:09:18 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (c) 2010 Aalto University and RWTH Aachen University.2 * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University.
3 *3 *
4 * Permission is hereby granted, free of charge, to any person4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation5 * obtaining a copy of this software and associated documentation
@@ -55,5 +55,7 @@
55void hip_fw_uninit_esp_relay(void);55void hip_fw_uninit_esp_relay(void);
56hip_hit_t *hip_fw_get_default_hit(void);56hip_hit_t *hip_fw_get_default_hit(void);
57hip_lsi_t *hip_fw_get_default_lsi(void);57hip_lsi_t *hip_fw_get_default_lsi(void);
58int hip_fw_send_message(const struct hip_common *const msg,
59 const struct sockaddr *const addr);
5860
59#endif /* HIP_FIREWALL_FIREWALL_H */61#endif /* HIP_FIREWALL_FIREWALL_H */
6062
=== modified file 'firewall/firewall_control.c'
--- firewall/firewall_control.c 2011-10-25 21:14:16 +0000
+++ firewall/firewall_control.c 2011-11-08 17:09:18 +0000
@@ -42,8 +42,10 @@
42#include "lib/core/debug.h"42#include "lib/core/debug.h"
43#include "lib/core/ife.h"43#include "lib/core/ife.h"
44#include "lib/core/message.h"44#include "lib/core/message.h"
45#include "lib/core/prefix.h"
45#include "lib/core/protodefs.h"46#include "lib/core/protodefs.h"
46#include "cache.h"47#include "cache.h"
48#include "conntrack.h"
47#include "firewall.h"49#include "firewall.h"
48#include "user_ipsec_fw_msg.h"50#include "user_ipsec_fw_msg.h"
49#include "user_ipsec_sadb.h"51#include "user_ipsec_sadb.h"
@@ -91,12 +93,13 @@
91}93}
9294
93/**95/**
94 * distribute a message from hipd to the respective extension handler96 * distribute a user message to the respective extension handler
95 *97 *
96 * @param msg pointer to the received user message98 * @param msg pointer to the received user message
99 * @param addr destination address for a reply
97 * @return 0 on success, else -1100 * @return 0 on success, else -1
98 */101 */
99int hip_handle_msg(struct hip_common *msg)102int hip_handle_msg(struct hip_common *msg, struct sockaddr *addr)
100{103{
101 int type, err = 0;104 int type, err = 0;
102 struct hip_common *msg_out = NULL;105 struct hip_common *msg_out = NULL;
@@ -150,12 +153,36 @@
150 HIP_IFEL(hip_send_recv_daemon_info(msg_out, 1, hip_fw_sock), -1,153 HIP_IFEL(hip_send_recv_daemon_info(msg_out, 1, hip_fw_sock), -1,
151 "Couldn't notify daemon of firewall presence\n");154 "Couldn't notify daemon of firewall presence\n");
152 break;155 break;
156 case HIP_MSG_GET_HA_INFO:
157 HIP_IFEL(hip_fw_handle_get_ha_info(msg), -1,
158 "Could not handle GET_HA message.\n");
159 HIP_IFEL(hip_fw_send_message(msg, addr), -1,
160 "Could not send HA reply.\n");
161 break;
153 default:162 default:
154 HIP_ERROR("Unhandled message type %d\n", type);163 HIP_ERROR("Unhandled message type %d\n", type);
155 err = -1;164 err = -1;
156 break;165 break;
157 }166 }
167
158out_err:168out_err:
169 if (hip_get_msg_response(msg)) {
170 HIP_DEBUG("Send response\n");
171 if (err) {
172 hip_hdr msg_type = hip_get_msg_type(msg);
173 hip_msg_init(msg);
174 hip_build_user_hdr(msg, msg_type, 0);
175 hip_set_msg_err(msg, 1);
176 }
177 HIP_DEBUG("Sending message (type=%d) response\n",
178 hip_get_msg_type(msg));
179 if (hip_fw_send_message(msg, addr) == -1) {
180 err = -1;
181 } else {
182 HIP_DEBUG("Response sent ok\n");
183 }
184 }
185
159 free(msg_out);186 free(msg_out);
160 return err;187 return err;
161}188}
162189
=== modified file 'firewall/firewall_control.h'
--- firewall/firewall_control.h 2010-10-15 15:29:14 +0000
+++ firewall/firewall_control.h 2011-11-08 17:09:18 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (c) 2010 Aalto University and RWTH Aachen University.2 * Copyright (c) 2010-2011 Aalto University and RWTH Aachen University.
3 *3 *
4 * Permission is hereby granted, free of charge, to any person4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation5 * obtaining a copy of this software and associated documentation
@@ -28,6 +28,6 @@
2828
29#include "lib/core/protodefs.h"29#include "lib/core/protodefs.h"
3030
31int hip_handle_msg(struct hip_common *msg);31int hip_handle_msg(struct hip_common *msg, struct sockaddr *addr);
3232
33#endif /* HIP_FIREWALL_FIREWALL_CONTROL_H */33#endif /* HIP_FIREWALL_FIREWALL_CONTROL_H */
3434
=== modified file 'hipd/init.c'
--- hipd/init.c 2011-11-03 09:21:12 +0000
+++ hipd/init.c 2011-11-08 17:09:18 +0000
@@ -164,7 +164,7 @@
164}164}
165165
166#define HIPL_CONFIG_FILE_EX \166#define HIPL_CONFIG_FILE_EX \
167 "# Format of this file is as with hipconf, but without hipconf prefix\n\167 "# Format of this file is as with hipconf, but without \"hipconf daemon\" prefix\n\
168# add hi default # add all four HITs (see bug id 592127)\n\168# add hi default # add all four HITs (see bug id 592127)\n\
169# add map HIT IP # preload some HIT-to-IP mappings to hipd\n\169# add map HIT IP # preload some HIT-to-IP mappings to hipd\n\
170# add service rvs # the host acts as HIP rendezvous (see also HIPL_SYSCONFDIR/relay_config)\n\170# add service rvs # the host acts as HIP rendezvous (see also HIPL_SYSCONFDIR/relay_config)\n\
@@ -549,7 +549,7 @@
549 /* Three steps because multiple large keys will not fit in the same message */549 /* Three steps because multiple large keys will not fit in the same message */
550550
551 /* DSA keys and RSA anonymous are not loaded by default until bug id551 /* DSA keys and RSA anonymous are not loaded by default until bug id
552 * 592127 is properly solved. Run hipconf add hi default if you want to552 * 592127 is properly solved. Run hipconf daemon add hi default if you want to
553 * enable non-default HITs. */553 * enable non-default HITs. */
554554
555 /* rsa pub */555 /* rsa pub */
556556
=== modified file 'hipd/nat.c'
--- hipd/nat.c 2011-10-25 21:14:16 +0000
+++ hipd/nat.c 2011-11-08 17:09:18 +0000
@@ -209,7 +209,7 @@
209 *209 *
210 * @return zero on success, or negative error value on error.210 * @return zero on success, or negative error value on error.
211 * @todo Extend this to handle peer_hit case for211 * @todo Extend this to handle peer_hit case for
212 * <code>"hipconf hip nat peer_hit"</code> This would be helpful in212 * <code>"hipconf daemon hip nat peer_hit"</code> This would be helpful in
213 * multihoming case.213 * multihoming case.
214 */214 */
215int hip_user_nat_mode(int nat_mode)215int hip_user_nat_mode(int nat_mode)
216216
=== modified file 'hipd/registration.c'
--- hipd/registration.c 2011-10-25 21:44:47 +0000
+++ hipd/registration.c 2011-11-08 17:09:18 +0000
@@ -1574,7 +1574,7 @@
1574 }1574 }
15751575
1576 /* Workaround for registration when a mapping already pre-exists1576 /* Workaround for registration when a mapping already pre-exists
1577 * (inserted e.g. with "hipconf add map"). This can be removed1577 * (inserted e.g. with "hipconf daemon add map"). This can be removed
1578 * after bug id 592135 is resolved. */1578 * after bug id 592135 is resolved. */
1579 if (entry->state != HIP_STATE_NONE || HIP_STATE_UNASSOCIATED) {1579 if (entry->state != HIP_STATE_NONE || HIP_STATE_UNASSOCIATED) {
1580 struct hip_common *msg2 = calloc(HIP_MAX_PACKET, 1);1580 struct hip_common *msg2 = calloc(HIP_MAX_PACKET, 1);
15811581
=== modified file 'lib/core/conf.c'
--- lib/core/conf.c 2011-11-08 14:19:35 +0000
+++ lib/core/conf.c 2011-11-08 17:09:18 +0000
@@ -77,9 +77,9 @@
7777
78/**78/**
79 * hipconf tool actions. These are numerical values for the first commandline79 * hipconf tool actions. These are numerical values for the first commandline
80 * argument. For example in "tools/hipconf get hi default" -command "get"80 * argument. For example in "tools/hipconf daemon get hi default"
81 * is the action. If you want a new action named as 'NEWACT', define a81 * -command "get" is the action. If you want a new action named as 'NEWACT',
82 * constant variable which has value between 0 and ACTION_MAX.82 * define a constant variable which has value between 0 and ACTION_MAX.
83 * Probably you also need to increase the value of ACTION_MAX.83 * Probably you also need to increase the value of ACTION_MAX.
84 * @see conf_get_action()84 * @see conf_get_action()
85 */85 */
@@ -181,6 +181,11 @@
181/* #define TYPE_RELAY 22 */181/* #define TYPE_RELAY 22 */
182182
183/**183/**
184 * The daemon process to be configured by the conf command.
185 */
186static enum daemon_name { HIP_DAEMON, HIP_FIREWALL, UNKNOWN_KEYWORD } daemon_name;
187
188/**
184 * A help string containing the usage of @c hipconf and also189 * A help string containing the usage of @c hipconf and also
185 * @c HIPL_SYSCONFDIR/hipd_config.190 * @c HIPL_SYSCONFDIR/hipd_config.
186 *191 *
@@ -188,6 +193,9 @@
188 * for the action.193 * for the action.
189 */194 */
190static const char *hipconf_usage =195static const char *hipconf_usage =
196 HIPCONF_HIPD_KEYWORD
197 " <command>\n\n"
198 "HIP daemon commands:\n"
191 "add map <hit> <ip> [lsi]\n"199 "add map <hit> <ip> [lsi]\n"
192 "get map <hit | lsi>\n"200 "get map <hit | lsi>\n"
193 "del hi <hit> | all\n"201 "del hi <hit> | all\n"
@@ -226,6 +234,51 @@
226;234;
227235
228/**236/**
237 * A help string containing the usage of @c hipfwconf.
238 *
239 * @note If you added a new action, do not forget to add a brief usage below
240 * for the action.
241 */
242static const char *hipfwconf_usage =
243 HIPCONF_HIPFW_KEYWORD
244 " <command>\n\n"
245 "HIP firewall commands:\n"
246 "get ha <hit> | all\n";
247
248/**
249 * Send a message to hipd or hipfw and optionally receive an answer.
250 *
251 * @param msg The message to be sent. The respective answer will be stored
252 * here as well.
253 * @param send_only 1 if no response from hipd should be requested.
254 * 0 if it should block until a response from hipd is received.
255 * This option has no effect when sending messages to hipfw.
256 *
257 * @return 0 on success
258 * -1 on error
259 */
260static int send_receive_message(struct hip_common *msg,
261 const int send_only)
262{
263 if (daemon_name == HIP_DAEMON) {
264 if (hip_send_recv_daemon_info(msg, send_only, 0)) {
265 HIP_ERROR("Failed to send user message to the HIP daemon.\n");
266 return -1;
267 }
268 } else if (daemon_name == HIP_FIREWALL) {
269 if (hip_send_recv_firewall_info(msg)) {
270 HIP_ERROR("Failed to send user message to the HIP firewall.\n");
271 return -1;
272 }
273 } else {
274 HIP_ERROR("Destination daemon process unknown.\n");
275 return -1;
276 }
277
278 return 0;
279}
280
281/**
229 * Query hipd for the HITs of the local host282 * Query hipd for the HITs of the local host
230 *283 *
231 * @param msg input/output message for the query/response for hipd284 * @param msg input/output message for the query/response for hipd
@@ -510,6 +563,25 @@
510/* Non-static functions -> global scope */563/* Non-static functions -> global scope */
511564
512/**565/**
566 * Map daemon / firewall keyword to its respective enum.
567 *
568 * @param argv an array of strings (command line args to hipconf)
569 * @return HIP_DAEMON in case of hipd keyword
570 * HIP_FIREWALL in case of hipfw keyword
571 * UNKNOWN_KEYWORD else
572 */
573static enum daemon_name conf_get_process(const char *const argv[])
574{
575 if (!strcmp(HIPCONF_HIPD_KEYWORD, argv[1])) {
576 return HIP_DAEMON;
577 } else if (!strcmp(HIPCONF_HIPFW_KEYWORD, argv[1])) {
578 return HIP_FIREWALL;
579 }
580
581 return UNKNOWN_KEYWORD;
582}
583
584/**
513 * Map a symbolic hipconf action (=add/del) into a number585 * Map a symbolic hipconf action (=add/del) into a number
514 *586 *
515 * @param argv an array of strings (command line args to hipconf)587 * @param argv an array of strings (command line args to hipconf)
@@ -526,61 +598,61 @@
526{598{
527 int ret = -1;599 int ret = -1;
528600
529 if (!strcmp("add", argv[1])) {601 if (!strcmp("add", argv[2])) {
530 ret = ACTION_ADD;602 ret = ACTION_ADD;
531 } else if (!strcmp("del", argv[1])) {603 } else if (!strcmp("del", argv[2])) {
532 ret = ACTION_DEL;604 ret = ACTION_DEL;
533 } else if (!strcmp("new", argv[1])) {605 } else if (!strcmp("new", argv[2])) {
534 ret = ACTION_NEW;606 ret = ACTION_NEW;
535 } else if (!strcmp("get", argv[1])) {607 } else if (!strcmp("get", argv[2])) {
536 ret = ACTION_GET;608 ret = ACTION_GET;
537 } else if (!strcmp("set", argv[1])) {609 } else if (!strcmp("set", argv[2])) {
538 ret = ACTION_SET;610 ret = ACTION_SET;
539 } else if (!strcmp("inc", argv[1])) {611 } else if (!strcmp("inc", argv[2])) {
540 ret = ACTION_INC;612 ret = ACTION_INC;
541 } else if (!strcmp("dec", argv[1])) {613 } else if (!strcmp("dec", argv[2])) {
542 ret = ACTION_DEC;614 ret = ACTION_DEC;
543 } else if (!strcmp("rst", argv[1])) {615 } else if (!strcmp("rst", argv[2])) {
544 ret = ACTION_RST;616 ret = ACTION_RST;
545 } else if (!strcmp("run", argv[1])) {617 } else if (!strcmp("run", argv[2])) {
546 ret = ACTION_RUN;618 ret = ACTION_RUN;
547 } else if (!strcmp("load", argv[1])) {619 } else if (!strcmp("load", argv[2])) {
548 ret = ACTION_LOAD;620 ret = ACTION_LOAD;
549 } else if (!strcmp("heartbeat", argv[1])) {621 } else if (!strcmp("heartbeat", argv[2])) {
550 ret = ACTION_HEARTBEAT;622 ret = ACTION_HEARTBEAT;
551 } else if (!strcmp("locator", argv[1])) {623 } else if (!strcmp("locator", argv[2])) {
552 ret = ACTION_LOCATOR;624 ret = ACTION_LOCATOR;
553 } else if (!strcmp("debug", argv[1])) {625 } else if (!strcmp("debug", argv[2])) {
554 ret = ACTION_DEBUG;626 ret = ACTION_DEBUG;
555 } else if (!strcmp("transform", argv[1])) {627 } else if (!strcmp("transform", argv[2])) {
556 ret = ACTION_TRANSORDER;628 ret = ACTION_TRANSORDER;
557 } else if (!strcmp("reinit", argv[1])) {629 } else if (!strcmp("reinit", argv[2])) {
558 ret = ACTION_REINIT;630 ret = ACTION_REINIT;
559 } else if (!strcmp("manual-update", argv[1])) {631 } else if (!strcmp("manual-update", argv[2])) {
560 ret = ACTION_MANUAL_UPDATE;632 ret = ACTION_MANUAL_UPDATE;
561 } else if (!strcmp("hit-to-lsi", argv[1])) {633 } else if (!strcmp("hit-to-lsi", argv[2])) {
562 ret = ACTION_HIT_TO_LSI;634 ret = ACTION_HIT_TO_LSI;
563 } else if (!strcmp("nsupdate", argv[1])) {635 } else if (!strcmp("nsupdate", argv[2])) {
564 ret = ACTION_NSUPDATE;636 ret = ACTION_NSUPDATE;
565 } else if (!strcmp("hit-to-ip-set", argv[1])) {637 } else if (!strcmp("hit-to-ip-set", argv[2])) {
566 ret = ACTION_HIT_TO_IP_SET;638 ret = ACTION_HIT_TO_IP_SET;
567 } else if (!strcmp("hit-to-ip", argv[1])) {639 } else if (!strcmp("hit-to-ip", argv[2])) {
568 ret = ACTION_HIT_TO_IP;640 ret = ACTION_HIT_TO_IP;
569 } else if (!strcmp("shotgun", argv[1])) {641 } else if (!strcmp("shotgun", argv[2])) {
570 ret = ACTION_SHOTGUN;642 ret = ACTION_SHOTGUN;
571 } else if (!strcmp("lsi-to-hit", argv[1])) {643 } else if (!strcmp("lsi-to-hit", argv[2])) {
572 ret = ACTION_LSI_TO_HIT;644 ret = ACTION_LSI_TO_HIT;
573 } else if (!strcmp("nat", argv[1])) {645 } else if (!strcmp("nat", argv[2])) {
574 if (!strcmp("port", argv[2])) {646 if (!strcmp("port", argv[3])) {
575 if (!strcmp("local", argv[3])) {647 if (!strcmp("local", argv[4])) {
576 ret = ACTION_NAT_LOCAL_PORT;648 ret = ACTION_NAT_LOCAL_PORT;
577 } else if (!strcmp("peer", argv[3])) {649 } else if (!strcmp("peer", argv[4])) {
578 ret = ACTION_NAT_PEER_PORT;650 ret = ACTION_NAT_PEER_PORT;
579 }651 }
580 } else {652 } else {
581 ret = ACTION_NAT;653 ret = ACTION_NAT;
582 }654 }
583 } else if (!strcmp("broadcast", argv[1])) {655 } else if (!strcmp("broadcast", argv[2])) {
584 ret = ACTION_BROADCAST;656 ret = ACTION_BROADCAST;
585 }657 }
586658
@@ -670,45 +742,45 @@
670 ret = TYPE_HA;742 ret = TYPE_HA;
671 } else if (!strcmp("shotgun", text)) {743 } else if (!strcmp("shotgun", text)) {
672 ret = TYPE_SHOTGUN;744 ret = TYPE_SHOTGUN;
673 } else if ((!strcmp("all", text)) && (strcmp("rst", argv[1]) == 0)) {745 } else if ((!strcmp("all", text)) && (strcmp("rst", argv[2]) == 0)) {
674 ret = TYPE_RST;746 ret = TYPE_RST;
675 } else if ((!strcmp("peer_hit", text)) && (strcmp("rst", argv[1]) == 0)) {747 } else if ((!strcmp("peer_hit", text)) && (strcmp("rst", argv[2]) == 0)) {
676 ret = TYPE_RST;748 ret = TYPE_RST;
677 } else if (strcmp("nat", argv[1]) == 0) {749 } else if (strcmp("nat", argv[2]) == 0) {
678 if (argv[2] && strcmp("port", argv[2]) == 0) {750 if (argv[3] && strcmp("port", argv[3]) == 0) {
679 if (argv[3] && strcmp("local", argv[3]) == 0) {751 if (argv[4] && strcmp("local", argv[4]) == 0) {
680 ret = TYPE_NAT_LOCAL_PORT;752 ret = TYPE_NAT_LOCAL_PORT;
681 } else if (argv[3] && strcmp("peer", argv[3]) == 0) {753 } else if (argv[4] && strcmp("peer", argv[4]) == 0) {
682 ret = TYPE_NAT_PEER_PORT;754 ret = TYPE_NAT_PEER_PORT;
683 }755 }
684 } else {756 } else {
685 ret = TYPE_NAT;757 ret = TYPE_NAT;
686 }758 }
687 } else if (strcmp("locator", argv[1]) == 0) {759 } else if (strcmp("locator", argv[2]) == 0) {
688 ret = TYPE_LOCATOR;760 ret = TYPE_LOCATOR;
689 } else if (!strcmp("debug", text)) {761 } else if (!strcmp("debug", text)) {
690 ret = TYPE_DEBUG;762 ret = TYPE_DEBUG;
691 } else if (!strcmp("order", text)) {763 } else if (!strcmp("order", text)) {
692 ret = TYPE_ORDER;764 ret = TYPE_ORDER;
693 } else if (strcmp("heartbeat", argv[1]) == 0) {765 } else if (strcmp("heartbeat", argv[2]) == 0) {
694 ret = TYPE_HEARTBEAT;766 ret = TYPE_HEARTBEAT;
695 } else if (!strcmp("ttl", text)) {767 } else if (!strcmp("ttl", text)) {
696 ret = TYPE_TTL;768 ret = TYPE_TTL;
697 } else if (!strcmp("config", text)) {769 } else if (!strcmp("config", text)) {
698 ret = TYPE_CONFIG;770 ret = TYPE_CONFIG;
699 } else if (strcmp("manual-update", argv[1]) == 0) {771 } else if (strcmp("manual-update", argv[2]) == 0) {
700 ret = TYPE_MANUAL_UPDATE;772 ret = TYPE_MANUAL_UPDATE;
701 } else if (strcmp("hit-to-lsi", argv[1]) == 0) {773 } else if (strcmp("hit-to-lsi", argv[2]) == 0) {
702 ret = TYPE_HIT_TO_LSI;774 ret = TYPE_HIT_TO_LSI;
703 } else if (strcmp("nsupdate", argv[1]) == 0) {775 } else if (strcmp("nsupdate", argv[2]) == 0) {
704 ret = TYPE_NSUPDATE;776 ret = TYPE_NSUPDATE;
705 } else if (strcmp("hit-to-ip-set", argv[1]) == 0) {777 } else if (strcmp("hit-to-ip-set", argv[2]) == 0) {
706 ret = TYPE_HIT_TO_IP_SET;778 ret = TYPE_HIT_TO_IP_SET;
707 } else if (strcmp("hit-to-ip", argv[1]) == 0) {779 } else if (strcmp("hit-to-ip", argv[2]) == 0) {
708 ret = TYPE_HIT_TO_IP;780 ret = TYPE_HIT_TO_IP;
709 } else if (strcmp("lsi-to-hit", argv[1]) == 0) {781 } else if (strcmp("lsi-to-hit", argv[2]) == 0) {
710 ret = TYPE_LSI_TO_HIT;782 ret = TYPE_LSI_TO_HIT;
711 } else if (strcmp("broadcast", argv[1]) == 0) {783 } else if (strcmp("broadcast", argv[2]) == 0) {
712 ret = TYPE_BROADCAST;784 ret = TYPE_BROADCAST;
713 } else {785 } else {
714 HIP_DEBUG("ERROR: NO MATCHES FOUND \n");786 HIP_DEBUG("ERROR: NO MATCHES FOUND \n");
@@ -725,7 +797,7 @@
725 * here in the switch(action) block.797 * here in the switch(action) block.
726 * @param action integer value for an action798 * @param action integer value for an action
727 * @return an index for argv[], which indicates the type argument.799 * @return an index for argv[], which indicates the type argument.
728 * Usually either 1 or 2.800 * Usually either 2 or 3.
729 */801 */
730static int conf_get_type_arg(int action)802static int conf_get_type_arg(int action)
731{803{
@@ -753,15 +825,15 @@
753 case ACTION_HIT_TO_IP:825 case ACTION_HIT_TO_IP:
754 case ACTION_HIT_TO_IP_SET:826 case ACTION_HIT_TO_IP_SET:
755 case ACTION_BROADCAST:827 case ACTION_BROADCAST:
828 type_arg = 3;
829 break;
830 case ACTION_MANUAL_UPDATE:
831 case ACTION_HIT_TO_LSI:
832 case ACTION_LSI_TO_HIT:
833 case ACTION_DEBUG:
834 case ACTION_SHOTGUN:
756 type_arg = 2;835 type_arg = 2;
757 break;836 break;
758 case ACTION_MANUAL_UPDATE:
759 case ACTION_HIT_TO_LSI:
760 case ACTION_LSI_TO_HIT:
761 case ACTION_DEBUG:
762 case ACTION_SHOTGUN:
763 type_arg = 1;
764 break;
765 default:837 default:
766 break;838 break;
767 }839 }
@@ -816,9 +888,9 @@
816 * Handles the hipconf commands where the type is @c server. Creates a user888 * Handles the hipconf commands where the type is @c server. Creates a user
817 * message from the function parameters @c msg, @c action and @c opt[]. The889 * message from the function parameters @c msg, @c action and @c opt[]. The
818 * command line that this function parses is of type:890 * command line that this function parses is of type:
819 * <code>tools/hipconf <b>add</b> server &lt;SERVICES&gt; &lt;SERVER HIT&gt;891 * <code>tools/hipconf daemon <b>add</b> server &lt;SERVICES&gt; &lt;SERVER HIT&gt;
820 * &lt;SERVER IP ADDRESS&gt; &lt;LIFETIME&gt;</code> or892 * &lt;SERVER IP ADDRESS&gt; &lt;LIFETIME&gt;</code> or
821 * <code>tools/hipconf <b>del</b> server &lt;SERVICES&gt; &lt;SERVER HIT&gt;893 * <code>tools/hipconf daemon <b>del</b> server &lt;SERVICES&gt; &lt;SERVER HIT&gt;
822 * &lt;SERVER IP ADDRESS&gt;</code>, where <code>&lt;SERVICES&gt;</code> is a list of894 * &lt;SERVER IP ADDRESS&gt;</code>, where <code>&lt;SERVICES&gt;</code> is a list of
823 * the services to which we want to register or cancel or registration. The895 * the services to which we want to register or cancel or registration. The
824 * list can consist of any number of the strings @c rvs, @c relay,896 * list can consist of any number of the strings @c rvs, @c relay,
@@ -1999,9 +2071,9 @@
1999}2071}
20002072
2001/**2073/**
2002 * Handle e.g. "hipconf run normal firefox". Enables HIP support2074 * Handle e.g. "hipconf daemon run normal firefox".
2003 * for the given application using LD_PRELOAD. This means that2075 * Enables HIP support for the given application using LD_PRELOAD. This means
2004 * all getaddrinfo() calls go through the modified libinet6 library.2076 * that all getaddrinfo() calls go through the modified libinet6 library.
2005 * This function is depracated.2077 * This function is depracated.
2006 *2078 *
2007 * @param msg input/output message for the query/response for hipd2079 * @param msg input/output message for the query/response for hipd
@@ -2045,10 +2117,10 @@
2045 HIP_IFEL(optc > 1, -1, "Too many arguments\n");2117 HIP_IFEL(optc > 1, -1, "Too many arguments\n");
20462118
2047 HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_GET_HA_INFO, 0), -1,2119 HIP_IFEL(hip_build_user_hdr(msg, HIP_MSG_GET_HA_INFO, 0), -1,
2048 "Building of daemon header failed\n");2120 "Building of user msg header failed\n");
20492121
2050 HIP_IFEL(hip_send_recv_daemon_info(msg, send_only, 0), -1,2122 HIP_IFEL(send_receive_message(msg, send_only), -1,
2051 "send recv daemon info\n");2123 "send recv info\n");
20522124
2053 while ((current_param = hip_get_next_param(msg, current_param))) {2125 while ((current_param = hip_get_next_param(msg, current_param))) {
2054 ha = hip_get_param_contents_direct(current_param);2126 ha = hip_get_param_contents_direct(current_param);
@@ -2316,8 +2388,9 @@
2316 *comment = '\0';2388 *comment = '\0';
2317 }2389 }
23182390
2319 /* prefix the contents of the line with" hipconf" */2391 /* prefix the contents of the line with" hipconf HIPCONF_HIPD_KEYWORD"
2320 res_len = sprintf(str, "hipconf %s", c);2392 * Only hipd parses config files as hipconf commands, hardcode it as target */
2393 res_len = sprintf(str, "hipconf %s %s", HIPCONF_HIPD_KEYWORD, c);
2321 if (str[res_len] == '\n') {2394 if (str[res_len] == '\n') {
2322 str[res_len] = '\0';2395 str[res_len] = '\0';
2323 }2396 }
@@ -2330,7 +2403,6 @@
2330 args[i++] = token;2403 args[i++] = token;
2331 token = strtok(NULL, " \t");2404 token = strtok(NULL, " \t");
2332 }2405 }
2333
2334 err = hip_do_hipconf(i, args, 1);2406 err = hip_do_hipconf(i, args, 1);
2335 if (err) {2407 if (err) {
2336 HIP_ERROR("Error on the following line: %s\n", line);2408 HIP_ERROR("Error on the following line: %s\n", line);
@@ -2454,9 +2526,18 @@
2454 struct hip_common *msg = NULL;2526 struct hip_common *msg = NULL;
24552527
2456 /* Check that we have at least one command line argument. */2528 /* Check that we have at least one command line argument. */
2457 if (argc < 2) {2529 if (argc < 3) {
2458 HIP_ERROR("Invalid arguments.\n\n%s usage:\n%s\n",2530 HIP_ERROR("Invalid arguments.\nUsage to communicate with HIP daemon:\n %s %s\n"
2459 argv[0], hipconf_usage);2531 "\nUsage to communicate with HIP firewall:\n %s %s\n",
2532 argv[0], hipconf_usage, argv[0], hipfwconf_usage);
2533 return -1;
2534 }
2535
2536 /* set context for this conf command */
2537 daemon_name = conf_get_process(argv);
2538 if (daemon_name == UNKNOWN_KEYWORD) {
2539 HIP_ERROR("Invalid target process argument '%s'. Expected '%s' or '%s'.\n",
2540 argv[1], HIPCONF_HIPD_KEYWORD, HIPCONF_HIPFW_KEYWORD);
2460 return -1;2541 return -1;
2461 }2542 }
24622543
@@ -2464,14 +2545,14 @@
2464 action = conf_get_action(argv);2545 action = conf_get_action(argv);
24652546
2466 if (action == -1) {2547 if (action == -1) {
2467 HIP_ERROR("Invalid action argument '%s'\n", argv[1]);2548 HIP_ERROR("Invalid action argument '%s'\n", argv[2]);
2468 return -1;2549 return -1;
2469 }2550 }
24702551
2471 /* Check that we have at least the minimum number of arguments2552 /* Check that we have at least the minimum number of arguments
2472 * for the given action. */2553 * for the given action. */
2473 if (argc < conf_check_action_argc(action) + 2) {2554 if (argc < conf_check_action_argc(action) + 3) {
2474 HIP_ERROR("Not enough arguments given for the action '%s'\n", argv[1]);2555 HIP_ERROR("Not enough arguments given for the action '%s'\n", argv[2]);
2475 return -1;2556 return -1;
2476 }2557 }
24772558
@@ -2499,25 +2580,23 @@
2499 /* Call handler function from the handler function pointer2580 /* Call handler function from the handler function pointer
2500 * array at index "type" with given commandline arguments.2581 * array at index "type" with given commandline arguments.
2501 * The functions build a hip_common message. */2582 * The functions build a hip_common message. */
2502 if (argc == 3) {2583 if (argc == 4) {
2503 err = (*action_handler[type])(msg, action, &argv[2], argc - 3, send_only);2584 err = (*action_handler[type])(msg, action, &argv[3], argc - 4, send_only);
2504 } else {2585 } else {
2505 err = (*action_handler[type])(msg, action, &argv[3], argc - 3, send_only);2586 err = (*action_handler[type])(msg, action, &argv[4], argc - 4, send_only);
2506 }2587 }
25072588
2508 if (err != 0) {2589 if (err != 0) {
2509 HIP_ERROR("Failed to send a message to the HIP daemon.\n");2590 HIP_ERROR("Failed to send user message.\n");
2510 goto out_err;2591 goto out_err;
2511 }2592 }
25122593
2513 /* hipconf new hi does not involve any messages to hipd */2594 /* hipconf daemon new hi does not involve any messages to hipd */
2514 if (hip_get_msg_type(msg) == 0) {2595 if (hip_get_msg_type(msg) == 0) {
2515 goto out_err;2596 goto out_err;
2516 }2597 }
25172598
2518 /* Send message to hipd */2599 send_receive_message(msg, send_only);
2519 HIP_IFEL(hip_send_recv_daemon_info(msg, send_only, 0), -1,
2520 "Failed to send user message to the HIP daemon.\n");
25212600
2522 HIP_INFO("User message was sent successfully to the HIP daemon.\n");2601 HIP_INFO("User message was sent successfully to the HIP daemon.\n");
25232602
@@ -2525,7 +2604,8 @@
2525 free(msg);2604 free(msg);
25262605
2527 if (err) {2606 if (err) {
2528 HIP_ERROR("(Check syntax for hipconf. Is hipd running or root privilege needed?)\n");2607 HIP_ERROR("(Check syntax for hipconf. Is the daemon running or root"
2608 " privilege needed?)\n");
2529 }2609 }
25302610
2531 return err;2611 return err;
25322612
=== modified file 'lib/core/conf.h'
--- lib/core/conf.h 2011-08-15 14:11:56 +0000
+++ lib/core/conf.h 2011-11-08 17:09:18 +0000
@@ -54,6 +54,10 @@
54#define ACTION_ADD 154#define ACTION_ADD 1
55#define ACTION_NEW 355#define ACTION_NEW 3
5656
57/* keywords used to identify hipd / hipfw as target of hipconf command */
58#define HIPCONF_HIPD_KEYWORD "daemon"
59#define HIPCONF_HIPFW_KEYWORD "firewall"
60
57int hip_handle_exec_app(int fork, int type, int argc,61int hip_handle_exec_app(int fork, int type, int argc,
58 const char *const argv[]);62 const char *const argv[]);
59int hip_do_hipconf(int argc, const char *argv[], int send_only);63int hip_do_hipconf(int argc, const char *argv[], int send_only);
6064
=== modified file 'lib/core/hostid.c'
--- lib/core/hostid.c 2011-10-25 21:14:16 +0000
+++ lib/core/hostid.c 2011-11-08 17:09:18 +0000
@@ -710,7 +710,7 @@
710710
711 switch (action) {711 switch (action) {
712 case ACTION_NEW:712 case ACTION_NEW:
713 /* Default directory is created only in "hipconf new default hi" */713 /* Default directory is created only in "hipconf daemon new default hi" */
714 if (use_default) {714 if (use_default) {
715 if ((err = check_and_create_dir(HIPL_SYSCONFDIR,715 if ((err = check_and_create_dir(HIPL_SYSCONFDIR,
716 HIP_DIR_MODE))) {716 HIP_DIR_MODE))) {
717717
=== modified file 'lib/core/message.c'
--- lib/core/message.c 2011-10-25 21:44:47 +0000
+++ lib/core/message.c 2011-11-08 17:09:18 +0000
@@ -40,7 +40,7 @@
40 * hence the message does not block.40 * hence the message does not block.
41 *41 *
42 * Use the synchronous message interface only when you expect the42 * Use the synchronous message interface only when you expect the
43 * request message to be completed immediately. For example, "hipconf43 * request message to be completed immediately. For example, "hipconf daemon
44 * get ha all" was safe to be implemented with synchronous messaging44 * get ha all" was safe to be implemented with synchronous messaging
45 * because hipd can process the request immediately.45 * because hipd can process the request immediately.
46 *46 *
@@ -86,6 +86,7 @@
86#include <sys/time.h>86#include <sys/time.h>
87#include <sys/types.h>87#include <sys/types.h>
8888
89#include "lib/core/conf.h"
89#include "lib/tool/nlink.h"90#include "lib/tool/nlink.h"
90#include "builder.h"91#include "builder.h"
91#include "common.h"92#include "common.h"
@@ -144,7 +145,7 @@
144 } while (timeout_left > 0 && errno == EAGAIN && bytes < 0);145 } while (timeout_left > 0 && errno == EAGAIN && bytes < 0);
145146
146 if (bytes < 0) {147 if (bytes < 0) {
147 HIP_ERROR("recv() peek error (is hipd running?)\n");148 HIP_ERROR("recv() peek error (is the daemon running?)\n");
148 err = -EAGAIN;149 err = -EAGAIN;
149 goto out_err;150 goto out_err;
150 } else if (bytes < hdr_size) {151 } else if (bytes < hdr_size) {
@@ -178,6 +179,30 @@
178}179}
179180
180/**181/**
182 * Connect a socket to the loopback address of hipd or hipfw.
183 *
184 * @param hip_user_sock The socket to connect.
185 * @param port The port to connect.
186 * @return zero on success and negative on failure
187 * @note currently only SOCK_DGRAM and AF_INET6 are supported
188 */
189static int hip_connect(int hip_user_sock, int port)
190{
191 struct sockaddr_in6 addr = { 0 };
192
193 addr.sin6_family = AF_INET6;
194 addr.sin6_port = htons(port);
195 addr.sin6_addr = in6addr_loopback;
196
197 if (connect(hip_user_sock, (struct sockaddr *) &addr, sizeof(addr))) {
198 HIP_ERROR("connection failed: %s\n", strerror(errno));
199 return -1;
200 }
201
202 return 0;
203}
204
205/**
181 * Connect a socket to the loop back address of hipd206 * Connect a socket to the loop back address of hipd
182 *207 *
183 * @param hip_user_sock The socket to connect. Currently only SOCK_DGRAM208 * @param hip_user_sock The socket to connect. Currently only SOCK_DGRAM
@@ -187,21 +212,7 @@
187 */212 */
188int hip_daemon_connect(int hip_user_sock)213int hip_daemon_connect(int hip_user_sock)
189{214{
190 int err = 0;215 return hip_connect(hip_user_sock, HIP_DAEMON_LOCAL_PORT);
191 struct sockaddr_in6 daemon_addr = { 0 };
192 // We're using system call here add thus resetting errno.
193 errno = 0;
194
195 daemon_addr.sin6_family = AF_INET6;
196 daemon_addr.sin6_port = htons(HIP_DAEMON_LOCAL_PORT);
197 daemon_addr.sin6_addr = in6addr_loopback;
198
199 HIP_IFEL(connect(hip_user_sock, (struct sockaddr *) &daemon_addr,
200 sizeof(daemon_addr)), -1, "connection to daemon failed\n");
201
202out_err:
203
204 return err;
205}216}
206217
207/**218/**
@@ -211,7 +222,7 @@
211 * obtain a port number below 1024. In UNIX/Linux this means that the222 * obtain a port number below 1024. In UNIX/Linux this means that the
212 * process has superuser privileges. Hipd uses the port number to223 * process has superuser privileges. Hipd uses the port number to
213 * verify if the caller has sufficient privileges to execute224 * verify if the caller has sufficient privileges to execute
214 * e.g. "hipconf rst all". The function falls back to non-privileged225 * e.g. "hipconf daemon rst all". The function falls back to non-privileged
215 * ports if it fails to obtain a privileged port and then hipd allows226 * ports if it fails to obtain a privileged port and then hipd allows
216 * only certain operations for the calling process.227 * only certain operations for the calling process.
217 *228 *
@@ -319,23 +330,30 @@
319#define EHIP 500330#define EHIP 500
320331
321/**332/**
322 * Send and receive data with hipd. Do not call this function directly, use333 * Send and receive data with hipd or hipfw. Do not call this function directly,
323 * hip_send_recv_daemon_info instead!334 * use hip_send_recv_daemon_info or hip_send_recv_firewall_info instead!
324 *335 *
325 * @param msg the message to send to hipd336 * @param msg The message to send to hipd or hipfw
326 * @param opt_socket Optional socket to use for the message exchange. When337 * @param opt_socket Optional socket to use for the message exchange. When
327 * set to zero, the function creates a temporary socket338 * set to zero, the function creates a temporary socket
328 * and closes it after the transaction is completed.339 * and closes it after the transaction is completed.
340 * @param port The port to send the message to.
329 * @return zero on success and negative on failure341 * @return zero on success and negative on failure
330 * @note currently only SOCK_DGRAM and AF_INET6 are supported342 * @note currently only SOCK_DGRAM and AF_INET6 are supported
331 */343 */
332static int send_recv_daemon_info_internal(struct hip_common *msg,344static int send_recv_info_internal(struct hip_common *msg, int opt_socket, int port)
333 int opt_socket)
334{345{
335 int hip_user_sock = 0, err = 0, n = 0, len = 0;346 int hip_user_sock = 0, err = 0, n = 0, len = 0;
336 struct sockaddr_in6 addr = { 0 };347 struct sockaddr_in6 addr = { 0 };
337 uint8_t msg_type_old, msg_type_new;348 uint8_t msg_type_old, msg_type_new;
349 const char *receiver;
338350
351 /* determine receiver to print correct debug / error messages */
352 if (port == HIP_FIREWALL_PORT) {
353 receiver = HIPCONF_HIPFW_KEYWORD;
354 } else {
355 receiver = HIPCONF_HIPD_KEYWORD;
356 }
339 msg_type_old = hip_get_msg_type(msg);357 msg_type_old = hip_get_msg_type(msg);
340358
341 // We're using system call here and thus resetting errno.359 // We're using system call here and thus resetting errno.
@@ -354,9 +372,9 @@
354 HIP_IFEL(daemon_bind_socket(hip_user_sock,372 HIP_IFEL(daemon_bind_socket(hip_user_sock,
355 (struct sockaddr *) &addr), -1,373 (struct sockaddr *) &addr), -1,
356 "bind failed\n");374 "bind failed\n");
357 /* Connect to hipd. Otherwise e.g. "hipconf get ha all"375 /* Connect to hipd or hipfw. Otherwise e.g. "hipconf daemon get ha all"
358 * blocks when hipd is not running. */376 * blocks when hipd is not running. */
359 HIP_IFEL(hip_daemon_connect(hip_user_sock), -1,377 HIP_IFEL(hip_connect(hip_user_sock, port), -1,
360 "connect failed\n");378 "connect failed\n");
361 }379 }
362380
@@ -368,14 +386,18 @@
368 /* Require a response from hipd */386 /* Require a response from hipd */
369 hip_set_msg_response(msg, 1);387 hip_set_msg_response(msg, 1);
370388
371 n = sendto_hipd(hip_user_sock, msg, len);389 if (port == HIP_FIREWALL_PORT) {
390 n = send(hip_user_sock, msg, len, 0);
391 } else {
392 n = sendto_hipd(hip_user_sock, msg, len);
393 }
372 if (n < len) {394 if (n < len) {
373 HIP_ERROR("Could not send message to daemon.\n");395 HIP_ERROR("Could not send message to %s.\n", receiver);
374 err = -ECOMM;396 err = -ECOMM;
375 goto out_err;397 goto out_err;
376 }398 }
377399
378 HIP_DEBUG("Waiting to receive daemon info.\n");400 HIP_DEBUG("Waiting to receive %s info.\n", receiver);
379401
380 if ((len = peek_recv_total_len(hip_user_sock, 0, HIP_DEFAULT_MSG_TIMEOUT)) < 0) {402 if ((len = peek_recv_total_len(hip_user_sock, 0, HIP_DEFAULT_MSG_TIMEOUT)) < 0) {
381 err = len;403 err = len;
@@ -390,14 +412,14 @@
390 "Message sync problem. Expected %d, got %d\n",412 "Message sync problem. Expected %d, got %d\n",
391 msg_type_old, msg_type_new);413 msg_type_old, msg_type_new);
392414
393 HIP_DEBUG("%d bytes received from HIP daemon\n", n);415 HIP_DEBUG("%d bytes received from HIP %s.\n", n, receiver);
394416
395 if (n == 0) {417 if (n == 0) {
396 HIP_INFO("The HIP daemon has performed an orderly shutdown.\n");418 HIP_INFO("The HIP %s has performed an orderly shutdown.\n", receiver);
397 // Note. This is not an error condition, thus we return zero.419 // Note. This is not an error condition, thus we return zero.
398 goto out_err;420 goto out_err;
399 } else if (n < (int) sizeof(struct hip_common)) {421 } else if (n < (int) sizeof(struct hip_common)) {
400 HIP_ERROR("Could not receive message from daemon.\n");422 HIP_ERROR("Could not receive message from %s.\n", receiver);
401 goto out_err;423 goto out_err;
402 }424 }
403425
@@ -442,7 +464,7 @@
442 struct sockaddr_in6 addr = { 0 };464 struct sockaddr_in6 addr = { 0 };
443465
444 if (!send_only) {466 if (!send_only) {
445 return send_recv_daemon_info_internal(msg, opt_socket);467 return send_recv_info_internal(msg, opt_socket, HIP_DAEMON_LOCAL_PORT);
446 }468 }
447469
448 if (opt_socket) {470 if (opt_socket) {
@@ -479,6 +501,21 @@
479}501}
480502
481/**503/**
504 * A generic function to send messages to hipfw with subsequent reply. This will
505 * block the process until the hipfw sends the response or a predefined timeout
506 * is exceeded.
507 *
508 * @param msg An input/output parameter. As input, contains the
509 * message to be sent to hipfw. As output, hipfw response
510 * will be written here.
511 * @return zero on success and negative on failure.
512 */
513int hip_send_recv_firewall_info(struct hip_common *const msg)
514{
515 return send_recv_info_internal(msg, 0, HIP_FIREWALL_PORT);
516}
517
518/**
482 * Read an interprocess (user) message519 * Read an interprocess (user) message
483 *520 *
484 * @param sockfd a socket from where to read521 * @param sockfd a socket from where to read
485522
=== modified file 'lib/core/message.h'
--- lib/core/message.h 2011-08-15 14:11:56 +0000
+++ lib/core/message.h 2011-11-08 17:09:18 +0000
@@ -46,5 +46,6 @@
46int hip_send_recv_daemon_info(struct hip_common *msg,46int hip_send_recv_daemon_info(struct hip_common *msg,
47 int send_only,47 int send_only,
48 int opt_socket);48 int opt_socket);
49int hip_send_recv_firewall_info(struct hip_common *const msg);
4950
50#endif /* HIP_LIB_CORE_MESSAGE_H */51#endif /* HIP_LIB_CORE_MESSAGE_H */
5152
=== modified file 'lib/tool/nlink.c'
--- lib/tool/nlink.c 2011-10-25 21:14:16 +0000
+++ lib/tool/nlink.c 2011-11-08 17:09:18 +0000
@@ -146,7 +146,7 @@
146146
147 /* Transitioned from recvmsg() to recvfrom() due to147 /* Transitioned from recvmsg() to recvfrom() due to
148 * "Netlink overrun" errors when executing148 * "Netlink overrun" errors when executing
149 * "hipconf rst all" */149 * "hipconf daemon rst all" */
150150
151 status = recvfrom(nl->fd, buf, sizeof(buf),151 status = recvfrom(nl->fd, buf, sizeof(buf),
152 0, NULL, NULL);152 0, NULL, NULL);
153153
=== modified file 'tools/hipconf.c'
--- tools/hipconf.c 2011-08-15 14:11:56 +0000
+++ tools/hipconf.c 2011-11-08 17:09:18 +0000
@@ -53,7 +53,7 @@
53 hip_set_logdebug(LOGDEBUG_ALL);53 hip_set_logdebug(LOGDEBUG_ALL);
5454
55 HIP_IFEL(hip_do_hipconf(argc, argv, 0), -2,55 HIP_IFEL(hip_do_hipconf(argc, argv, 0), -2,
56 "Error: Cannot configure the HIP daemon.\n");56 "Error: Cannot configure the daemon.\n");
5757
58out_err:58out_err:
59 return err;59 return err;
6060
=== modified file 'tools/hipdnsproxy/hipdnsproxy.in'
--- tools/hipdnsproxy/hipdnsproxy.in 2011-06-09 19:11:46 +0000
+++ tools/hipdnsproxy/hipdnsproxy.in 2011-11-08 17:09:18 +0000
@@ -545,7 +545,7 @@
545 f.close()545 f.close()
546546
547 def map_hit_to_lsi(gp, hit):547 def map_hit_to_lsi(gp, hit):
548 cmd = "hipconf hit-to-lsi " + hit + " 2>&1"548 cmd = "hipconf daemon hit-to-lsi " + hit + " 2>&1"
549 #gp.fout.write("cmd - %s\n" % (cmd,))549 #gp.fout.write("cmd - %s\n" % (cmd,))
550 p = Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout550 p = Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
551 result = p.readline()551 result = p.readline()
@@ -558,7 +558,7 @@
558 return None558 return None
559559
560 def lsi_to_hit(gp, lsi):560 def lsi_to_hit(gp, lsi):
561 cmd = "hipconf lsi-to-hit " + lsi + " 2>&1"561 cmd = "hipconf daemon lsi-to-hit " + lsi + " 2>&1"
562 p = Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout562 p = Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout
563 result = p.readline()563 result = p.readline()
564 while result:564 while result:
@@ -570,7 +570,7 @@
570 return None570 return None
571571
572 def add_hit_ip_map(gp, hit, ip):572 def add_hit_ip_map(gp, hit, ip):
573 cmd = "hipconf add map " + hit + " " + ip + \573 cmd = "hipconf daemon add map " + hit + " " + ip + \
574 " > /dev/null 2>&1"574 " > /dev/null 2>&1"
575 gp.fout.write('Associating HIT %s with IP %s\n' % (hit, ip))575 gp.fout.write('Associating HIT %s with IP %s\n' % (hit, ip))
576 os.system(cmd)576 os.system(cmd)

Subscribers

People subscribed via source and target branches

to all changes: