NSIS-ka
A free C++ implementation of NSIS protocols

Changeset 4569


Ignore:
Timestamp:
Oct 18, 2009, 3:16:21 PM (8 years ago)
Author:
stud-lenk
Message:
  • Fixed a bug when setting the outgoing interface by address only.
  • Improved logging.
  • Reduced logging if compiled without DEBUG_HARD.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • protlib/branches/20090723-multicast/src/cmsghdr_util.cpp

    r4211 r4569  
    4141}
    4242
     43#include <stdexcept>
     44
    4345#include "logfile.h"
    4446#include "cmsghdr_util.h"
     47#include "networkinterface.h"
    4548
    4649using namespace std;
     
    221224    assert(cmsg != NULL);
    222225
     226#ifdef DEBUG_HARD
     227    const char *methodname = "build_oif";
     228    DLog(methodname, "Adding outgoing interface " << outgoing_address << " (interface " << oif << ")");
     229#endif
     230
    223231    in6_pktinfo pktinfo;
    224232    unsigned int space_left = msg->msg_controllen - (cmsg - ((cmsghdr*)msg->msg_control));
     
    232240
    233241    pktinfo.ipi6_ifindex = oif;
     242#ifdef DEBUG_HARD
     243    DLog(methodname, "pktinfo.ipi6_ifindex: " << oif);
     244#endif
    234245
    235246    cmsg->cmsg_level = IPPROTO_IPV6;
     
    314325  if (rao != -1)
    315326  {
     327#ifdef DEBUG_HARD
    316328    DLog(methodname, "Adding IP ROA " << rao);
     329#endif
    317330    int rv = cmsghdr_build_rao(msg, cmsgptr, rao);
    318331    if (rv != 0) {
     
    328341  if (hlim > 0)
    329342  {
     343#ifdef DEBUG_HARD
    330344    DLog(methodname, "Adding IP hop limit " << hlim);
     345#endif
    331346    int rv = cmsghdr_build_hlim(msg, cmsgptr, hlim);
    332347    if (rv != 0) {
     
    342357  if (oif > 0 || outgoing_address != NULL)
    343358  {
     359
     360    if (outgoing_address != NULL) {
     361#ifdef DEBUG_HARD
     362            DLog(methodname, "Adding outgoing IP address " << *outgoing_address);
     363#endif
     364            if (oif == 0) {
     365              try {
     366                networkinterface outgoing_address_interface(*outgoing_address);
     367                oif = outgoing_address_interface.get_index();
     368              } catch (std::invalid_argument& ia)
     369              {
     370                WLog(methodname, "The specified IP address " << outgoing_address
     371                                 << " is not assigned to any interface");
     372              }
     373            }
     374    }
     375#ifdef DEBUG_HARD
    344376    if (oif > 0)
    345             DLog(methodname, "Adding IP outgoing interface " << oif);
    346     if (outgoing_address != NULL)
    347             DLog(methodname, "Adding outgoing IP address " << *outgoing_address);
     377            DLog(methodname, "Adding outgoing interface " << oif);
     378#endif
    348379
    349380    int rv = cmsghdr_build_oif(msg, cmsgptr, outgoing_address, oif);
     
    360391}
    361392
     393#ifdef DEBUG_HARD
    362394inline const char *level_p(int level) {
    363395        if (level == IPPROTO_IPV6) return "IPv6";
     
    372404}
    373405
    374 #ifdef DEBUG_HARD
    375406void
    376407dump_cmsghdr(struct msghdr *c)
Note: See TracChangeset for help on using the changeset viewer.