'Process an OFPFC_ADD flow mod sent to the switch.'

def _flow_mod_add(self, flow_mod, connection, table):

    match = flow_mod.match
    priority = flow_mod.priority
    if (flow_mod.flags & OFPFF_EMERG):
        if ((flow_mod.idle_timeout != 0) or (flow_mod.hard_timeout != 0)):
            self.log.warn('Rejecting    emergency    flow    with    nonzero    timeout')
            self.send_error(type=OFPET_FLOW_MOD_FAILED, code=OFPFMFC_BAD_EMERG_TIMEOUT, ofp=flow_mod, connection=connection)
            return
        if (flow_mod.flags & OFPFF_SEND_FLOW_REM):
            self.log.warn('Rejecting    emergency    flow    with    flow    removal    flag')
            self.send_error(type=OFPET_FLOW_MOD_FAILED, code=OFPFMFC_EPERM, ofp=flow_mod, connection=connection)
            return
        self.log.warn('Rejecting    emergency    flow    (not    supported)')
        self.send_error(type=OFPET_FLOW_MOD_FAILED, code=OFPFMFC_ALL_TABLES_FULL, ofp=flow_mod, connection=connection)
        return
    new_entry = TableEntry.from_flow_mod(flow_mod)
    if (flow_mod.flags & OFPFF_CHECK_OVERLAP):
        if table.check_for_overlapping_entry(new_entry):
            self.send_error(type=OFPET_FLOW_MOD_FAILED, code=OFPFMFC_OVERLAP, ofp=flow_mod, connection=connection)
            return
    if (flow_mod.command == OFPFC_ADD):
        table.remove_matching_entries(match, priority=priority, strict=True)
    if (len(table) >= self.max_entries):
        self.send_error(type=OFPET_FLOW_MOD_FAILED, code=OFPFMFC_ALL_TABLES_FULL, ofp=flow_mod, connection=connection)
        return
    table.add_entry(new_entry)
